After being chewed out by my sysadmin over slack for asking whether we can enable user namespaces on the compute cluster, I am interested in building a statically linked nix executable with custom /nix/store and /nix/var locations that I can transfer over to the cluster with a copy of nixpkgs and rebuild everything I need from scratch.
Here is what I have so far:
with (import <nixpkgs> {});
pkgsStatic.nix.overrideAttrs (oldAttrs: rec {
configureFlags = [ "--with-store-dir=/foo/.nix/store"
"--localstatedir=/foo/.nix/var"
"--sysconfdir=/foo/.nix/etc"
"--enable-gc"
"--disable-shared"
"--build=x86_64-unknown-linux-gnu"
"--host=x86_64-unknown-linux-musl" ];
})
but the resulting executable keeps trying to lstat /nix
when doing anything non trivial which is undesirable.
Is what I am trying to do even possible? If so, it would be super useful for people who want to use nix on large shared computer systems, and I would be more than happy to put in the work to get it done.