nixos/nix-daemon: remove obsolete compatibility code

* 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
This commit is contained in:
Alois Wohlschlager
2025-12-14 15:53:41 +01:00
parent 2fbfb1d73d
commit 8165c8d96a
+3 -26
View File
@@ -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;
};
}