Skip to content

Instantly share code, notes, and snippets.

@Profpatsch
Created May 26, 2017 18:00
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Profpatsch/bfe0d13de28413e68c783a9aa0fe8962 to your computer and use it in GitHub Desktop.
Save Profpatsch/bfe0d13de28413e68c783a9aa0fe8962 to your computer and use it in GitHub Desktop.
hpack to nix file in nix expression
let
hpack2nix =
name: src:
let
addCabalFile = stdenv.mkDerivation {
inherit name src;
phases = [ "unpackPhase" "patchPhase" "installPhase" ];
installPhase = ''cp -r . $out'';
patchPhase = ''
${haskellPackages.hpack}/bin/hpack
'';
};
nixFile = runCommand "${name}.nix" {} ''
cd ${addCabalFile}
find
${haskellPackages.cabal2nix}/bin/cabal2nix . > $out
sed -ie "s|\./\.|${addCabalFile}|" $out
'';
in nixFile;
in hpack2nix
@bsima
Copy link

bsima commented Feb 15, 2018

needs with import <nixpkgs> {}; at the top to bring in the runCommand function

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment