mirror of
https://github.com/ilyakooo0/nixpkgs.git
synced 2024-09-20 12:08:17 +03:00
nixos/systemd-nspawn: disallow multiple packages with .nspawn
-units
In contrast to `.service`-units, it's not possible to declare an `overrides.conf`, however this is done by `generateUnits` for `.nspawn` units as well. This change breaks the build if you have two derivations configuring one nspawn unit. This will happen in a case like this: ``` nix { pkgs, ... }: { systemd.packages = [ (pkgs.writeTextDir "etc/systemd/nspawn/container0.nspawn" '' [Files] Bind=/tmp '') ]; systemd.nspawn.container0 = { /* ... */ }; } ```
This commit is contained in:
parent
384a164a25
commit
a9e3ec1d6e
@ -114,7 +114,9 @@ in rec {
|
|||||||
(if isList value then value else [value]))
|
(if isList value then value else [value]))
|
||||||
as));
|
as));
|
||||||
|
|
||||||
generateUnits = type: units: upstreamUnits: upstreamWants:
|
generateUnits = generateUnits' true;
|
||||||
|
|
||||||
|
generateUnits' = allowCollisions: type: units: upstreamUnits: upstreamWants:
|
||||||
pkgs.runCommand "${type}-units"
|
pkgs.runCommand "${type}-units"
|
||||||
{ preferLocalBuild = true;
|
{ preferLocalBuild = true;
|
||||||
allowSubstitutes = false;
|
allowSubstitutes = false;
|
||||||
@ -182,8 +184,13 @@ in rec {
|
|||||||
if [ "$(readlink -f $i/$fn)" = /dev/null ]; then
|
if [ "$(readlink -f $i/$fn)" = /dev/null ]; then
|
||||||
ln -sfn /dev/null $out/$fn
|
ln -sfn /dev/null $out/$fn
|
||||||
else
|
else
|
||||||
mkdir -p $out/$fn.d
|
${if allowCollisions then ''
|
||||||
ln -s $i/$fn $out/$fn.d/overrides.conf
|
mkdir -p $out/$fn.d
|
||||||
|
ln -s $i/$fn $out/$fn.d/overrides.conf
|
||||||
|
'' else ''
|
||||||
|
echo "Found multiple derivations configuring $fn!"
|
||||||
|
exit 1
|
||||||
|
''}
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
ln -fs $i/$fn $out/
|
ln -fs $i/$fn $out/
|
||||||
|
@ -116,7 +116,7 @@ in {
|
|||||||
in
|
in
|
||||||
mkMerge [
|
mkMerge [
|
||||||
(mkIf (cfg != {}) {
|
(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" ];
|
systemd.targets.multi-user.wants = [ "machines.target" ];
|
||||||
|
Loading…
Reference in New Issue
Block a user