DavHau / nix-portable

Nix - Static, Permissionless, Installation-free, Pre-configured
MIT License
904 stars 33 forks source link

Option to run system-wide Nix on systems with Nix installed #42

Closed Thesola10 closed 1 year ago

Thesola10 commented 1 year ago

This would allow for nix-portable to be used in much the same way as gradlew and be shipped with projects. On systems with Nix, nix-portable would be able to detect and run the system-wide install of Nix instead of itself. This behaviour could be modified with a flag or environment variable.

Alternatively, nix-portable could obtain access to the system-wide Nix store or talk to the system-wide Nix daemon if it detects it, so that the sandbox is retained, but the risk of data duplication is reduced

DavHau commented 1 year ago

Sure sounds good. Feel invited to open a PR

Thesola10 commented 1 year ago

Never mind that, while attempting to bump the nixpkgs version I found out that static Nix binaries can now use a chroot out of the box since 2.10

I'm looking into building a Nix user experience à la gradlew with a much simpler design leveraging this new feature

Thesola10 commented 1 year ago

Nixie is the result of this line of thinking, and is very close to native macOS support too!

DavHau commented 1 year ago

Interesting to see an alternative solution emerging. I'd be happy to deprecate nix-portable in favor of a better solution.

Things that I like about the nixie approach which are missing from nix-portable:

Drawbacks that I currently see with nixie's approach:

What are your thoughts regarding these drawbacks?

I have the following ideas how we could move the whole story forward:

Some additional ideas: I think for some environments, especially like docker containers, the best option would be to just create /nix instead of using a fragile sandboxing solution like proot. Maybe that could be a valid approach for macos as well. If /nix doesn't exist, try creating it via sudo or instruct the user on how to create it.

Thesola10 commented 1 year ago

You raise some very good points, so let me address some of the drawbacks:

As for the Docker thing, I've made sure that the script works out-of-the-box in the nixos/nix image, and I assume users usually have a say on which image to use in most Docker environments. I might add a flag for rootful Nix setup, or falling back to the official Nix installer.