mirror of
https://github.com/privatevoid-net/nix-super.git
synced 2024-11-29 09:06:15 +02:00
Merge pull request #10624 from edolstra/flake-root-tests
Add tests for dirOf/baseNameOf on the root of a flake
This commit is contained in:
commit
e18c3d4670
3 changed files with 11 additions and 0 deletions
|
@ -54,6 +54,7 @@ struct PathInputScheme : InputScheme
|
||||||
"narHash",
|
"narHash",
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
std::optional<Input> inputFromAttrs(const Attrs & attrs) const override
|
std::optional<Input> inputFromAttrs(const Attrs & attrs) const override
|
||||||
{
|
{
|
||||||
getStrAttr(attrs, "path");
|
getStrAttr(attrs, "path");
|
||||||
|
|
|
@ -21,6 +21,10 @@ writeSimpleFlake() {
|
||||||
|
|
||||||
# To test "nix flake init".
|
# To test "nix flake init".
|
||||||
legacyPackages.$system.hello = import ./simple.nix;
|
legacyPackages.$system.hello = import ./simple.nix;
|
||||||
|
|
||||||
|
parent = builtins.dirOf ./.;
|
||||||
|
|
||||||
|
baseName = builtins.baseNameOf ./.;
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
|
@ -231,6 +231,12 @@ nix build -o "$TEST_ROOT/result" --expr "(builtins.getFlake \"$flake1Dir\").pack
|
||||||
# 'getFlake' on a locked flakeref should succeed even in pure mode.
|
# '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"
|
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"\" ]]
|
||||||
|
|
||||||
|
# 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.
|
# 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-registries)
|
||||||
(! nix build -o "$TEST_ROOT/result" flake2#bar --no-use-registries)
|
(! nix build -o "$TEST_ROOT/result" flake2#bar --no-use-registries)
|
||||||
|
|
Loading…
Reference in a new issue