Skip to content

Prevent nix-collect-garbage from invalidating cache #34

Description

@unode

Hi everyone,

First thank you for this project. It completely removes the slowdown seen with nix-shell scripts so I'm relying on it a lot these days.
One issue I'm experiencing however is that the cache gets invalidated by nix-collect-garbage.

To avoid this I'm using nix-instantiate inside the script to pin (some of) the packages used.

A typical script looks like:

#!/usr/bin/env cached-nix-shell
#!nix-shell -i bash -p bash packageA packageB

nix-instantiate '<nixpkgs>' -A bash -A packageA -A packageB --indirect --add-root "$HOME/nix/pins/packageAB.drv"
(...)

However, this has the downside that for some packages nix-instantiate also takes some time to execute which removes some of the benefit of using cached-nix-shell.

Is there any way to pin the same packages that were used by the shell without this nix-instantiate hack?

Thanks

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions