Skip to content

Commit 559106b

Browse files
committed
add git submodule ignore code and notice in nix derivation
1 parent c071398 commit 559106b

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

{{cookiecutter.project_slug}}/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,3 +20,6 @@ Use `make` to run common tasks (see the [Makefile](Makefile) for a complete list
2020
* `make format`: Format code
2121
* `make test-unit`: Run unit tests
2222
* `make test-integration`: Run integration tests
23+
24+
## Considerations
25+
If you use git submodules that are not required for building the project with `nix`, then you should add these directories to the `gitignoreSourcePure` list in `nix/default.nix`, see the respective left-over `TODO` in the nix file. Otherwise, the nix build that is uploaded to the nix binary cache by CI might not match the version that is requested by `kup`, in case this project is offered as a package by `kup`. This is due to weird behaviour in regards to git submodules by `git` and `nix`, where a submodule directory might exist and be empty or instead not exist, which impacts the resulting nix hash, which is of impartance when offering/downloading cached nix derivations.

{{cookiecutter.project_slug}}/nix/{{cookiecutter.project_slug}}/default.nix

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
{
22
lib,
33
callPackage,
4+
nix-gitignore,
45

56
pyproject-nix,
67
pyproject-build-systems,
@@ -16,7 +17,17 @@ let
1617

1718
# load a uv workspace from a workspace root
1819
workspace = uv2nix.lib.workspace.loadWorkspace {
19-
workspaceRoot = ../..;
20+
workspaceRoot = lib.cleanSource (nix-gitignore.gitignoreSourcePure [
21+
../../.gitignore
22+
".github/"
23+
"result*"
24+
# do not include submodule directories that might be initilized empty or non-existent due to nix/git
25+
# otherwise cachix build might not match the version that is requested by `kup`
26+
# TODO: for new projects, add your submodule directories that are not required for nix builds here!
27+
# e.g., `"/docs/external-computation"` with `external-computation` being a git submodule directory
28+
# "/docs/external-computation"
29+
] ../..
30+
);
2031
};
2132

2233
# create overlay

0 commit comments

Comments
 (0)