From a5ab9470033a550bf510c26fd68a99f21586b39b Mon Sep 17 00:00:00 2001 From: snicket2100 <57048005+snicket2100@users.noreply.github.com> Date: Sat, 25 Jan 2020 00:28:25 +0100 Subject: [PATCH 1/3] irqbalance: systemd service config aligned with upstream Aligned systemd service config with the definition in the upstream repo: https://github.com/Irqbalance/irqbalance/blob/master/misc/irqbalance.service#L7. Other than adding some level of sandboxing it also fixes the "Daemon couldn't be bound to the file-based socket." warning reported on irqbalance startup due to the fact that the "/run/irqbalance" directory didn't exist. The "RuntimeDirectory" property makes sure it gets created. The aforementioned warning didn't cause any problems I could spot though. I have verified that both `irqbalance` as well as `irqbalance-ui` work fine with this new systemd service config. --- nixos/modules/services/hardware/irqbalance.nix | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/nixos/modules/services/hardware/irqbalance.nix b/nixos/modules/services/hardware/irqbalance.nix index b139154432c..39c139576bf 100644 --- a/nixos/modules/services/hardware/irqbalance.nix +++ b/nixos/modules/services/hardware/irqbalance.nix @@ -17,8 +17,15 @@ in irqbalance = { description = "irqbalance daemon"; path = [ pkgs.irqbalance ]; - serviceConfig = - { ExecStart = "${pkgs.irqbalance}/bin/irqbalance --foreground"; }; + serviceConfig = { + ExecStart = "${pkgs.irqbalance}/bin/irqbalance --foreground"; + CapabilityBoundingSet = ""; + NoNewPrivileges = "yes"; + ReadOnlyPaths = "/"; + ReadWritePaths = "/proc/irq"; + RestrictAddressFamilies = "AF_UNIX"; + RuntimeDirectory = "irqbalance/"; + }; wantedBy = [ "multi-user.target" ]; }; }; From 04bfeeac79b0dc857b89d9ef43ff6f1ddd349cff Mon Sep 17 00:00:00 2001 From: snicket2100 <57048005+snicket2100@users.noreply.github.com> Date: Sun, 2 Feb 2020 18:09:45 +0100 Subject: [PATCH 2/3] irqbalance: using systemd service definition from the package itself --- .../modules/services/hardware/irqbalance.nix | 19 ++----------------- pkgs/os-specific/linux/irqbalance/default.nix | 10 ++++++++++ 2 files changed, 12 insertions(+), 17 deletions(-) diff --git a/nixos/modules/services/hardware/irqbalance.nix b/nixos/modules/services/hardware/irqbalance.nix index 39c139576bf..c07e35943f2 100644 --- a/nixos/modules/services/hardware/irqbalance.nix +++ b/nixos/modules/services/hardware/irqbalance.nix @@ -13,25 +13,10 @@ in config = mkIf cfg.enable { - systemd.services = { - irqbalance = { - description = "irqbalance daemon"; - path = [ pkgs.irqbalance ]; - serviceConfig = { - ExecStart = "${pkgs.irqbalance}/bin/irqbalance --foreground"; - CapabilityBoundingSet = ""; - NoNewPrivileges = "yes"; - ReadOnlyPaths = "/"; - ReadWritePaths = "/proc/irq"; - RestrictAddressFamilies = "AF_UNIX"; - RuntimeDirectory = "irqbalance/"; - }; - wantedBy = [ "multi-user.target" ]; - }; - }; - environment.systemPackages = [ pkgs.irqbalance ]; + systemd.packages = [ pkgs.irqbalance ]; + }; } diff --git a/pkgs/os-specific/linux/irqbalance/default.nix b/pkgs/os-specific/linux/irqbalance/default.nix index 8dc9e2694d4..27f176f6a72 100644 --- a/pkgs/os-specific/linux/irqbalance/default.nix +++ b/pkgs/os-specific/linux/irqbalance/default.nix @@ -16,6 +16,16 @@ stdenv.mkDerivation rec { LDFLAGS = "-lncurses"; + postInstall = + '' + # Systemd service + mkdir -p $out/lib/systemd/system + grep -vi "EnvironmentFile" misc/irqbalance.service >$out/lib/systemd/system/irqbalance.service + substituteInPlace $out/lib/systemd/system/irqbalance.service \ + --replace /usr/sbin/irqbalance $out/bin/irqbalance \ + --replace ' $IRQBALANCE_ARGS' "" + ''; + meta = { homepage = https://github.com/Irqbalance/irqbalance; description = "A daemon to help balance the cpu load generated by interrupts across all of a systems cpus"; From c24a2d3e32d844d67f2155c7bf9c78ef42ebacf7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C3=B6rg=20Thalheim?= Date: Tue, 4 Feb 2020 14:19:04 +0000 Subject: [PATCH 3/3] nixos/irqbalance: re-add multi-user.target otherwise the service is never started by us. --- nixos/modules/services/hardware/irqbalance.nix | 2 ++ 1 file changed, 2 insertions(+) diff --git a/nixos/modules/services/hardware/irqbalance.nix b/nixos/modules/services/hardware/irqbalance.nix index c07e35943f2..c79e0eb83ec 100644 --- a/nixos/modules/services/hardware/irqbalance.nix +++ b/nixos/modules/services/hardware/irqbalance.nix @@ -15,6 +15,8 @@ in environment.systemPackages = [ pkgs.irqbalance ]; + systemd.services.irqbalance.wantedBy = ["multi-user.target"]; + systemd.packages = [ pkgs.irqbalance ]; };