on iko/ghcjs-patch-master help sign in
Add subDir argument to cleanGit (#280)
23e0c2fHamish Mackenzie
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:
108Note: The `cleanGit` call will exclude any files not in the index file
108Note: The `cleanGit` call will exclude any files not in the index file
109in the local `.git` directory. This is extremely useful as it avoids
109in the local `.git` directory. This is extremely useful as it avoids
110unwanted builds (for instance when the contents of `dist-newstyle` are
110unwanted 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+
112
121
113You can build a component from your project with `nix-build` (in this
122You can build a component from your project with `nix-build` (in this
114case the `hello` executable in a `helloworld` package):
123case the `hello` executable in a `helloworld` package):
lib/clean-git.nix+3−3
@@ -1,6 +1,6 @@
1# From https://github.com/NixOS/nix/issues/2944
1# From https://github.com/NixOS/nix/issues/2944
2{ lib, runCommand, git, cleanSourceWith }:
2{ lib, runCommand, git, cleanSourceWith }:
3−{ src }:
3+{ src, subDir ? "" }:
4
4
5# The function call
5# The function call
6#
6#
@@ -90,12 +90,12 @@ then
90 filter = filter_from_list src whitelist;
90 filter = filter_from_list src whitelist;
91 in
91 in
92 cleanSourceWith {
92 cleanSourceWith {
93− inherit src filter;
93+ inherit src subDir filter;
94 }
94 }
95
95
96else
96else
97 trace "gitSource.nix: ${toString src} does not seem to be a git repository,\nassuming it is a clean checkout." (
97 trace "gitSource.nix: ${toString src} does not seem to be a git repository,\nassuming it is a clean checkout." (
98 cleanSourceWith {
98 cleanSourceWith {
99− inherit src;
99+ inherit src subDir;
100 }
100 }
101 )
101 )