From 4cdb21be0b4081162b65f25d46d2509cd944831d Mon Sep 17 00:00:00 2001 From: Zhaofeng Li Date: Wed, 17 Aug 2022 01:09:43 -0600 Subject: [PATCH] integration-tests/flakes: Eliminate slow nixpkgs copy --- integration-tests/flakes/default.nix | 5 ++--- integration-tests/flakes/flake.nix | 2 +- integration-tests/nixpkgs-stable.nix | 5 +++++ integration-tests/nixpkgs.nix | 5 +++++ integration-tests/tools.nix | 6 +++++- 5 files changed, 18 insertions(+), 5 deletions(-) diff --git a/integration-tests/flakes/default.nix b/integration-tests/flakes/default.nix index 00b5e72..0fa5b55 100644 --- a/integration-tests/flakes/default.nix +++ b/integration-tests/flakes/default.nix @@ -14,11 +14,10 @@ in tools.makeTest { testScript = '' import re - deployer.succeed("sed -i \"s @nixpkgs@ $(readlink /nixpkgs) g\" /tmp/bundle/flake.nix") + deployer.succeed("sed -i 's @nixpkgs@ path:${pkgs._inputs.nixpkgs.outPath}?narHash=${pkgs._inputs.nixpkgs.narHash} g' /tmp/bundle/flake.nix") with subtest("Lock flake dependencies"): - # --impure required for path:/nixpkgs which is a symlink to a store path - deployer.succeed("cd /tmp/bundle && nix --experimental-features \"nix-command flakes\" flake lock --impure") + deployer.succeed("cd /tmp/bundle && nix --experimental-features \"nix-command flakes\" flake lock") with subtest("Deploy with a plain flake without git"): deployer.succeed("cd /tmp/bundle && ${tools.colmenaExec} apply --on @target --evaluator ${evaluator}") diff --git a/integration-tests/flakes/flake.nix b/integration-tests/flakes/flake.nix index 190647c..4924867 100644 --- a/integration-tests/flakes/flake.nix +++ b/integration-tests/flakes/flake.nix @@ -2,7 +2,7 @@ description = "A simple deployment"; inputs = { - nixpkgs.url = "path:@nixpkgs@"; + nixpkgs.url = "@nixpkgs@"; }; outputs = { self, nixpkgs }: let diff --git a/integration-tests/nixpkgs-stable.nix b/integration-tests/nixpkgs-stable.nix index a23282b..8e019d9 100644 --- a/integration-tests/nixpkgs-stable.nix +++ b/integration-tests/nixpkgs-stable.nix @@ -4,5 +4,10 @@ in import flake.inputs.stable.outPath { overlays = [ flake._evalJobsOverlay flake.overlay + + # Pass through original flake inputs + (final: prev: { + _inputs = flake.inputs; + }) ]; } diff --git a/integration-tests/nixpkgs.nix b/integration-tests/nixpkgs.nix index 92cce60..718a862 100644 --- a/integration-tests/nixpkgs.nix +++ b/integration-tests/nixpkgs.nix @@ -4,5 +4,10 @@ in import flake.inputs.nixpkgs.outPath { overlays = [ flake._evalJobsOverlay flake.overlay + + # Pass through original flake inputs + (final: prev: { + _inputs = flake.inputs; + }) ]; } diff --git a/integration-tests/tools.nix b/integration-tests/tools.nix index a165ef2..893ced7 100644 --- a/integration-tests/tools.nix +++ b/integration-tests/tools.nix @@ -38,11 +38,15 @@ let # We include the input closure of a prebuilt system profile # so it can build system profiles for the targets without # network access. - deployerConfig = { lib, config, ... }: { + deployerConfig = { pkgs, lib, config, ... }: { imports = [ extraDeployerConfig ]; + nix.registry = lib.mkIf (pkgs ? _inputs) { + nixpkgs.flake = pkgs._inputs.nixpkgs; + }; + nix.nixPath = [ "nixpkgs=${pkgs.path}" ];