I remember doing this a couple of years ago. I think this can be compared to bootstrapping a compiler toolchain on a new target. The point being that the nix that you built is only half way. It will “live” in /nix/store but know how to build for /foo. You will need to build a third nix using that second nix that will live in /foo and build for /foo.
Knedlsepp in discourse.nixos
Nixpkgs Overlays – A place for all excluded packages by Nicolas B. Pierron (NixCon 2017), start=467 end=501
TODO:
.override
thishttps://github.com/NixOS/nix/issues/585
https://github.com/NixOS/nix/commit/2a9fddc0b16d9b4771d11fc10d8b2a9cba55ff64
https://rgoswami.me/posts/local-nix-no-root/#patches
https://nixos.org/manual/nixpkgs/stable/#chap-overlays
https://github.com/NixOS/nixpkgs/blob/79c7b6a353e22f0eec342dead0bc69fb7ce846db/nixos/modules/services/misc/nix-daemon.nix#L75-L76
nix in custom location
https://gist.github.com/eqyiel/64007446616e412229fbfa07b6eef873
https://blog.flyingcircus.io/2017/11/07/nixos-the-dos-and-donts-of-nixpkgs-overlays/
https://discourse.nixos.org/t/why-the-overlays-defined-in-flake-nix-must-use-final-and-prev-as-arguments/9740/5
https://www.reddit.com/r/NixOS/comments/64ndq8/what_if_i_cant_create_nix_apologies_if_faq/dg4u8p3/?utm_source=reddit&utm_medium=web2x&context=3
https://github.com/NixOS/nix/issues/1559
https://github.com/NixOS/nixpkgs/pull/144197#issuecomment-965351423
https://github.com/nix-community/nix-user-chroot
https://github.com/NixOS/nix/issues/2764
https://github.com/NixOS/nixpkgs/blob/cc5f7c2f3dd3a288c540c287c7788242a2b557c5/nixos/modules/virtualisation/qemu-vm.nix#L131
TODO: