Unverified Commit 828585a7 authored by Ramses's avatar Ramses Committed by GitHub
Browse files

nixos/channel: fix channel linkage if broken channel link already exists (#513441)

parents cde127b0 fb266d76
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -92,7 +92,7 @@ in
            -i ${channelSources} --quiet --option build-use-substitutes false \
            ${lib.optionalString config.boot.initrd.systemd.enable "--option sandbox false"} # There's an issue with pivot_root
          mkdir -m 0700 -p /root/.nix-defexpr
          ln -s /nix/var/nix/profiles/per-user/root/channels /root/.nix-defexpr/channels
          ln -sfvT /nix/var/nix/profiles/per-user/root/channels /root/.nix-defexpr/channels
          mkdir -m 0755 -p /var/lib/nixos
          touch /var/lib/nixos/did-channel-init
        fi
+9 −0
Original line number Diff line number Diff line
@@ -45,6 +45,15 @@ in
    };
  };

  channel = incusRunTest {
    name = "channel";

    instances.c1 = {
      type = "container";
      copyChannel = true;
    };
  };

  # used in lxc tests to verify container functionality
  container = incusRunTest {
    name = "container";
+67 −59
Original line number Diff line number Diff line
@@ -60,6 +60,11 @@ in
                default = { };
              };

              copyChannel = lib.mkEnableOption ''
                copy channel in test image. disabled by default as it forces image
                rebuilds excessively. enable to validate channel things.
              '';

              testScript = lib.mkOption {
                type = lib.types.str;
                description = "final script provided to test runner";
@@ -104,7 +109,7 @@ in
                  documentation.enable = lib.mkForce false;
                  documentation.nixos.enable = lib.mkForce false;
                  # including a channel forces images to be rebuilt on any changes
                  system.installer.channel.enable = lib.mkForce false;
                  system.installer.channel.enable = lib.mkForce config.copyChannel;

                  environment.etc."nix/registry.json".text = lib.mkForce "{}";

@@ -170,8 +175,7 @@ in
                #
                # container specific
                #
                +
                  lib.optionalString (config.type == "container")
                + lib.optionalString (config.type == "container") (
                  # python
                  ''
                    with subtest("[${image_id}] switch-to-configuration updates /sbin/init via installBootLoader"):
@@ -227,7 +231,11 @@ in
                            server.wait_for_instance(instance_name)
                            server.succeed(f"pgrep -a lxcfs | grep 'incus/devices/{instance_name}/lxcfs'")
                  ''

                  + lib.optionalString (config.copyChannel) ''
                    with subtest("[${image_id}] channel copied correctly"):
                        server.succeed(f"incus exec {instance_name} -- systemctl status nix-channel-init.service")
                  ''
                )
                #
                # virtual-machine specific
                #