Open
Description
After reading this, this and this, I still can't figure out how to prevent flake devShell dependencies from being garbage collected by nix store gc
. M(N)WE:
flake.nix
{
description = "test";
inputs = {
flake-parts.url = "github:hercules-ci/flake-parts";
haskellNix.url = "github:input-output-hk/haskell.nix";
nixpkgs.follows = "haskellNix/nixpkgs-unstable";
};
outputs = inputs@{ flake-parts, nixpkgs, haskellNix, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
perSystem = { self', system, ... }:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ haskellNix.overlay ];
inherit (haskellNix) config;
};
proj = pkgs.haskell-nix.project {
src = ./.;
compiler-nix-name = "ghc966";
};
in
{
devShells.default = proj.shellFor {
withHoogle = false;
buildInputs = [ proj.roots ];
};
};
};
}
test.cabal
cabal-version: 1.12
name: test
version: 1.0.0
build-type: Simple
$ nix develop . --profile nixenv
$ nix store gc
129 store paths deleted, 1551.01 MiB freed
BTW if the proj.roots
line is removed, the garbage is even larger:
188 store paths deleted, 3325.91 MiB freed
Usually this isn't a huge problem because only the flake inputs are GC'd (mostly nixpkgs), but with haskell.nix the collected garbage is much larger and seems not limited to flake inputs (I might be wrong). Can someone provide a minimal example where nothing is GC'd?