1

I am using nixops and want to reduce disk space consumption by sharing nix store among instances.

Possible implementation:

  • share /nix/store store through elastic file system.
  • make cron job on random machine inside network that runs nix-collect-garbage -d. This will remove all packages that are not linked with first machine: actually stale packages and packages of other machines inside network. To restore them first machine triggers nixos-rebuild switch on other machines inside network.

Can this be done better/does this make sense?

  • 1
    Not sure if this works for NixOS, but I once shared the nix store via NFS: nixos.wiki/wiki/NFS#Nix_store_on_NFS You could probably put overlayfs on top of NFS to allow local modifications. – Mic92 May 22 '18 at 15:13
  • The nixos iso also shows how readonly and read-write layers can be overlayed: github.com/NixOS/nixpkgs/blob/master/nixos/modules/installer/… – Mic92 May 22 '18 at 15:17
  • Only having a single read-only /nix/store has it caveats as the nix store also store configuration files. Sharing the same elastic filesystem could work so, if your network storage implements posix file locking. nix-collect-garbage usually relies on seeing other processes using files - in a distributed settings it might delete files in use. – Mic92 May 22 '18 at 15:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.