From 0d8a0ed71d370455f192efea903e96b01ab86e25 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 25 May 2016 00:08:34 +0200 Subject: writeHaskellBin: init --- krebs/5pkgs/builders.nix | 40 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) (limited to 'krebs') diff --git a/krebs/5pkgs/builders.nix b/krebs/5pkgs/builders.nix index 19169b186..8506801bb 100644 --- a/krebs/5pkgs/builders.nix +++ b/krebs/5pkgs/builders.nix @@ -66,6 +66,46 @@ rec { mv "$textPath" $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 = name: path: pkgs.runCommand name {} '' ${pkgs.cabal2nix}/bin/cabal2nix ${path} > $out ''; -- cgit v1.2.3 From 2b71d7f72865215717a2c604cb391f87af73c0a9 Mon Sep 17 00:00:00 2001 From: tv Date: Wed, 25 May 2016 00:28:09 +0200 Subject: writeNixFromCabal: deprecate --- krebs/5pkgs/builders.nix | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) (limited to 'krebs') diff --git a/krebs/5pkgs/builders.nix b/krebs/5pkgs/builders.nix index 8506801bb..39b91d144 100644 --- a/krebs/5pkgs/builders.nix +++ b/krebs/5pkgs/builders.nix @@ -106,7 +106,12 @@ rec { ''; }; - writeNixFromCabal = name: path: pkgs.runCommand name {} '' - ${pkgs.cabal2nix}/bin/cabal2nix ${path} > $out - ''; + writeNixFromCabal = + trace (toString [ + "The function `writeNixFromCabal` has been deprecated in favour of" + "`writeHaskellBin'." + ]) + (name: path: pkgs.runCommand name {} '' + ${pkgs.cabal2nix}/bin/cabal2nix ${path} > $out + ''); } -- cgit v1.2.3