From 5abb454ec02400e6b33cc61b9f97e19769a0f592 Mon Sep 17 00:00:00 2001 From: EncodePanda Date: Wed, 7 Apr 2021 12:05:55 +0200 Subject: [PATCH 1/2] Upgrade haskell.nix and bind nixpkgs to what haskell.nix exposes for better cache hits We've upgraded haskell.nix to latest revision. Also instead of explicitly pointing to nixpkgs (in sources.json) - which requires us to manually updated it each time we upgrade haskell.nix in order to get cache hits - we've modified the default.nix so that it explicitly picks haskell.nix's nixpkgs. In other words, next time some one wants to update haskell.nix it should be a matter of just calling 'niv update haskell.nix' and commiting changes. Script will automatically pick the right nixpkgs. In this commit we did not modified iohk-nix entry. It might be the case that it should also be updated. Co-authored-by: Javier Sagredo --- nix/default.nix | 18 +++++------------- nix/sources.json | 18 +++--------------- 2 files changed, 8 insertions(+), 28 deletions(-) diff --git a/nix/default.nix b/nix/default.nix index cb7e9acdef9..05246212421 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -7,22 +7,14 @@ let sources = import ./sources.nix { pkgs = import iohkNixMain.nixpkgs { }; } // sourcesOverride; iohkNixMain = import sources.iohk-nix { }; - haskellNix = (import sources."haskell.nix" { inherit system sourcesOverride; }).nixpkgsArgs; - # use our own nixpkgs if it exists in our sources, - # otherwise use iohkNix default nixpkgs. - nixpkgs = - if (sources ? nixpkgs) - then - (builtins.trace "Not using IOHK default nixpkgs (use 'niv drop nixpkgs' to use default for better sharing)" - sources.nixpkgs) - else - (builtins.trace "Using IOHK default nixpkgs" - iohkNixMain.nixpkgs); + haskellNix = import sources."haskell.nix" { inherit system sourcesOverride; }; + haskellNixArgs = haskellNix.nixpkgsArgs; + nixpkgs = haskellNix.sources.nixpkgs-2009; # for inclusion in pkgs: overlays = # Haskell.nix (https://github.com/input-output-hk/haskell.nix) - haskellNix.overlays + haskellNixArgs.overlays # haskell-nix.haskellLib.extra: some useful extra utility functions for haskell.nix ++ iohkNixMain.overlays.haskell-nix-extra ++ iohkNixMain.overlays.crypto @@ -44,7 +36,7 @@ let pkgs = import nixpkgs { inherit system crossSystem overlays; - config = haskellNix.config // config; + config = haskellNixArgs.config // config; }; in diff --git a/nix/sources.json b/nix/sources.json index aa5c8498c08..bf45ce4a026 100644 --- a/nix/sources.json +++ b/nix/sources.json @@ -5,10 +5,10 @@ "homepage": "https://input-output-hk.github.io/haskell.nix", "owner": "input-output-hk", "repo": "haskell.nix", - "rev": "958e9d3e9ec53fbce72ac720b10a6418f3b477f0", - "sha256": "0j9p3xyck636gv87rwd6yl7w9ssv3jwrfqyxvhpchszkj097qwi6", + "rev": "1b9b05beed75a1be98405501fbb33ac1f080069e", + "sha256": "0679ymbjm7z3qbiv9wf7f22rxdwzkpk0jlh1by0rswdmbwqi5786", "type": "tarball", - "url": "https://github.com/input-output-hk/haskell.nix/archive/958e9d3e9ec53fbce72ac720b10a6418f3b477f0.tar.gz", + "url": "https://github.com/input-output-hk/haskell.nix/archive/1b9b05beed75a1be98405501fbb33ac1f080069e.tar.gz", "url_template": "https://github.com///archive/.tar.gz" }, "iohk-nix": { @@ -34,17 +34,5 @@ "type": "tarball", "url": "https://github.com/input-output-hk/niv/archive/89da7b2e7ae0779fd351618fc74df1b1da5e6214.tar.gz", "url_template": "https://github.com///archive/.tar.gz" - }, - "nixpkgs": { - "branch": "nixpkgs-20.09-darwin", - "description": "Nix Packages collection", - "homepage": null, - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "fbc078d2451d67b3091ead72ddece78a3d48c226", - "sha256": "01fysh7bnbwr135qn0j9rs77widi4isznj8arda5f6dpab24pyki", - "type": "tarball", - "url": "https://github.com/NixOS/nixpkgs/archive/fbc078d2451d67b3091ead72ddece78a3d48c226.tar.gz", - "url_template": "https://github.com///archive/.tar.gz" } } From 832bd91c78a94334a367989d0ba26b2e1455c9d3 Mon Sep 17 00:00:00 2001 From: EncodePanda Date: Wed, 7 Apr 2021 16:41:11 +0200 Subject: [PATCH 2/2] Add ability to swap nixpkgs via niv As requested by reviewer --- nix/default.nix | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/nix/default.nix b/nix/default.nix index 05246212421..cab740e9dba 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -9,8 +9,17 @@ let iohkNixMain = import sources.iohk-nix { }; haskellNix = import sources."haskell.nix" { inherit system sourcesOverride; }; haskellNixArgs = haskellNix.nixpkgsArgs; - nixpkgs = haskellNix.sources.nixpkgs-2009; - + nixpkgs = + if (sources ? nixpkgs) + then + (builtins.trace "Not using nixpkgs that haskell.nix is exposing. + * This means that you've added entry to 'sources.json' via niv. + * This is fine, but please be aware that you might be getting less cache hits. + * Use 'niv drop nixpkgs' to use haskell.nix's nixpkgs" + sources.nixpkgs) + else + (builtins.trace "Using haskell.nix's nixpkgs. Good. Sharing is caring" + haskellNix.sources.nixpkgs-2009); # for inclusion in pkgs: overlays = # Haskell.nix (https://github.com/input-output-hk/haskell.nix)