From 178c5d54d533c4fd594e2e5fe9d2b8c570838058 Mon Sep 17 00:00:00 2001 From: Remo Date: Tue, 21 Apr 2020 17:59:33 +0200 Subject: [PATCH] Integrate stack in the nix-shell environment --- nix/README.md | 4 +++- shell.nix | 8 ++++++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/nix/README.md b/nix/README.md index 84f84df9a..820c99f5d 100644 --- a/nix/README.md +++ b/nix/README.md @@ -38,7 +38,9 @@ nix-shell ``` -Within `nix-shell`, you can run Cabal commands as usual. +Within `nix-shell`, you can run Cabal commands as usual. You can also run +stack with the `--nix` option, which causes stack to pick up the non-Haskell +dependencies from the same pinned Nixpkgs version that the Nix builds use. ## Tour diff --git a/shell.nix b/shell.nix index 69bca8533..c5989dd03 100644 --- a/shell.nix +++ b/shell.nix @@ -4,9 +4,17 @@ pkgs.lib.overrideDerivation env ( buildInputs = base.buildInputs ++ [ pkgs.cabal-install + pkgs.stack pkgs.cabal2nix pkgs.postgresql nixpkgsUpgrade ]; + + shellHook = + '' + # Set our pinned version of Nixpkgs in the NIX_PATH so that + # `stack --nix` also uses that version. + NIX_PATH="nixpkgs=${pinnedPkgs}" + ''; } )