From 8f4ea912a19d75bbcd914adc0a4a0cb6f2a79124 Mon Sep 17 00:00:00 2001 From: arcnmx Date: Fri, 27 Sep 2024 17:06:10 -0700 Subject: [PATCH] chore: tweak niceness of some services --- modules/nixos/github-runner.nix | 50 ++++++++++++++++++--------------- nixos/github-runner/zone.nix | 3 ++ nixos/klipper/default.nix | 3 ++ nixos/minecraft/java.nix | 1 + 4 files changed, 34 insertions(+), 23 deletions(-) diff --git a/modules/nixos/github-runner.nix b/modules/nixos/github-runner.nix index ba431611..0f18ede5 100644 --- a/modules/nixos/github-runner.nix +++ b/modules/nixos/github-runner.nix @@ -5,7 +5,7 @@ ... }: let inherit (lib.options) mkOption; - inherit (lib.modules) mkIf mkDefault mkForce; + inherit (lib.modules) mkIf mkMerge mkDefault mkForce; inherit (lib.attrsets) attrNames attrValues filterAttrs mapAttrs' nameValuePair; inherit (gensokyo-zone.lib) unmerged; cfg = config.services.github-runners; @@ -24,28 +24,32 @@ }; config = { replace = mkIf config.ephemeral (mkDefault true); - serviceSettings = mkIf (config.networkNamespace.name != null) { - networkNamespace = { - name = mkDefault config.networkNamespace.name; - afterOnline = mkDefault true; - }; - restartTriggers = [ - config.ephemeral - config.url - config.name - config.runnerGroup - config.extraLabels - config.noDefaultLabels - config.user - config.group - config.workDir - "${config.package}" - config.extraPackages - config.nodeRuntimes - (attrNames config.extraEnvironment) - (attrValues config.extraEnvironment) - ]; - }; + serviceSettings = mkMerge [ + (mkIf (config.networkNamespace.name != null) { + networkNamespace = { + name = mkDefault config.networkNamespace.name; + afterOnline = mkDefault true; + }; + }) + { + restartTriggers = [ + config.ephemeral + config.url + config.name + config.runnerGroup + config.extraLabels + config.noDefaultLabels + config.user + config.group + config.workDir + "${config.package}" + config.extraPackages + config.nodeRuntimes + (attrNames config.extraEnvironment) + (attrValues config.extraEnvironment) + ]; + } + ]; serviceOverrides = mkIf (config.user != null || config.group != null) { DynamicUser = mkForce true; }; diff --git a/nixos/github-runner/zone.nix b/nixos/github-runner/zone.nix index 0f15a49c..02b32032 100644 --- a/nixos/github-runner/zone.nix +++ b/nixos/github-runner/zone.nix @@ -79,6 +79,9 @@ in { unitConfig = { StopPropagatedFrom = ["${cfg.targetName}.target"]; }; + serviceConfig = { + Nice = mkDefault 5; + }; }; serviceOverrides = mkIf (!cfg.dynamicUser) { # XXX: the ci sshd hack requires this for now :< diff --git a/nixos/klipper/default.nix b/nixos/klipper/default.nix index a8f28d84..0e84ae5f 100644 --- a/nixos/klipper/default.nix +++ b/nixos/klipper/default.nix @@ -30,6 +30,9 @@ in { systemd = mkIf cfg.enable { services.klipper = { restartIfChanged = false; + serviceConfig = { + Nice = mkDefault (-5); + }; }; tmpfiles.rules = mkIf (cfg.logFile != null) [ "d ${dirOf cfg.logFile} 0755 ${cfg.user} ${cfg.group} 8w -" diff --git a/nixos/minecraft/java.nix b/nixos/minecraft/java.nix index ea4158b9..c465fa54 100644 --- a/nixos/minecraft/java.nix +++ b/nixos/minecraft/java.nix @@ -116,6 +116,7 @@ in { "~.*Invalid modellist patch" "~.*Invalid modellist patch.*" ]; + Nice = mkDefault (-4); }; }; tmpfiles.rules = let