Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 70ecf83c3379
Choose a base ref
...
head repository: NixOS/nixpkgs
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 2d55f9c01a20
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Apr 4, 2020

  1. 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 = {
        /* ... */
      };
    }
    ```
    Ma27 committed Apr 4, 2020
    Copy the full SHA
    a9e3ec1 View commit details

Commits on Apr 15, 2020

  1. Merge pull request #84266 from Ma27/nspawn-overrides

    nixos/systemd-nspawn: disallow multiple packages with `.nspawn`-units
    Ma27 authored Apr 15, 2020
    Copy the full SHA
    2d55f9c View commit details
Showing with 11 additions and 4 deletions.
  1. +10 −3 nixos/modules/system/boot/systemd-lib.nix
  2. +1 −1 nixos/modules/system/boot/systemd-nspawn.nix
13 changes: 10 additions & 3 deletions nixos/modules/system/boot/systemd-lib.nix
Original file line number Diff line number Diff line change
@@ -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/
2 changes: 1 addition & 1 deletion nixos/modules/system/boot/systemd-nspawn.nix
Original file line number Diff line number Diff line change
@@ -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" ];