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; cfg = config.programs.oddjobd;
in in
{ {
options.programs.oddjobd = { options = {
enable = lib.mkEnableOption "oddjob"; programs.oddjobd = {
package = lib.mkPackageOption pkgs "oddjob" {}; enable = lib.mkEnableOption "oddjob";
package = lib.mkPackageOption pkgs "oddjob" {};
};
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
systemd.packages = [ cfg.package ];
systemd.services.oddjobd = { systemd.services.oddjobd = {
wantedBy = [ "multi-user.target"]; wantedBy = [ "multi-user.target" ];
after = [ "network.target"]; after = [ "network.target" "dbus.service" ];
description = "DBUS Odd-job Daemon"; description = "DBUS Odd-job Daemon";
enable = true; enable = true;
documentation = [ "man:oddjobd(8)" "man:oddjobd.conf(5)" ]; documentation = [ "man:oddjobd(8)" "man:oddjobd.conf(5)" ];
serviceConfig = { serviceConfig = {
Type = "dbus"; Type = "simple";
BusName = "org.freedesktop.oddjob"; PIDFile = "/run/oddjobd.pid";
ExecStart = "${lib.getBin cfg.package}/bin/oddjobd"; 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 ]; meta.maintainers = with lib.maintainers; [ SohamG ];

View File

@ -652,6 +652,7 @@ in {
nzbget = handleTest ./nzbget.nix {}; nzbget = handleTest ./nzbget.nix {};
nzbhydra2 = handleTest ./nzbhydra2.nix {}; nzbhydra2 = handleTest ./nzbhydra2.nix {};
ocis = handleTest ./ocis.nix {}; ocis = handleTest ./ocis.nix {};
oddjobd = handleTestOn [ "x86_64-linux" "aarch64-linux" ] ./oddjobd.nix {};
oh-my-zsh = handleTest ./oh-my-zsh.nix {}; oh-my-zsh = handleTest ./oh-my-zsh.nix {};
ollama = handleTest ./ollama.nix {}; ollama = handleTest ./ollama.nix {};
ombi = handleTest ./ombi.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 autoreconfHook,
, stdenv dbus,
, autoreconfHook fetchpatch,
, dbus fetchurl,
, libxml2 lib,
, pam libxml2,
, pkg-config nixosTests,
, systemd pam,
pkg-config,
stdenv,
systemd,
}: }:
stdenv.mkDerivation rec { stdenv.mkDerivation rec {
@ -14,34 +17,36 @@ stdenv.mkDerivation rec {
version = "0.34.7"; version = "0.34.7";
src = fetchurl { src = fetchurl {
url = "https://pagure.io/oddjob/archive/${pname}-${version}/oddjob-${pname}-${version}.tar.gz"; url = "https://pagure.io/oddjob/archive/${pname}-${version}/oddjob-${pname}-${version}.tar.gz";
hash = "sha256-SUOsMH55HtEsk5rX0CXK0apDObTj738FGOaL5xZRnIM="; 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 = [ nativeBuildInputs = [
autoreconfHook autoreconfHook
pkg-config pkg-config
]; ];
buildInputs =[ buildInputs = [
libxml2
dbus dbus
libxml2
pam pam
systemd 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 = [ configureFlags = [
"--prefix=${placeholder "out"}" "--prefix=${placeholder "out"}"
"--sysconfdir=${placeholder "out"}/etc" "--sysconfdir=${placeholder "out"}/etc"
"--with-selinux-acls=no" "--with-selinux-acls=no"
"--with-selinux-labels=no" "--with-selinux-labels=no"
"--disable-systemd" "--with-systemdsystemunitdir=${placeholder "out"}/lib/systemd/system"
]; ];
postConfigure = '' postConfigure = ''
@ -49,12 +54,19 @@ stdenv.mkDerivation rec {
--replace "globals.selinux_enabled" "FALSE" --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"; description = "Odd Job Daemon";
homepage = "https://pagure.io/oddjob"; homepage = "https://pagure.io/oddjob";
changelog = "https://pagure.io/oddjob/blob/oddjob-${version}/f/ChangeLog"; license = lib.licenses.bsd3;
license = licenses.bsd0; maintainers = with lib.maintainers; [ SohamG ];
platforms = platforms.linux; platforms = lib.platforms.linux;
maintainers = with maintainers; [ SohamG ];
}; };
} }