Last active
December 7, 2019 13:22
-
-
Save yorickvP/87882776444ea1d00d8453edfd4edaf0 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# usage: cache = import ./cache.nix { pkgs, stackYaml = ./stack.yaml; } | |
let sources = import ../nix/sources.nix; | |
in { pkgs ? import sources.nixpkgs { }, stackYaml ? ./stack.yaml }: | |
let | |
s2n = import "${sources.stack-to-nix}/lib.nix" pkgs; | |
deps = (s2n.importYAML stackYaml).extra-deps or [ ]; | |
hashPath = path: pkgs.runCommand "hash-path" { | |
preferLocalBuild = true; | |
} '' | |
echo -n \'\'$(${pkgs.nix}/bin/nix-hash --type sha256 --base32 ${path})\'\' > $out | |
''; | |
in with pkgs.lib; | |
concatMap (dep: | |
if isString dep then | |
[ ] | |
else | |
let | |
pkgsrc = builtins.fetchGit { | |
url = dep.git; | |
ref = "*"; | |
rev = dep.commit; | |
}; | |
in map (subdir: | |
{ | |
name = s2n.cabalPackageName "${pkgsrc}/${subdir}"; | |
rev = dep.commit; | |
url = dep.git; | |
sha256 = import (hashPath pkgsrc); | |
} // (optionalAttrs (subdir != "") { inherit subdir; })) | |
(dep.subdirs or [ "" ])) deps |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment