diff --git a/nixos/modules/system/boot/systemd-nspawn.nix b/nixos/modules/system/boot/systemd-nspawn.nix index f765db275e79..1997b48d8cde 100644 --- a/nixos/modules/system/boot/systemd-nspawn.nix +++ b/nixos/modules/system/boot/systemd-nspawn.nix @@ -41,8 +41,7 @@ let ]; instanceOptions = { - options = { - + options = sharedOptions // { execConfig = mkOption { default = {}; example = { Parameters = "/bin/sh"; }; @@ -82,18 +81,20 @@ let }; - instanceToUnit = name: def: - { text = '' - [Exec] - ${attrsToSection def.execConfig} + instanceToUnit = name: def: + let base = { + text = '' + [Exec] + ${attrsToSection def.execConfig} - [Files] - ${attrsToSection def.filesConfig} + [Files] + ${attrsToSection def.filesConfig} - [Network] - ${attrsToSection def.networkConfig} - ''; - }; + [Network] + ${attrsToSection def.networkConfig} + ''; + } // def; + in base // { unit = makeUnit name base; }; in { @@ -109,7 +110,7 @@ in { config = let - units = mapAttrs' (n: v: nameValuePair "${n}.nspawn" (instanceToUnit n v)) cfg.instances; + units = mapAttrs' (n: v: nameValuePair "${n}.nspawn" (instanceToUnit n v)) cfg; in mkIf (cfg != {}) { environment.etc."systemd/nspawn".source = generateUnits "nspawn" units [] [];