Update mkCacheFile and mkCacheModule to support private repos with builtins.fetchGit#348
Conversation
overlays/haskell.nix
Outdated
| # Non-private repos must have sha256 set. | ||
| assert repo ? sha256; | ||
| # pkgs.fetchgit doesn't have any way of fetching from a given | ||
| # ref. | ||
| assert !(repo ? ref); |
There was a problem hiding this comment.
It might be nicer to have these assertions return an understandable error message, but for now they should be fine.
overlays/haskell.nix
Outdated
| sha256String = if isNull sha256 then self.buildPackages.lib.fakeSha256 else sha256; | ||
| in "${url} ${rev} ${subdir} ${sha256String} ${name} ${nix-expr}"; |
There was a problem hiding this comment.
It might be better to add some sort of actual format (maybe json based?) for this cache line that stack-to-nix knows how to parse.
The format could be a sum-type, with one constructor for public repos (which use pkgs.fetchgit), and one constructor for private repos (which use builtins.fetchGit).
But I think that would be best for a future PR.
|
Here's an example of a cache that has both private and public repos: let
caches = [
# an example of a private repo
{
name = "net-mqtt";
url = "https://github.com/xc-jp/mqtt-hs.git";
rev = "2c5ffe80cd1d765fd8ff3db2eaa54a98ca0485b2";
ref = "fix-message-id-0"; # this is a branch
is-private = true;
}
# an example of a normal public repo
{
name = "datasets";
url = "https://github.com/DataHaskell/dh-core.git";
rev = "78dee2304790fae0e301af17c7512d9c916a9b3f";
sha256 = "1rwwfc78cgdw3b2mv9ibiphl86m32c8r7zvb2a5saq0zg9vi3f9h";
subdir = "datasets";
}
];
in ...In the future, I think it would be possible to write a function to generate this cache file from the |
8c62504 to
56ad780
Compare
|
This PR had a conflict with #334, but I have fixed it and rebased on top of |
56ad780 to
a9b7bc9
Compare
…se builtins.fetchGit.
a9b7bc9 to
f29409a
Compare
|
Thanks for merging this in. |
This updates the
mkCacheFileandmkCacheModulefunctions to support caches that are pulling from private repos withbuiltins.fetchGit.At work (@xc-jp), we have a big stack-based project that has a few private libraries in the
stack.yamlfile.In order to use private libraries with nix, we need to use
builtins.fetchGit(so that the library is fetched at eval time with the user's SSH_AUTH stuff).This PR modifies the
mkCacheFileandmkCacheModulefunctions to take anis-privateargument for the individual cache definitions. Ifis-privateis true, thenbuiltins.fetchGitis used instead of the normalpkgs.fetchgit.buitins.fetchGithas a few differences frompkgs.fetchgit(namely that you don't have to specify asha256), so there are a few differences in the arguments for the caches depending on whether you are using a private repo vs. a non-private repo.It doesn't look like there are any tests for the cache stuff, so I didn't add any tests for my changes, but I could always go back and add tests if that would be necessary.
This is related to #309, although I don't think it fully fixes it.