From afb2a42e96f98219595b7bb49e068978e86ad68c Mon Sep 17 00:00:00 2001 From: Lennart Spitzner Date: Sun, 14 Jun 2020 14:18:06 +0200 Subject: [PATCH] Fix/Upgrade/Improve nix expressions --- default.nix | 2 +- nix/.gitignore | 1 + nix/all.nix | 32 ++++++++++++++++++-------------- nix/create-roots.sh | 25 +++++++++++++++++++++++++ nix/via-hackage.nix | 15 +++++++++------ nix/via-stackage.nix | 9 ++++++--- shell.nix | 2 +- stack-8.4.yaml | 1 + 8 files changed, 62 insertions(+), 25 deletions(-) create mode 100755 nix/create-roots.sh diff --git a/default.nix b/default.nix index 2143997..8df93ad 100644 --- a/default.nix +++ b/default.nix @@ -1 +1 @@ -(import ./nix/all.nix {}).default.multistate \ No newline at end of file +(import ./nix/all.nix).default.butcher \ No newline at end of file diff --git a/nix/.gitignore b/nix/.gitignore index 7556e9b..413cb59 100644 --- a/nix/.gitignore +++ b/nix/.gitignore @@ -1,2 +1,3 @@ nixpkgs.nix local-extra-deps.nix +gcroots diff --git a/nix/all.nix b/nix/all.nix index 5ef5b44..d75883a 100644 --- a/nix/all.nix +++ b/nix/all.nix @@ -5,19 +5,17 @@ let ( let haskellNix = import ( builtins.fetchTarball - https://github.com/lspitzner/haskell.nix/archive/4ad436d66d1a553d1a36d89fcab9329f10ae36e9.tar.gz + https://github.com/lspitzner/haskell.nix/archive/1873ab6de8f5a072d5405c8803f55b2fb386988f.tar.gz ) { version = 2; }; - nixpkgsSrc = haskellNix.sources.nixpkgs-1909; + nixpkgsSrc = haskellNix.sources.nixpkgs-2003; in import nixpkgsSrc haskellNix.nixpkgsArgs ); gitignoreSrc = pkgs.fetchFromGitHub { - # owner = "hercules-ci"; - owner = "lspitzner"; # TODO switch back to the above once PR is merged - # see https://github.com/hercules-ci/gitignore.nix/pull/44 + owner = "hercules-ci"; repo = "gitignore.nix"; - rev = "97d53665298d2b31b79e5fe4b60edb12a6661547"; - sha256 = "sha256:1b3z2ikpg32zsfrhv4fb17dqavgg7d4wahslxlm37w68y7adsdav"; + rev = "c4662e662462e7bf3c2a968483478a665d00e717"; + sha256 = "sha256:1npnx0h6bd0d7ql93ka7azhj40zgjp815fw2r6smg8ch9p7mzdlx"; }; inherit (import gitignoreSrc { inherit (pkgs) lib; }) gitignoreSource gitignoreFilter; cleanedSource = pkgs.lib.cleanSourceWith { @@ -47,35 +45,38 @@ let "stackage-8.4" = import ./via-stackage.nix (args // { # resolver = "lts-12.26"; stackFile = "stack-8.4.yaml"; + ghc-ver = "ghc844"; }); "stackage-8.6" = import ./via-stackage.nix (args // { # resolver = "lts-14.27"; stackFile = "stack-8.6.yaml"; + ghc-ver = "ghc865"; }); "stackage-8.8" = import ./via-stackage.nix (args // { # resolver = "lts-15.12"; stackFile = "stack-8.8.yaml"; + ghc-ver = "ghc883"; }); "hackage-8.4" = import ./via-hackage.nix (args // { ghc-ver = "ghc844"; index-state = "2020-05-01T00:00:00Z"; # plan-sha256 = "0s6rfanb6zxhr5zbinp7h25ahwasciwj3ambsr6zdxm1l782b3ap"; # materialized = ./materialized/hackage-8.4; - configureArgs = "--allow-newer multistate:*"; + configureArgs = "--allow-newer='multistate:*'"; }); "hackage-8.6" = import ./via-hackage.nix (args // { ghc-ver = "ghc865"; index-state = "2020-05-01T00:00:00Z"; # plan-sha256 = "01m95xirrh00dvdxrpsx8flhcwlwcvgr3diwlnkw7lj5f3i7rfrl"; # materialized = ./materialized/hackage-8.6; - configureArgs = "--allow-newer multistate:*"; + configureArgs = "--allow-newer='multistate:*'"; }); "hackage-8.8" = import ./via-hackage.nix (args // { ghc-ver = "ghc883"; index-state = "2020-05-01T00:00:00Z"; # plan-sha256 = "14qs7ynlf7p2qvdk8sf498y87ss5vab3ylnbpc8sacqbpv2hv4pf"; # materialized = ./materialized/hackage-8.8; - configureArgs = "--allow-newer multistate:*"; + configureArgs = "--allow-newer='multistate:*'"; }); } // (if hasAttr "ghc8101" pkgs.haskell-nix.compiler then { @@ -85,15 +86,18 @@ let # index-sha256 = "1h1x65840jl6w2qvyq9csc7b3ivadr933glarnmydk2b23vw2i77"; # plan-sha256 = "1s8a6cb5qgf4ky5s750rzx6aa52slp1skazh8kbx0dbfjd6df7yw"; # materialized = ./materialized/hackage-8.10; - configureArgs = "--allow-newer multistate:* --constraint 'splitmix<0.1'"; + configureArgs = "--allow-newer='multistate:*' --constraint 'splitmix<0.1'"; }); } else builtins.trace "warn: ghc 8.10 is not avaiable, will not be tested!" {} ); - linkFarmFromDrvs = name: drvs: - let mkEntryFromDrv = drv: { name = drv.name; path = drv; }; - in pkgs.linkFarm name (map mkEntryFromDrv drvs); in versions // { inherit cleanedSource; default = versions."stackage-8.8"; + roots = pkgs.linkFarm "haskell-nix-roots" + [ { name = "haskell-nix-roots-ghc844" ; path = pkgs.haskell-nix.roots "ghc844"; } + { name = "haskell-nix-roots-ghc865" ; path = pkgs.haskell-nix.roots "ghc865"; } + { name = "haskell-nix-roots-ghc883" ; path = pkgs.haskell-nix.roots "ghc883"; } + { name = "haskell-nix-roots-ghc8101"; path = pkgs.haskell-nix.roots "ghc8101"; } + ]; } \ No newline at end of file diff --git a/nix/create-roots.sh b/nix/create-roots.sh new file mode 100755 index 0000000..82e56d5 --- /dev/null +++ b/nix/create-roots.sh @@ -0,0 +1,25 @@ + +set -ex + +ROOTSDIR="nix/gcroots" + +function create-root { + local ATTRPATH=$1 + nix-build -o "${ROOTSDIR}/${ATTRPATH}-shell" nix/all.nix -A "\"$ATTRPATH\".shell" + nix-build -o "${ROOTSDIR}/${ATTRPATH}-test" nix/all.nix -A "\"$ATTRPATH\".butcher.components.tests.tests" + nix-build -o "${ROOTSDIR}/${ATTRPATH}-plan" nix/all.nix -A "\"$ATTRPATH\".butcher-plan" + nix-build -o "${ROOTSDIR}/${ATTRPATH}-nix" nix/all.nix -A "\"$ATTRPATH\".butcher-nix" || true +} + +mkdir -p "$ROOTSDIR" + +nix-build -o "${ROOTSDIR}/haskell-nix-roots" nix/all.nix -A "roots" + +create-root "stackage-8.4" +create-root "stackage-8.6" +create-root "stackage-8.8" + +create-root "hackage-8.4" +create-root "hackage-8.6" +create-root "hackage-8.8" +create-root "hackage-8.10" diff --git a/nix/via-hackage.nix b/nix/via-hackage.nix index f9c39af..cf0f8af 100644 --- a/nix/via-hackage.nix +++ b/nix/via-hackage.nix @@ -6,22 +6,23 @@ , index-sha256 ? null , plan-sha256 ? null , materialized ? null -, configureArgs ? null +, configureArgs ? "" }: let - butcher-plan = pkgs.haskell-nix.importAndFilterProject (pkgs.haskell-nix.callCabalProjectToNix { + butcher-nix = pkgs.haskell-nix.callCabalProjectToNix { src = cleanedSource; inherit index-state index-sha256 plan-sha256 materialized configureArgs; # ghc = pkgs.haskell-nix.compiler.${ghc-ver}; compiler-nix-name = ghc-ver; - }); + }; + butcher-plan = pkgs.haskell-nix.importAndFilterProject { inherit (butcher-nix) projectNix sourceRepos src; }; in rec { - inherit butcher-plan pkgs; + inherit butcher-nix butcher-plan pkgs; hsPkgs = let in let pkg-set = pkgs.haskell-nix.mkCabalProjectPkgSet - { plan-pkgs = butcher-plan.pkgs; + { plan-pkgs = butcher-plan; pkg-def-extras = pkg-def-extras; modules = [ { ghc.package = pkgs.haskell-nix.compiler.${ghc-ver}; } @@ -47,9 +48,11 @@ in rec { # tools = { cabal = "3.2.0.0"; }; # See overlays/tools.nix for more details + tools = { ghcid = "0.8.7"; cabal = "3.2.0.0"; }; + # Some you may need to get some other way. buildInputs = with pkgs.haskellPackages; - [ pkgs.haskell-nix.cabal-install ghcid bash pkgs.nix ]; + [ bash pkgs.nix ]; # Prevents cabal from choosing alternate plans, so that # *all* dependencies are provided by Nix. diff --git a/nix/via-stackage.nix b/nix/via-stackage.nix index 172a76f..bb8f2cc 100644 --- a/nix/via-stackage.nix +++ b/nix/via-stackage.nix @@ -1,4 +1,5 @@ { pkgs +, ghc-ver , cleanedSource , stackFile , pkg-def-extras ? [] @@ -47,12 +48,12 @@ let stackYaml = stackFile; }; hsPkgs = (pkgs.haskell-nix.mkStackPkgSet { - stack-pkgs = butcher-plan.pkgs; + stack-pkgs = butcher-plan; pkg-def-extras = pkg-def-extras; modules = pkgs.lib.singleton (pkgs.haskell-nix.mkCacheModule generatedCache); }).config.hsPkgs; in { - inherit butcher-plan hsPkgs pkgs; + inherit butcher-nix butcher-plan hsPkgs pkgs; inherit (hsPkgs) butcher; inherit (hsPkgs.butcher) checks; shell = hsPkgs.shellFor { @@ -71,9 +72,11 @@ in { # tools = { cabal = "3.2.0.0"; }; # See overlays/tools.nix for more details + tools = { ghcid = "0.8.7"; cabal = "3.2.0.0"; }; + # Some you may need to get some other way. buildInputs = with pkgs.haskellPackages; - [ cabal-install ghcid bash pkgs.nix ]; + [ bash pkgs.nix ]; # Prevents cabal from choosing alternate plans, so that # *all* dependencies are provided by Nix. diff --git a/shell.nix b/shell.nix index f8a2f7e..1d1566e 100644 --- a/shell.nix +++ b/shell.nix @@ -1 +1 @@ -(import ./nix/all.nix {}).default.shell +(import ./nix/all.nix).default.shell diff --git a/stack-8.4.yaml b/stack-8.4.yaml index 7ecfbda..d839e5a 100644 --- a/stack-8.4.yaml +++ b/stack-8.4.yaml @@ -43,6 +43,7 @@ extra-deps: - extra-1.7.1 - strict-list-0.1.5 - barbies-2.0.1.0 +- hsc2hs-0.68.7 # Override default flag values for local packages and extra-deps # flags: {}