From 8165c8d96a0a114b6455cce23d31f94e26eee63f Mon Sep 17 00:00:00 2001 From: Alois Wohlschlager Date: Mon, 8 Dec 2025 17:25:16 +0100 Subject: [PATCH] nixos/nix-daemon: remove obsolete compatibility code MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * util-linux was used for ionice, replaced by systemd directives in 2012 [1]. * gzip was used for compressing stuff sent over ssh, replaced by the `-C` option in Nix 1.8 [2]. * Conditionals for versions less than 2.8 (or 2.3) can be removed, as they are not supported any more [3]. * Some systemd directives are already in the upstream service file of all supported Nix and Lix versions, and are removed. For cgroup delegation, this is only strictly true for Lix ≥2.94; Lix 2.93 does not support it at all yet, and Nix doesn't use the supervisor group at all (I haven't investigated whether it creates one itself or is just broken entirely, but in any case the creation of the empty cgroup in the module will not help). [1] https://github.com/NixOS/nixpkgs/commit/88f94d76bcce27b42c748e6f2a7691d0659e5513 [2] https://github.com/NixOS/nix/commit/7f7d4ab68649b2f5530143e8cfa95fc785ae9937 [3] https://github.com/NixOS/nixpkgs/commit/fa0cba1c398faad0b810555daea3bfeb05719a8c --- nixos/modules/services/system/nix-daemon.nix | 29 ++------------------ 1 file changed, 3 insertions(+), 26 deletions(-) diff --git a/nixos/modules/services/system/nix-daemon.nix b/nixos/modules/services/system/nix-daemon.nix index 2c4769da5764..9c3fba3f6dba 100644 --- a/nixos/modules/services/system/nix-daemon.nix +++ b/nixos/modules/services/system/nix-daemon.nix @@ -16,10 +16,6 @@ let nixPackage = cfg.package.out; - # nixVersion is an attribute which defines the implementation version. - # This is useful for Nix implementations which don't follow Nix's versioning. - isNixAtLeast = lib.versionAtLeast (nixPackage.nixVersion or (lib.getVersion nixPackage)); - makeNixBuildUser = nr: { name = "nixbld${toString nr}"; value = { @@ -196,26 +192,15 @@ in systemd.packages = [ nixPackage ]; - systemd.tmpfiles = lib.mkMerge [ - (lib.mkIf (isNixAtLeast "2.8") { - packages = [ nixPackage ]; - }) - (lib.mkIf (!isNixAtLeast "2.8") { - rules = [ - "d /nix/var/nix/daemon-socket 0755 root root - -" - ]; - }) - ]; + systemd.tmpfiles.packages = [ nixPackage ]; systemd.sockets.nix-daemon.wantedBy = [ "sockets.target" ]; systemd.services.nix-daemon = { path = [ nixPackage - pkgs.util-linux config.programs.ssh.package - ] - ++ lib.optionals cfg.distributedBuilds [ pkgs.gzip ]; + ]; environment = cfg.envVars @@ -224,15 +209,10 @@ in } // config.networking.proxy.envVars; - unitConfig.RequiresMountsFor = "/nix/store"; - serviceConfig = { CPUSchedulingPolicy = cfg.daemonCPUSchedPolicy; IOSchedulingClass = cfg.daemonIOSchedClass; IOSchedulingPriority = cfg.daemonIOSchedPriority; - LimitNOFILE = 1048576; - Delegate = "yes"; - DelegateSubgroup = "supervisor"; }; restartTriggers = [ config.environment.etc."nix/nix.conf".source ]; @@ -287,10 +267,7 @@ in services.displayManager.hiddenUsers = lib.attrNames nixbldUsers; # Legacy configuration conversion. - nix.settings = lib.mkMerge [ - (lib.mkIf (isNixAtLeast "2.3pre") { sandbox-fallback = false; }) - ]; - + nix.settings.sandbox-fallback = false; }; }