summaryrefslogtreecommitdiffstats
path: root/krebs/5pkgs/builders.nix
diff options
context:
space:
mode:
authormakefu <github@syntax-fehler.de>2016-06-02 11:17:18 +0200
committermakefu <github@syntax-fehler.de>2016-06-02 11:17:18 +0200
commit4f28d9a306c2989304b52889c07e22992e40da0b (patch)
treed07166696ed3bd97bb6a165418af8611b8f68571 /krebs/5pkgs/builders.nix
parentd5961aa09e399bb30f940eb5ac2cfe26dfa51d65 (diff)
parent7bd85d7bbbce68ba7317e16b805b1093ded3f1e2 (diff)
Merge remote-tracking branch 'prism/master'
Diffstat (limited to 'krebs/5pkgs/builders.nix')
-rw-r--r--krebs/5pkgs/builders.nix51
1 files changed, 48 insertions, 3 deletions
diff --git a/krebs/5pkgs/builders.nix b/krebs/5pkgs/builders.nix
index 19169b186..39b91d144 100644
--- a/krebs/5pkgs/builders.nix
+++ b/krebs/5pkgs/builders.nix
@@ -66,7 +66,52 @@ rec {
mv "$textPath" $out
'';
- writeNixFromCabal = name: path: pkgs.runCommand name {} ''
- ${pkgs.cabal2nix}/bin/cabal2nix ${path} > $out
- '';
+ writeHaskellBin =
+ k:
+ let
+ k' = parseDrvName k;
+ name = k'.name;
+ version = if k'.version != "" then k'.version else "0";
+ in
+ { build-depends ? ["base"] ++ depends
+ , depends ? []
+ , ghc-options ? ["-Wall" "-O3" "-threaded" "-rtsopts"]
+ , haskellPackages ? pkgs.haskellPackages
+ , license ? "WTFPL"
+ }:
+ main-text:
+ let
+ cabal-file = pkgs.writeText "${name}-${version}.cabal" ''
+ build-type: Simple
+ cabal-version: >= 1.2
+ name: ${name}
+ version: ${version}
+
+ executable ${name}
+ build-depends: ${concatStringsSep "," build-depends}
+ ghc-options: ${toString ghc-options}
+ main-is: ${main-file.name}
+ '';
+ main-file = pkgs.writeText "${name}-${version}.hs" main-text;
+ in
+ haskellPackages.mkDerivation rec {
+ inherit license version;
+ executableHaskellDepends = attrVals build-depends haskellPackages;
+ isExecutable = true;
+ isLibrary = false;
+ pname = name;
+ src = pkgs.runCommand "${name}-${version}-src" {} ''
+ install -D ${cabal-file} $out/${cabal-file.name}
+ install -D ${main-file} $out/${main-file.name}
+ '';
+ };
+
+ writeNixFromCabal =
+ trace (toString [
+ "The function `writeNixFromCabal` has been deprecated in favour of"
+ "`writeHaskellBin'."
+ ])
+ (name: path: pkgs.runCommand name {} ''
+ ${pkgs.cabal2nix}/bin/cabal2nix ${path} > $out
+ '');
}