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}"
17 # A way to specify in which branch a git commit can
21 then { location, tag, ...}: branchMap."${location}"."${tag}" or null
23, resolverSha256 ? null
24, nix-tools ? pkgs.haskell-nix.internal-nix-tools # When building stack projects we use the internal nix-tools (compiled with a fixed GHC version)
28 # We only care about the stackYaml file. If src is a local directory
29 # we want to avoid recalculating the cache unless the stack.yaml file
32 inherit (haskellLib.fetchResolver {
33 inherit src stackYaml resolverSha256;
34 }) resolver fetchedResolver;
36 # Filter just the stack yaml file and any resolver yaml file it points to.
38 if haskellLib.canCleanSource src
39 then haskellLib.cleanSourceWith {
43 origSrc = if src ? _isLibCleanSourceWith then src.origSrc else src;
44 origSubDir = if src ? _isLibCleanSourceWithEx then src.origSubDir else "";
45 relPath = pkgs.lib.removePrefix (toString origSrc + origSubDir + "/") path;
47 # checks if path1 is a parent directory for path2
48 isParent = path1: path2: pkgs.lib.hasPrefix "${path1}/" path2;
51 (relPath == stackYaml)
52 || (resolver != null && (relPath == resolver || isParent relPath resolver))
57 # All repos served via ssh or git protocols are usually private
58 private = url: pkgs.lib.substring 0 4 url != "http";
60 repos = builtins.fromJSON (builtins.readFile (pkgs.runCommand "stack-repos" {
61 buildInputs = [ nix-tools ];
65 cp -r "${maybeCleanedSource}/." $TMP
67 substituteInPlace ${stackYaml} --replace "# nix-sha256:" "nix-sha256:"
68 ${pkgs.lib.optionalString (fetchedResolver != null) ''
69 substituteInPlace ${stackYaml} --replace "${resolver}" "${fetchedResolver}"
71 stack-repos --stack-yaml ${stackYaml}
75 cabalName = path: builtins.readFile (pkgs.runCommand "cabal-name" {
76 buildInputs = [ nix-tools ];
78 cabal-name ${path} > $out
82 builtins.readFile (pkgs.runCommand "hash-path" { preferLocalBuild = true; }
83 "echo -n $(${pkgs.nix}/bin/nix-hash --type sha256 --base32 ${path}) > $out");
87 is-private = private dep.url;
88 sha256 = if dep.sha256 != null
94 branch = lookupBranch {
99 if !is-private && sha256 != null
101 inherit (dep) url rev;
104 else builtins.fetchGit ({
105 inherit (dep) url rev;
106 } // pkgs.lib.optionalAttrs (branch != null) { ref = branch; });
108 name = cabalName "${pkgsrc}/${subdir}";
109 inherit (dep) url rev;
111 sha256 = if !is-private then hashPath pkgsrc else null;
112 } // (optionalAttrs (subdir != "") { inherit subdir; }))
113 (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