Skip to content

Commit

Permalink
Test baseNameOf behaviour on the root of a flake
Browse files Browse the repository at this point in the history
  • Loading branch information
edolstra committed Apr 30, 2024
1 parent 0950094 commit 2101916
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 1 deletion.
1 change: 0 additions & 1 deletion src/libexpr/primops.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1648,7 +1648,6 @@ static std::string_view legacyBaseNameOf(std::string_view path)
static void prim_baseNameOf(EvalState & state, const PosIdx pos, Value * * args, Value & v)
{
NixStringContext context;
// FIXME: handle roots of source trees (should return "<hash>-source").
v.mkString(legacyBaseNameOf(*state.coerceToString(pos, *args[0], context,
"while evaluating the first argument passed to builtins.baseNameOf",
false, false)), context);
Expand Down
2 changes: 2 additions & 0 deletions tests/functional/flakes/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ writeSimpleFlake() {
legacyPackages.$system.hello = import ./simple.nix;
parent = builtins.dirOf ./.;
baseName = builtins.baseNameOf ./.;
};
}
EOF
Expand Down
3 changes: 3 additions & 0 deletions tests/functional/flakes/flakes.sh
Original file line number Diff line number Diff line change
Expand Up @@ -235,6 +235,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)
Expand Down

0 comments on commit 2101916

Please sign in to comment.