diff options
author | Ben Sima <ben@bsima.me> | 2019-08-31 00:42:02 -0700 |
---|---|---|
committer | Ben Sima <ben@bsima.me> | 2019-08-31 00:42:02 -0700 |
commit | 19732ae8d1da6347ab48c1123758fde6ace7a734 (patch) | |
tree | b96f7ca6ea748806735d04f30ce6594837e4517f | |
parent | c72ae999c2850a01901e94ff22956921571cbb73 (diff) |
pack: a common bild function
-rw-r--r-- | default.nix | 7 | ||||
-rw-r--r-- | lore/bild.nix | 49 | ||||
-rw-r--r-- | pack/default.nix | 7 | ||||
-rw-r--r-- | pack/ibb.nix | 82 |
4 files changed, 86 insertions, 59 deletions
diff --git a/default.nix b/default.nix index 543f571..ab8089b 100644 --- a/default.nix +++ b/default.nix @@ -1,4 +1,7 @@ +let + nixpkgs = import "${builtins.fetchTarball (import ./pack/nixpkgs.nix)}" {}; +in { -depo = import ./depo; -pack = import ./pack; + depo = import ./depo; + pack = import ./pack { inherit nixpkgs; }; } diff --git a/lore/bild.nix b/lore/bild.nix new file mode 100644 index 0000000..8a6d510 --- /dev/null +++ b/lore/bild.nix @@ -0,0 +1,49 @@ +{ + # a common build function + # + # see example usage in pack/ibb.nix. this is not set in stone, obviously. we + # should figure out how to use overlays, for one. + # + bild = file: { nixpkgs }: + with nixpkgs; + let + pack = import file; + + depsToPackageSet = packageSet: deps: + map (s: builtins.getAttr s packageSet) deps; + + ghc = pkgs.haskell.packages.ghc844.ghcWithPackages (hp: + depsToPackageSet hp + ([ "hinotify" ] ++ pack.deps.both ++ pack.deps.apex)); + + ghcjs_ = pkgs.haskell.packages.ghcjs.override (oldAttrs: { + overrides = with pkgs.haskell.lib; self: super: { + http-types = dontCheck super.http-types; + tasty-quickcheck = dontCheck super.tasty-quickcheck; + scientific = dontCheck super.scientific; # takes forever + servant = dontCheck super.servant; + comonad = dontCheck super.comonad; + QuickCheck = dontCheck super.QuickCheck; + }; + }); + + ghcjs = ghcjs_.ghcWithPackages (hp: + depsToPackageSet hp (pack.deps.both ++ pack.deps.aero)); + + make = ../chip/make; + in + stdenv.mkDerivation { + name = pack.name; + version = "0"; + src = ../.; + nativeBuildInputs = [ + ghc ghcjs + ]; + strictDeps = true; + buildPhase = "${ghc}/bin/runhaskell ${make} ${pack.name}"; + installPhase = '' + mkdir -p $out/bin + cp bild/${pack.name} $out/bin/${pack.name} + ''; + }; +} diff --git a/pack/default.nix b/pack/default.nix index 3e7ff2d..db2a655 100644 --- a/pack/default.nix +++ b/pack/default.nix @@ -1,10 +1,11 @@ -{ nixpkgs ? import "${builtins.fetchTarball (import ./nixpkgs.nix)}" {} -}: +{ nixpkgs }: + +with import ../lore/bild.nix; { bs = import ./bs.nix { inherit nixpkgs; }; cmdwave = import ./cmdwave.nix { inherit nixpkgs; }; duree = import ./duree.nix { inherit nixpkgs; }; fathom = import ./fathom.nix { inherit nixpkgs; }; - ibb = import ./ibb.nix { inherit nixpkgs; }; + ibb = bild ./ibb.nix { inherit nixpkgs; }; } diff --git a/pack/ibb.nix b/pack/ibb.nix index fe74346..c531a34 100644 --- a/pack/ibb.nix +++ b/pack/ibb.nix @@ -1,56 +1,30 @@ -{ nixpkgs }: -with nixpkgs; -let - ghc = pkgs.haskell.packages.ghc844.ghcWithPackages (hp: with hp; [ - hinotify - - acid-state - blaze-html - blaze-markup - bytestring - miso - MonadRandom - protolude - random - scotty - servant - servant-server - shakespeare - text - ]); - ghcjs_ = pkgs.haskell.packages.ghcjs.override (oldAttrs: { - overrides = with pkgs.haskell.lib; self: super: { - http-types = dontCheck super.http-types; - tasty-quickcheck = dontCheck super.tasty-quickcheck; - scientific = dontCheck super.scientific; # takes forever - servant = dontCheck super.servant; - comonad = dontCheck super.comonad; - QuickCheck = dontCheck super.QuickCheck; - }; - }); - ghcjs = ghcjs_.ghcWithPackages (hp: with hp; [ - aeson - containers - ghcjs-base - miso - protolude - servant - text - ]); - make = ../chip/make; - entrypoint = "Ibb"; -in -stdenv.mkDerivation rec { +{ name = "ibb"; - version = "0"; - src = ../.; - nativeBuildInputs = [ - ghc ghcjs - ]; - strictDeps = true; - buildPhase = "${ghc}/bin/runhaskell ${make} ibb"; - installPhase = '' - mkdir -p $out/bin - cp bild/${name} $out/bin/${name} - ''; + deps = { + both = [ + "miso" + "protolude" + "servant" + "text" + ]; + apex = [ + "MonadRandom" + "acid-state" + "blaze-html" + "blaze-markup" + "bytestring" + "ixset" + "random" + "safecopy" + "scotty" + "servant-server" + "shakespeare" + "text" + ]; + aero = [ + "aeson" + "containers" + "ghcjs-base" + ]; + }; } |