Skip to content

Commit c1660ef

Browse files
committed
Add test
1 parent dbe6770 commit c1660ef

File tree

3 files changed

+38
-0
lines changed

3 files changed

+38
-0
lines changed

tests/functional/flakes/common.sh

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ writeSimpleFlake() {
3232
baseName = builtins.baseNameOf ./.;
3333
3434
root = ./.;
35+
36+
number = 123;
3537
};
3638
}
3739
EOF

tests/functional/flakes/meson.build

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ suites += {
3636
'trace-ifd.sh',
3737
'build-time-flake-inputs.sh',
3838
'substitution.sh',
39+
'shallow.sh',
3940
],
4041
'workdir' : meson.current_source_dir(),
4142
}

tests/functional/flakes/shallow.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/usr/bin/env bash
2+
3+
export _NIX_FORCE_HTTP=1
4+
5+
source ./common.sh
6+
7+
requireGit
8+
TODO_NixOS
9+
10+
createFlake1
11+
12+
repoDir="$TEST_ROOT/repo"
13+
mkdir -p "$repoDir"
14+
echo "# foo" >> "$flake1Dir/flake.nix"
15+
git -C "$flake1Dir" commit -a -m bla
16+
17+
cat > "$repoDir"/flake.nix <<EOF
18+
{
19+
inputs.dep = {
20+
type = "git";
21+
url = "file://$flake1Dir";
22+
};
23+
outputs = inputs: rec {
24+
revs = assert inputs.dep.number == 123; inputs.dep.revCount;
25+
};
26+
}
27+
EOF
28+
29+
# This will do a non-shallow fetch.
30+
[[ $(nix eval "path:$repoDir#revs") = 2 ]]
31+
32+
# This should re-use the existing non-shallow clone.
33+
clearStore
34+
mv "$flake1Dir" "$flake1Dir.moved"
35+
[[ $(nix eval "path:$repoDir#revs") = 2 ]]

0 commit comments

Comments
 (0)