Merge pull request #84266 from Ma27/nspawn-overrides

nixos/systemd-nspawn: disallow multiple packages with `.nspawn`-units
This commit is contained in:
Maximilian Bosch 2020-04-16 00:24:33 +02:00 committed by GitHub
commit 2d55f9c01a
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 11 additions and 4 deletions

View file

@ -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;
@ -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/

View file

@ -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" ];