Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to prevent flake devShell dependencies from being garbage collected? #2249

Open
jameswhqi opened this issue Sep 16, 2024 · 0 comments
Open

Comments

@jameswhqi
Copy link

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?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant