Siggsy

Melting flakes

2026/06/14 [nix] [flakes]

I use nix in every git repository to document the contex of the project. I lost count at the amount of times it saved me by removing the “bootstraping” phase of revisiting an old project. Unfortunatelly, because I used flakes, this came at a cost: every project has its own version of nixpkgs, and in practice, because for now nix uses input-addressed derivations, you end up with multiple copies of “the same” package. At some point I had 6 instances of nixpkgs#ghc, each taking up

console (docs)

$ nix path-info --recursive --size --closure-size --human-readable nixpkgs#ghc

# Path                                                  size     closure-size
...
/nix/store/k493jzz83044mqayvlb6247l35780kxy-ghc-9.10.3  1.8G     3.0G

Not to mention nixpkgs#haskell-language-server

console

$ nix path-info --recursive --size --closure-size --human-readable nixpkgs#haskell-language-server

# Path                                                                        size     closure-size
...
/nix/store/ymvsfvbhw5kvw639cv8k447v1v6jbsc4-haskell-language-server-2.13.0.0  110.9M   7.5G
/nix/store/ps0yfb2bvv33srn6fcnwfiw8rg7w5g7s-haskell-language-server-2.13.0.0  896.0    7.5G

Strictly speaking, I have no need for multiple ghc/hls versions. Pre-nix I just used the most recent without any major issues. Most software cannot assume everyone has nix-adjacent package managers, so most of the time there is some leeway when it comes to version pinning. Lets abuse this a bit

Since the problem is different versions of nixpkgs in flake.lock files, I pinned system flake registry nixpkgs input

modules/the-shire/core/nix.nix

registry = {
  self.flake = inputs.self;
  nixpkgs.to = {
    owner = "NixOS";
    repo = "nixpkgs";
    rev = inputs.nixpkgs.rev;
    type = "github";
  };
};

and added a zsh function so I can update an old project to my current system’s nixpkgs

modules/hjem/zsh.nix

nix-spicy-lock() {
  nix flake lock --override-input nixpkgs flake:nixpkgs --output-lock-file flake.lock "$@"
}