1# Generate cache entries for dependencies of package defined in `src`
5, stackYaml ? "stack.yaml"
7 # An alternative to adding `# nix-sha256:` comments into the
10 # { "https://github.com/jgm/pandoc-citeproc"."0.17"
11 # = "0dxx8cp2xndpw3jwiawch2dkrkp15mil7pyx7dvd810pwc22pm2q"; };
14 then { location, tag, ...}: sha256map."${location}"."${tag}"
16, resolverSha256 ? null
17, nix-tools ? pkgs.haskell-nix.internal-nix-tools # When building stack projects we use the internal nix-tools (compiled with a fixed GHC version)
21 # We only care about the stackYaml file. If src is a local directory
22 # we want to avoid recalculating the cache unless the stack.yaml file
25 inherit (haskellLib.fetchResolver {
26 inherit src stackYaml resolverSha256;
27 }) resolver fetchedResolver;
29 # Filter just the stack yaml file and any reolver yaml file it points to.
31 if haskellLib.canCleanSource src
32 then haskellLib.cleanSourceWith {
35 pkgs.lib.hasSuffix ("/" + stackYaml) path
36 || (resolver != null && pkgs.lib.hasSuffix ("/" + resolver) path);
40 # All repos served via ssh or git protocols are usually private
41 private = url: pkgs.lib.substring 0 4 url != "http";
43 repos = builtins.fromJSON (builtins.readFile (pkgs.runCommand "stack-repos" {
44 buildInputs = [ nix-tools ];
48 cp -r "${maybeCleanedSource}/." $TMP
50 substituteInPlace ${stackYaml} --replace "# nix-sha256:" "nix-sha256:"
51 ${pkgs.lib.optionalString (fetchedResolver != null) ''
52 substituteInPlace ${stackYaml} --replace "${resolver}" "${fetchedResolver}"
54 stack-repos --stack-yaml ${stackYaml}
58 cabalName = path: builtins.readFile (pkgs.runCommand "cabal-name" {
59 buildInputs = [ nix-tools ];
61 cabal-name ${path} > $out
65 builtins.readFile (pkgs.runCommand "hash-path" { preferLocalBuild = true; }
66 "echo -n $(${pkgs.nix}/bin/nix-hash --type sha256 --base32 ${path}) > $out");
70 is-private = private dep.url;
71 sha256 = if dep.sha256 != null
78 if !is-private && sha256 != null
80 inherit (dep) url rev;
83 else builtins.fetchGit {
84 inherit (dep) url rev;
87 name = cabalName "${pkgsrc}/${subdir}";
88 inherit (dep) url rev;
90 sha256 = if !is-private then hashPath pkgsrc else null;
91 } // (optionalAttrs (subdir != "") { inherit subdir; }))
92 (dep.subdirs or [ "" ])) repos
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list