on iko/ghcjs-patch-master help sign in
Add subDir argument to cleanGit (#280)

Co-Authored-By: Viktor Kronvall <viktor.kronvall@gmail.com>

commit23e0c2fcea6943b6ff2351a1c13119dcccdebc95 authorHamish Mackenzie <Hamish.Mackenzie@iohk.io> dateWed 30 Oct 2019, 15:09 (7 years ago) parente920ddf
2 files changed+13−4
docs/user-guide.md+10−1 lib/clean-git.nix+3−3
docs/user-guide.md+10−1
@@ -108,7 +108,16 @@ If your project has a `cabal.project` you can add a `default.nix` like this:
108108Note: The `cleanGit` call will exclude any files not in the index file
109109in the local `.git` directory. This is extremely useful as it avoids
110110unwanted builds (for instance when the contents of `dist-newstyle` are
111−modified by cabal).
111+modified by cabal). It is important that `src` is the root directory
112+of the repo (so `cleanGit` can find the `.git` directory). If the project
113+is not at the root of the repo, then also pass `subDir` to `cleanGit` with the
114+location of the project relative to `src` as a string. For example:
115+
116+```
117+ src = pkgs.haskell-nix.haskellLib.cleanGit
118+ { src = ./.; subDir = "subdir/another-subdir"; };
119+```
120+
112121
113122You can build a component from your project with `nix-build` (in this
114123case the `hello` executable in a `helloworld` package):
lib/clean-git.nix+3−3
@@ -1,6 +1,6 @@
11# From https://github.com/NixOS/nix/issues/2944
22{ lib, runCommand, git, cleanSourceWith }:
3−{ src }:
3+{ src, subDir ? "" }:
44
55# The function call
66#
@@ -90,12 +90,12 @@ then
9090 filter = filter_from_list src whitelist;
9191 in
9292 cleanSourceWith {
93− inherit src filter;
93+ inherit src subDir filter;
9494 }
9595
9696else
9797 trace "gitSource.nix: ${toString src} does not seem to be a git repository,\nassuming it is a clean checkout." (
9898 cleanSourceWith {
99− inherit src;
99+ inherit src subDir;
100100 }
101101 )