From c4e0d766b75363e20c2beca5fbbaa61312911785 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Christian=20K=C3=B6gler?= Date: Sun, 23 Oct 2022 15:57:55 +0200 Subject: [PATCH] nixos/unitGenerator: fix generation for nspawn files --- nixos/lib/systemd-lib.nix | 6 +++--- nixos/tests/systemd-machinectl.nix | 3 +++ 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/nixos/lib/systemd-lib.nix b/nixos/lib/systemd-lib.nix index 779dadece582..65356634655d 100644 --- a/nixos/lib/systemd-lib.nix +++ b/nixos/lib/systemd-lib.nix @@ -214,7 +214,7 @@ in rec { ${concatStrings (mapAttrsToList (name: unit: concatMapStrings (name2: '' ln -sfn '${name}' $out/'${name2}' - '') unit.aliases) units)} + '') (unit.aliases or [])) units)} # Create .wants and .requires symlinks from the wantedBy and # requiredBy options. @@ -222,13 +222,13 @@ in rec { concatMapStrings (name2: '' mkdir -p $out/'${name2}.wants' ln -sfn '../${name}' $out/'${name2}.wants'/ - '') unit.wantedBy) units)} + '') (unit.wantedBy or [])) units)} ${concatStrings (mapAttrsToList (name: unit: concatMapStrings (name2: '' mkdir -p $out/'${name2}.requires' ln -sfn '../${name}' $out/'${name2}.requires'/ - '') unit.requiredBy) units)} + '') (unit.requiredBy or [])) units)} ${optionalString (type == "system") '' # Stupid misc. symlinks. diff --git a/nixos/tests/systemd-machinectl.nix b/nixos/tests/systemd-machinectl.nix index 7a4888ab85f6..fa5c81599eb0 100644 --- a/nixos/tests/systemd-machinectl.nix +++ b/nixos/tests/systemd-machinectl.nix @@ -41,6 +41,9 @@ import ./make-test-python.nix ({ pkgs, ... }: systemd.targets.machines.wants = [ "systemd-nspawn@${containerName}.service" ]; virtualisation.additionalPaths = [ containerSystem ]; + + # not needed, but we want to test the nspawn file generation + systemd.nspawn.${containerName} = { }; }; testScript = ''