From 4d99d07bc97bab9ba3e399ac3ca6e78a8ccf4aab Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 30 Apr 2024 15:34:35 +0200 Subject: [PATCH 1/3] Whitespace --- src/libfetchers/path.cc | 1 + 1 file changed, 1 insertion(+) diff --git a/src/libfetchers/path.cc b/src/libfetchers/path.cc index 0af1bad73..67a9fc2f2 100644 --- a/src/libfetchers/path.cc +++ b/src/libfetchers/path.cc @@ -54,6 +54,7 @@ struct PathInputScheme : InputScheme "narHash", }; } + std::optional inputFromAttrs(const Attrs & attrs) const override { getStrAttr(attrs, "path"); From 458441c637e7bac1f579c8448aa5a7210bd27fcf Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 30 Apr 2024 15:34:38 +0200 Subject: [PATCH 2/3] Test dirOf behaviour on the root of a flake --- tests/functional/flakes/common.sh | 2 ++ tests/functional/flakes/flakes.sh | 3 +++ 2 files changed, 5 insertions(+) diff --git a/tests/functional/flakes/common.sh b/tests/functional/flakes/common.sh index fc45cf7bf..65c12a9c3 100644 --- a/tests/functional/flakes/common.sh +++ b/tests/functional/flakes/common.sh @@ -21,6 +21,8 @@ writeSimpleFlake() { # To test "nix flake init". legacyPackages.$system.hello = import ./simple.nix; + + parent = builtins.dirOf ./.; }; } EOF diff --git a/tests/functional/flakes/flakes.sh b/tests/functional/flakes/flakes.sh index 4f41cae0a..5beb1e0f5 100644 --- a/tests/functional/flakes/flakes.sh +++ b/tests/functional/flakes/flakes.sh @@ -231,6 +231,9 @@ nix build -o "$TEST_ROOT/result" --expr "(builtins.getFlake \"$flake1Dir\").pack # 'getFlake' on a locked flakeref should succeed even in pure mode. nix build -o "$TEST_ROOT/result" --expr "(builtins.getFlake \"git+file://$flake1Dir?rev=$hash2\").packages.$system.default" +# Regression test for dirOf on the root of the flake. +[[ $(nix eval --json flake1#parent) = \""$NIX_STORE_DIR"\" ]] + # Building a flake with an unlocked dependency should fail in pure mode. (! nix build -o "$TEST_ROOT/result" flake2#bar --no-registries) (! nix build -o "$TEST_ROOT/result" flake2#bar --no-use-registries) From 503be57bbd88d5cfc2246b900b6dcb4e388f5066 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Tue, 30 Apr 2024 15:43:33 +0200 Subject: [PATCH 3/3] Test baseNameOf behaviour on the root of a flake --- tests/functional/flakes/common.sh | 2 ++ tests/functional/flakes/flakes.sh | 3 +++ 2 files changed, 5 insertions(+) diff --git a/tests/functional/flakes/common.sh b/tests/functional/flakes/common.sh index 65c12a9c3..e0776d5ed 100644 --- a/tests/functional/flakes/common.sh +++ b/tests/functional/flakes/common.sh @@ -23,6 +23,8 @@ writeSimpleFlake() { legacyPackages.$system.hello = import ./simple.nix; parent = builtins.dirOf ./.; + + baseName = builtins.baseNameOf ./.; }; } EOF diff --git a/tests/functional/flakes/flakes.sh b/tests/functional/flakes/flakes.sh index 5beb1e0f5..b2bea0711 100644 --- a/tests/functional/flakes/flakes.sh +++ b/tests/functional/flakes/flakes.sh @@ -234,6 +234,9 @@ nix build -o "$TEST_ROOT/result" --expr "(builtins.getFlake \"git+file://$flake1 # Regression test for dirOf on the root of the flake. [[ $(nix eval --json flake1#parent) = \""$NIX_STORE_DIR"\" ]] +# Regression test for baseNameOf on the root of the flake. +[[ $(nix eval --raw flake1#baseName) =~ ^[a-z0-9]*-source$ ]] + # Building a flake with an unlocked dependency should fail in pure mode. (! nix build -o "$TEST_ROOT/result" flake2#bar --no-registries) (! nix build -o "$TEST_ROOT/result" flake2#bar --no-use-registries)