This is something you might want to do if you have an existing store directory on another dataset but don't want to overlay mount it onto /nix/store
.
~/shell.nix
is
{
pkgs ? import <nixpkgs> {
overlays = [
(self: super: {
nix = super.nix.override {
storeDir = "/mnt/nix/store";
stateDir = "/mnt/nix/var";
};
})
];
}
}: pkgs.mkShell {
buildInputs = [
pkgs.nix
pkgs.nix-serve
];
}
nixpkgs
revision: https://github.com/NixOS/nixpkgs-channels/archive/fce7562cf46727fdaf801b232116bc9ce0512049.tar.gz
~ # readlink -f /root/.nix-defexpr/channels/nixos/
/nix/store/xv5v445yf322zfh0xirb05vpw2jyjk4m-nixos-20.09pre223023.fce7562cf46/nixos
~ # nix-shell
# ...
~ # nix-serve -p 8080
# in another terminal
~ # curl http://127.0.0.1:8080/nix-cache-info
StoreDir: /mnt/nix/store
WantMassQuery: 1
Priority: 30
~ # nixos-install --option extra-binary-caches http://127.0.0.1:8080/
warning: binary cache 'http://127.0.0.1:8080' is for Nix stores with prefix '/mnt/nix/store', not '/nix/store'
🥺