Skip to content

Instantly share code, notes, and snippets.

@3noch
Last active November 1, 2016 01:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save 3noch/ffd80e935dec7a2a91d1f92207cb2a76 to your computer and use it in GitHub Desktop.
Save 3noch/ffd80e935dec7a2a91d1f92207cb2a76 to your computer and use it in GitHub Desktop.
# use it like this: (import ./fetch-cabal pkgs pkgs.haskellPackages).fetchZip "url" "sha256" "subfolder in archive"
pkgs: haskellPackages:
let
srcPackage = src: folder:
pkgs.runCommand "src-package"
{
inherit src;
buildInputs = [ pkgs.cabal2nix ];
}
''
mkdir -p $out
cp -r $src/${folder}/* $out
cd $out
cabal2nix . > package.nix
'';
fetch = src: folder: haskellPackages.callPackage "${srcPackage src folder}/package.nix" {};
in {
inherit fetch;
fromGit = url: rev: sha256: fetch (pkgs.fetchgit {
inherit url rev sha256;
});
fromZip = url: sha256: fetch (pkgs.fetchzip {
inherit url sha256;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment