News for hackers. Stuff that matters.
Re:macOS Sonoma is available today by bshacklett on Tuesday September 26, 2023 @06:48PM (#37666877)
My issue with Nix is that you are forced to install packages in a global location. Why is it that every package manager assumes I’m an administrator on my machine? Even if I am, how does it make sense to take over a global directory as a single user?
Re:macOS Sonoma is available today by miniBill on Tuesday September 26, 2023 @07:28PM (#37667330)
Nix does not require you to be an administrator to install a package though!
[dead]
Re:macOS Sonoma is available today by iFreilicht on Wednesday September 27, 2023 @03:48AM (#37671450)
So this is possible, but there are a lot of caveats. First, the installer itself explicitly says:

```

# Please don't change this. We don't support it, because the

# default shell profile that comes with Nix doesn't support it.

readonly NIX_ROOT="/nix"

```

I haven't seen any configurations where the entire /nix is relocated, but nix _does_ support relocating the store with the environment variable `NIX_STORE_DIR`.[1]

However, this means that you can no longer use the the binary cache and *everything* you install has to be compiled from scratch, including glibc. The reason is that nix usually patches paths like `/bin/myprogram` to `/nix/store/1238f...-myprogram-1.2.3/bin/myprogram` in everything that depends on `myprogram` during build time to isolate the build outputs from the system. If you change your store, all those paths will now be invalid, including the hash part.

So using a nix store that isn't `/nix/store` is possible, but I don't think anyone is actually doing it except in a few select scenarios.

You can also compile nix itself with a different root. That will work as expected, but you still have the issue that you need to compile everything you install yourself.

[1]: https://nixos.org/manual/nix/stable/command-ref/env-common.h... (you can also relocate most other directories. The `prefix` in the paths is `/nix`)

Re:macOS Sonoma is available today by bshacklett on Wednesday September 27, 2023 @08:59AM (#37673987)
Now that's interesting. I use Homebrew in a similar way. It does mean I have to compile a lot of things from scratch, but Homebrew has knowledge of which packages are relocatable and which aren't, so I get to use binary "bottles" for about 25% of the packages I install. I'll have to give this a try.
Re:macOS Sonoma is available today by watermelon0 on Tuesday September 26, 2023 @10:42PM (#37669261)
Homebrew is the same, there is no good way to have Homebrew installation shared among multiple users on a single machine, much less to have separate packages for each of them.
Re:macOS Sonoma is available today by bshacklett on Wednesday September 27, 2023 @08:59AM (#37673983)
> ...there is no good way...

Agreed, but it's at least possible. My usual install is just cloning Homebrew to ~/homebrew and setting up a symlink. It's far from ideal, due to the number of packages I need to build from source, but it works, and it's allowed me to function normally in tightly controlled environments.

As far as I can tell, the initial installation for Nix doesn't allow this, though iFreilicht pointed out some options that I haven't seen before, so I may be wrong.

Re:macOS Sonoma is available today by pxc on Wednesday September 27, 2023 @02:36AM (#37670975)
[delayed]
Re:macOS Sonoma is available today by pxc on Wednesday September 27, 2023 @11:19AM (#37675944)
I have a bad habit of writing user-mode when I mean 'unprivileged' in the sense of 'not as root' and I don't think the word really works that way. I did it again here! Whoops.
Re:macOS Sonoma is available today by n8henrie on Wednesday September 27, 2023 @09:24AM (#37674322)
Only true for MacOS though, Linux supports a proper single-user no-root install.
Re:macOS Sonoma is available today by bshacklett on Sunday October 08, 2023 @09:17AM (#37810191)
Interesting. Would you mind elaborating? I'd love to give this a try, but I'm not having luck finding documentation on how to do it.
Re:macOS Sonoma is available today by n8henrie on Sunday October 08, 2023 @11:09AM (#37811149)
Re:macOS Sonoma is available today by johnklos on Wednesday September 27, 2023 @06:21PM (#37682209)
Try pkgsrc. You can run it wherever you like, as an unprivileged user.