From 58921a49040285b76da8575fc3dd3d41fc42f895 Mon Sep 17 00:00:00 2001 From: Kevin Quick Date: Fri, 9 Apr 2021 22:37:00 -0700 Subject: [PATCH] nixos/nix-daemon: assert system or systems for buildMachines. Commit 5395397f removed the assertions from the buildMachines to ensure that either system or systems is set for each buildmachine. This patch re-implements those assertions. The symptom is that if both system and systems are omitted, then the /etc/machines file has the wrong number of columns and any attempt to run a `nix` operation that has to perform a build will fail with a `strtoull` exception. --- nixos/modules/services/misc/nix-daemon.nix | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/nixos/modules/services/misc/nix-daemon.nix b/nixos/modules/services/misc/nix-daemon.nix index 64bdbf159d51..19cbf8136a14 100644 --- a/nixos/modules/services/misc/nix-daemon.nix +++ b/nixos/modules/services/misc/nix-daemon.nix @@ -533,6 +533,22 @@ in + "\n" ) cfg.buildMachines; }; + assertions = + let badMachine = m: m.system == null && m.systems == []; + in [ + { + assertion = !(builtins.any badMachine cfg.buildMachines); + message = '' + At least one system type (via system or + systems) must be set for every build machine. + Invalid machine specifications: + '' + " " + + (builtins.concatStringsSep "\n " + (builtins.map (m: m.hostName) + (builtins.filter (badMachine) cfg.buildMachines))); + } + ]; + systemd.packages = [ nix ];