nix-super/scripts
Dave Nicponski a2b7baa42f
Set HOME var to root's home when running nix-store as root
A [recent-ish change](https://github.com/NixOS/nix/pull/6676) logs a warning when a potentially counterintuitive situation happens.

This now causes the multi-user installer to [emit a warning](https://github.com/NixOS/nixpkgs/issues/189043) when it's doing
the "seed the Nix database" step via a low-level `nix-store --load-db` invocation.

`nix-store` functionality implementations don't actually use profiles or channels or homedir as far as i can tell.  So why are we 
hitting this code at all?  

Well, the current command approach for functionality here builds a [fat `nix` binary](https://github.com/NixOS/nix/blob/master/src/nix/local.mk#L23-L26) which has _all_ the functionality of
previous individual binaries (nix-env, nix-store, etc) bundled in, then [uses the invocation name](https://github.com/NixOS/nix/blob/master/src/nix/main.cc#L274-L277) to select the
set of commands to expose.  `nix` itself has this behavior, even when just trying to parse the (sub)command and arguments:

```
dave @ davembp2
$ nix
error: no subcommand specified
Try 'nix --help' for more information.

dave @ davembp2
$ sudo nix
warning: $HOME ('/Users/dave') is not owned by you, falling back to the one defined in the 'passwd' file
error: no subcommand specified
Try 'nix --help' for more information.

dave @ davembp2
$ HOME=~root sudo nix
error: no subcommand specified
Try 'nix --help' for more information.
```

This behavior can also be seen pretty easily with an arbitrary `nix-store` invocation:
```
dave @ davembp2 
$ nix-store --realize

dave @ davembp2 
$ sudo nix-store --realize  # what installer is doing now
warning: $HOME ('/Users/dave') is not owned by you, falling back to the one defined in the 'passwd' file

dave @ davembp2
$ sudo HOME=~root nix-store --realize  # what this PR effectively does

dave @ davembp2
$ 
```
2022-08-31 17:25:26 -04:00
..
bigsur-nixbld-user-migration.sh fix nixbld user name/uid for macOS 2021-03-11 10:16:34 -06:00
check-hydra-status.sh curl: Use --fail to catch errors 2022-04-06 13:34:25 +02:00
create-darwin-volume.sh darwin-install: work around existing vim swapfiles 2022-06-01 09:41:00 -05:00
install-darwin-multi-user.sh darwin-install: fix shell hint 2022-08-23 19:38:53 -04:00
install-multi-user.sh Set HOME var to root's home when running nix-store as root 2022-08-31 17:25:26 -04:00
install-nix-from-closure.sh Fix --no-daemon installation 2022-07-12 16:15:21 +02:00
install-systemd-multi-user.sh scripts/install-systemd-multi-user.sh: fix another typo 2022-03-31 22:14:53 +03:00
install.in curl: Use --fail to catch errors 2022-04-06 13:34:25 +02:00
local.mk Remove nix-reduce-build and nix-http-export 2021-11-18 21:17:57 +01:00
nix-profile-daemon.sh.in Apply some shellcheck suggestions 2021-11-19 15:18:10 +01:00
nix-profile.sh.in Document usage of MANPATH in nix-profile.sh 2022-02-21 13:35:55 +01:00
prepare-installer-for-github-actions Apply some shellcheck suggestions 2021-11-19 15:18:10 +01:00