Merge pull request #302195 from anthonyroussel/fix-oddjobd

nixos/oddjobd: enable dbus service to fix service startup
This commit is contained in:
Weijia Wang 2024-04-07 22:52:46 +02:00 committed by GitHub
commit d217732cef
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 73 additions and 35 deletions

View File

@ -4,26 +4,28 @@ let
cfg = config.programs.oddjobd;
in
{
options.programs.oddjobd = {
enable = lib.mkEnableOption "oddjob";
package = lib.mkPackageOption pkgs "oddjob" {};
options = {
programs.oddjobd = {
enable = lib.mkEnableOption "oddjob";
package = lib.mkPackageOption pkgs "oddjob" {};
};
};
config = lib.mkIf cfg.enable {
systemd.packages = [ cfg.package ];
systemd.services.oddjobd = {
wantedBy = [ "multi-user.target"];
after = [ "network.target"];
wantedBy = [ "multi-user.target" ];
after = [ "network.target" "dbus.service" ];
description = "DBUS Odd-job Daemon";
enable = true;
documentation = [ "man:oddjobd(8)" "man:oddjobd.conf(5)" ];
serviceConfig = {
Type = "dbus";
BusName = "org.freedesktop.oddjob";
ExecStart = "${lib.getBin cfg.package}/bin/oddjobd";
Type = "simple";
PIDFile = "/run/oddjobd.pid";
ExecStart = "${lib.getBin cfg.package}/bin/oddjobd -n -p /run/oddjobd.pid -t 300";
};
};
services.dbus.packages = [ cfg.package ];
};
meta.maintainers = with lib.maintainers; [ SohamG ];

View File

@ -652,6 +652,7 @@ in {
nzbget = handleTest ./nzbget.nix {};
nzbhydra2 = handleTest ./nzbhydra2.nix {};
ocis = handleTest ./ocis.nix {};
oddjobd = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./oddjobd.nix {};
oh-my-zsh = handleTest ./oh-my-zsh.nix {};
ollama = handleTest ./ollama.nix {};
ombi = handleTest ./ombi.nix {};

23
nixos/tests/oddjobd.nix Normal file
View File

@ -0,0 +1,23 @@
import ./make-test-python.nix ({ pkgs, lib, ... }: {
name = "oddjobd";
meta.maintainers = [ lib.maintainers.anthonyroussel ];
nodes.machine = { ... } : {
environment.systemPackages = [
pkgs.oddjob
];
programs.oddjobd.enable = true;
};
testScript = ''
start_all()
machine.wait_for_unit("oddjobd.service")
machine.wait_for_file("/run/oddjobd.pid")
with subtest("send oddjob listall request"):
result = machine.succeed("oddjob_request -s com.redhat.oddjob -o /com/redhat/oddjob -i com.redhat.oddjob listall")
assert ('(service="com.redhat.oddjob",object="/com/redhat/oddjob",interface="com.redhat.oddjob",method="listall")' in result)
'';
})

View File

@ -1,12 +1,15 @@
{ lib
, fetchurl
, stdenv
, autoreconfHook
, dbus
, libxml2
, pam
, pkg-config
, systemd
{
autoreconfHook,
dbus,
fetchpatch,
fetchurl,
lib,
libxml2,
nixosTests,
pam,
pkg-config,
stdenv,
systemd,
}:
stdenv.mkDerivation rec {
@ -14,34 +17,36 @@ stdenv.mkDerivation rec {
version = "0.34.7";
src = fetchurl {
url = "https://pagure.io/oddjob/archive/${pname}-${version}/oddjob-${pname}-${version}.tar.gz";
hash = "sha256-SUOsMH55HtEsk5rX0CXK0apDObTj738FGOaL5xZRnIM=";
url = "https://pagure.io/oddjob/archive/${pname}-${version}/oddjob-${pname}-${version}.tar.gz";
hash = "sha256-SUOsMH55HtEsk5rX0CXK0apDObTj738FGOaL5xZRnIM=";
};
patches = [
# Define SystemD service location using `with-systemdsystemunitdir` configure flag
(fetchpatch {
url = "https://pagure.io/oddjob/c/f63287a35107385dcb6e04a4c742077c9d1eab86.patch";
hash = "sha256-2mmw4pJhrIk4/47FM8zKH0dTQJWnntHPNmq8VAUWqJI=";
})
];
nativeBuildInputs = [
autoreconfHook
pkg-config
];
buildInputs =[
libxml2
buildInputs = [
dbus
libxml2
pam
systemd
];
postPatch = ''
substituteInPlace configure.ac \
--replace 'SYSTEMDSYSTEMUNITDIR=`pkg-config --variable=systemdsystemunitdir systemd 2> /dev/null`' "SYSTEMDSYSTEMUNITDIR=${placeholder "out"}" \
--replace 'SYSTEMDSYSTEMUNITDIR=`pkg-config --variable=systemdsystemunitdir systemd`' "SYSTEMDSYSTEMUNITDIR=${placeholder "out"}"
'';
configureFlags = [
"--prefix=${placeholder "out"}"
"--sysconfdir=${placeholder "out"}/etc"
"--with-selinux-acls=no"
"--with-selinux-labels=no"
"--disable-systemd"
"--with-systemdsystemunitdir=${placeholder "out"}/lib/systemd/system"
];
postConfigure = ''
@ -49,12 +54,19 @@ stdenv.mkDerivation rec {
--replace "globals.selinux_enabled" "FALSE"
'';
meta = with lib; {
# Requires a dbus-daemon environment
doCheck = false;
passthru.tests = {
inherit (nixosTests) oddjobd;
};
meta = {
changelog = "https://pagure.io/oddjob/blob/oddjob-${version}/f/ChangeLog";
description = "Odd Job Daemon";
homepage = "https://pagure.io/oddjob";
changelog = "https://pagure.io/oddjob/blob/oddjob-${version}/f/ChangeLog";
license = licenses.bsd0;
platforms = platforms.linux;
maintainers = with maintainers; [ SohamG ];
license = lib.licenses.bsd3;
maintainers = with lib.maintainers; [ SohamG ];
platforms = lib.platforms.linux;
};
}