From d63a8903273360aa1dccc875b871f467e48a3f01 Mon Sep 17 00:00:00 2001 From: Gregor Kleen Date: Wed, 26 Jun 2019 13:39:33 +0200 Subject: [PATCH] chore: fix build environment on NixOS --- shell.nix | 7 +++---- stack.nix | 13 ++++--------- stack.yaml | 19 +++++++------------ stackage.nix | 30 ++++++++++++++++++++++++++++++ 4 files changed, 44 insertions(+), 25 deletions(-) create mode 100644 stackage.nix diff --git a/shell.nix b/shell.nix index f98506e41..94ef0ba00 100644 --- a/shell.nix +++ b/shell.nix @@ -1,8 +1,7 @@ -{ nixpkgs ? import , compiler ? null }: +{ nixpkgs ? import }: let - inherit (nixpkgs {}) pkgs; - haskellPackages = if isNull compiler then pkgs.haskellPackages else pkgs.haskell.packages."${compiler}"; + haskellPackages = import ./stackage.nix { inherit nixpkgs; }; drv = haskellPackages.callPackage ./uniworx.nix {}; @@ -19,7 +18,7 @@ let ''; override = oldAttrs: { - nativeBuildInputs = oldAttrs.nativeBuildInputs ++ (with pkgs; [ postgresql pgadmin openldap ]) ++ (with haskellPackages; [ stack yesod-bin hlint cabal-install ]); + nativeBuildInputs = oldAttrs.nativeBuildInputs ++ (with pkgs; [ nodejs-8_x postgresql pgadmin openldap ]) ++ (with haskellPackages; [ stack yesod-bin hlint cabal-install ]); shellHook = '' export PROMPT_INFO="${oldAttrs.name}" diff --git a/stack.nix b/stack.nix index e986ba349..a9a2af3de 100644 --- a/stack.nix +++ b/stack.nix @@ -1,16 +1,11 @@ { ghc, nixpkgs ? import }: let - snapshot = "lts-10.5"; - stackage = import (fetchTarball { - url = "https://stackage.serokell.io/drczwlyf6mi0ilh3kgv01wxwjfgvq14b-stackage/default.nix.tar.gz"; - sha256 = "1bwlbxx6np0jfl6z9gkmmcq22crm0pa07a8zrwhz5gkal64y6jpz"; - }); - inherit (nixpkgs { overlays = [ stackage."${snapshot}" ]; }) haskell pkgs; - - haskellPackages = pkgs.haskell.packages."${snapshot}"; -in haskell.lib.buildStackProject { + haskellPackages = import ./stackage.nix { inherit nixpkgs; }; + inherit (nixpkgs {}) pkgs; +in pkgs.haskell.lib.buildStackProject { inherit ghc; + inherit (haskellPackages) stack; name = "stackenv"; buildInputs = (with pkgs; [ postgresql zlib libsodium diff --git a/stack.yaml b/stack.yaml index 02b25ee57..67b72469b 100644 --- a/stack.yaml +++ b/stack.yaml @@ -9,20 +9,15 @@ extra-package-dbs: [] packages: - . - - location: - git: https://github.com/pngwjpgh/zip-stream.git - commit: 9272bbed000928d500febad1cdc98d1da29d399e - extra-dep: true - - location: - git: https://github.com/pngwjpgh/encoding.git - commit: 67bb87ceff53f0178c988dd4e15eeb2daee92b84 - extra-dep: true - - location: - git: https://github.com/pngwjpgh/memcached-binary.git - commit: b5461747e7be226d3b67daebc3c9aefe8a4490ad - extra-dep: true extra-deps: + - git: https://github.com/pngwjpgh/zip-stream.git + commit: 9272bbed000928d500febad1cdc98d1da29d399e + - git: https://github.com/pngwjpgh/encoding.git + commit: 67bb87ceff53f0178c988dd4e15eeb2daee92b84 + - git: https://github.com/pngwjpgh/memcached-binary.git + commit: b5461747e7be226d3b67daebc3c9aefe8a4490ad + - colonnade-1.2.0 - yesod-colonnade-1.2.0 diff --git a/stackage.nix b/stackage.nix new file mode 100644 index 000000000..4fb2c4623 --- /dev/null +++ b/stackage.nix @@ -0,0 +1,30 @@ +{ nixpkgs ? import +, snapshot ? "lts-10.5" +}: + +let + stackage = import (fetchTarball { + url = "https://stackage.serokell.io/drczwlyf6mi0ilh3kgv01wxwjfgvq14b-stackage/default.nix.tar.gz"; + sha256 = "1bwlbxx6np0jfl6z9gkmmcq22crm0pa07a8zrwhz5gkal64y6jpz"; + }); + + overlays = + [ stackage."${snapshot}" + (self: super: { + haskell = super.haskell // { + packages = super.haskell.packages // { + "${snapshot}" = super.haskell.packages."${snapshot}".override { + overrides = hself: hsuper: { + zip-archive = self.haskell.lib.overrideCabal hsuper.zip-archive (old: { + testToolDepends = old.testToolDepends ++ (with self; [ unzip ]); + }); + }; + }; + }; + }; + } + ) + ]; + + inherit (nixpkgs { inherit overlays; }) pkgs; +in pkgs.haskell.packages."${snapshot}"