Skip to content

Commit

Permalink
Merge pull request #84266 from Ma27/nspawn-overrides
Browse files Browse the repository at this point in the history
nixos/systemd-nspawn: disallow multiple packages with `.nspawn`-units
  • Loading branch information
Ma27 authored Apr 15, 2020
2 parents 70ecf83 + a9e3ec1 commit 2d55f9c
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
13 changes: 10 additions & 3 deletions nixos/modules/system/boot/systemd-lib.nix
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,9 @@ in rec {
(if isList value then value else [value]))
as));

generateUnits = type: units: upstreamUnits: upstreamWants:
generateUnits = generateUnits' true;

generateUnits' = allowCollisions: type: units: upstreamUnits: upstreamWants:
pkgs.runCommand "${type}-units"
{ preferLocalBuild = true;
allowSubstitutes = false;
Expand Down Expand Up @@ -182,8 +184,13 @@ in rec {
if [ "$(readlink -f $i/$fn)" = /dev/null ]; then
ln -sfn /dev/null $out/$fn
else
mkdir -p $out/$fn.d
ln -s $i/$fn $out/$fn.d/overrides.conf
${if allowCollisions then ''
mkdir -p $out/$fn.d
ln -s $i/$fn $out/$fn.d/overrides.conf
'' else ''
echo "Found multiple derivations configuring $fn!"
exit 1
''}
fi
else
ln -fs $i/$fn $out/
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/system/boot/systemd-nspawn.nix
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ in {
in
mkMerge [
(mkIf (cfg != {}) {
environment.etc."systemd/nspawn".source = mkIf (cfg != {}) (generateUnits "nspawn" units [] []);
environment.etc."systemd/nspawn".source = mkIf (cfg != {}) (generateUnits' false "nspawn" units [] []);
})
{
systemd.targets.multi-user.wants = [ "machines.target" ];
Expand Down

0 comments on commit 2d55f9c

Please sign in to comment.