nix-portable icon indicating copy to clipboard operation
nix-portable copied to clipboard

Idea: bootsrap via direnv source_url

Open Mic92 opened this issue 4 years ago • 5 comments

direnv has this cool feature to download scripts to extend direnv functionality. I use this method here in nix-direnv: https://github.com/nix-community/nix-direnv#direnv-source_url

Would you be interested in having similar functionality for nix-portable? The script could check if nix is available and if not download nix-portable (with the appropriate arch check).

Mic92 avatar Jun 02 '21 13:06 Mic92

Not sure if I understand correctly. The use case for this would be, if one has direnv installed, but not nix, and some .envrc requires nix, it would automatically fetch nix-portable?

What would need to change in nix-portable to make this happen? I guess it would need a default.nix that returns a single derivation? Since the current default.nix strongly depends on stuff defined in flakes.nix, it is probably best to add a flakes-compat.nix

DavHau avatar Jun 06 '21 14:06 DavHau

Guess I was thinking too complicated. The script could just download the pre-built binary from github. No need to build anything on the client. That wouldn't work anyways, since it doesn't have nix to begin with.

DavHau avatar Jun 06 '21 18:06 DavHau

Right. It should also check if nix is already installed and only install it otherwise.

Mic92 avatar Jun 07 '21 04:06 Mic92

Sounds like a good idea. I'd be happy about a PR.

DavHau avatar Jun 12 '21 17:06 DavHau

But... does direnv and nix-portable actually work well together? Because nix-portable does not write stuff in /nix, and AFAIK direnv expects that path when enabling nix, isn't it? Is there a workaround I don't know? See https://github.com/direnv/direnv/issues/875

yajo avatar Jan 03 '22 12:01 yajo