File tree 2 files changed +53
-0
lines changed
2 files changed +53
-0
lines changed Original file line number Diff line number Diff line change
1
+ source common.sh
2
+
3
+ # Tests that:
4
+ # - flake.nix may reside inside of a git submodule
5
+ # - the flake can access content outside of the submodule
6
+ #
7
+ # rootRepo
8
+ # ├── root.nix
9
+ # └── submodule
10
+ # ├── flake.nix
11
+ # └── sub.nix
12
+
13
+
14
+ requireGit
15
+
16
+ clearStore
17
+
18
+ # Submodules can't be fetched locally by default.
19
+ # See fetchGitSubmodules.sh
20
+ export XDG_CONFIG_HOME=$TEST_HOME /.config
21
+ git config --global protocol.file.allow always
22
+
23
+
24
+ rootRepo=$TEST_ROOT /rootRepo
25
+ subRepo=$TEST_ROOT /submodule
26
+
27
+
28
+ createGitRepo $subRepo
29
+ cat > $subRepo /flake.nix << EOF
30
+ {
31
+ outputs = { self }: {
32
+ sub = import ./sub.nix;
33
+ root = import ../root.nix;
34
+ };
35
+ }
36
+ EOF
37
+ echo ' "expression in submodule"' > $subRepo /sub.nix
38
+ git -C $subRepo add flake.nix sub.nix
39
+ git -C $subRepo commit -m Initial
40
+
41
+ createGitRepo $rootRepo
42
+
43
+ git -C $rootRepo submodule init
44
+ git -C $rootRepo submodule add $subRepo submodule
45
+ echo ' "expression in root repo"' > $rootRepo /root.nix
46
+ git -C $rootRepo add root.nix
47
+ git -C $rootRepo commit -m " Add root.nix"
48
+
49
+ # Flake can live inside a submodule and can be accessed via ?dir=submodule
50
+ [[ $( nix eval --json git+file://$rootRepo \? submodules=1\& dir=submodule#sub ) = ' "expression in submodule"' ]]
51
+ # The flake can access content outside of the submodule
52
+ [[ $( nix eval --json git+file://$rootRepo \? submodules=1\& dir=submodule#root ) = ' "expression in root repo"' ]]
Original file line number Diff line number Diff line change @@ -13,6 +13,7 @@ nix_tests = \
13
13
flakes/unlocked-override.sh \
14
14
flakes/absolute-paths.sh \
15
15
flakes/build-paths.sh \
16
+ flakes/flake-in-submodule.sh \
16
17
ca/gc.sh \
17
18
gc.sh \
18
19
remote-store.sh \
You can’t perform that action at this time.
0 commit comments