Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

make self-contained #441

Merged
merged 2 commits into from
Dec 15, 2023
Merged

make self-contained #441

merged 2 commits into from
Dec 15, 2023

Conversation

kingarrrt
Copy link
Contributor

This prepends coreutils and direnv to $PATH in addition to nix in order to make this self-contained.

Fixes #440.

@Mic92
Copy link
Member

Mic92 commented Dec 14, 2023

Not quite sure this fully fixes the problem because what happens if people install nix-direnv not via nix but i.e. use source_url.

@bbenne10
Copy link
Contributor

Is it worth considering removing support for installing outside of nix workflows? Installing via nix would expand our possibilities (i.e. we could use jq and this problem would be solved via a simple anti-quotation). The Installation barrier would be higher. We could offset that by pointing at the flake so that they could override the nixpkgs' version with arbitrary commits.

Everyone consuming this should have Nix. Nix now has support for flakes everywhere (2.10 being the earliest you can get in nixpkgs). And the whole purpose is to make using flakes/shell.nix easier in a project, so I think it reasonable to say that you must have a devShell set up for this project to use nix-direnv.

On the other hand - I can see a circular dependency happening whereby nix-direnv is installed as part of a devShell and so won't be on PATH until the devShell is loaded.

@kingarrrt
Copy link
Contributor Author

I was thinking only of the case where the install is via nix.

To take this a bit further, we could check if sort is a symlink to coreutils and if not install it, but this seems a lot of effort for an edge case.

default.nix Outdated Show resolved Hide resolved
direnvrc Outdated Show resolved Hide resolved
direnvrc Outdated Show resolved Hide resolved
@kingarrrt
Copy link
Contributor Author

Just discovered https://github.com/abathur/resholve which deals with this in a much nicer way.

@Mic92 Mic92 merged commit 499255d into nix-community:master Dec 15, 2023
28 checks passed
@kingarrrt kingarrrt deleted the self-contained branch December 16, 2023 16:39
@Lyndeno
Copy link

Lyndeno commented Dec 29, 2023

Is there a way to check what version of nix-direnv I am using? I updated to the latest nixpkgs which should be at 3.0.1 with this fix but I want to make sure. I am still running into the error I described in #448 (comment).

Edit: Actually this comment: #448 (comment)

@Mic92
Copy link
Member

Mic92 commented Dec 29, 2023

echo $NIX_DIRENV_VERSION in .envrc

@Lyndeno
Copy link

Lyndeno commented Jan 1, 2024

Here is my output:

$ direnv allow
direnv: loading ~/Projects/nix-config/.envrc
3.0.1
direnv: using flake
sort: unrecognized option '--check=quiet'
BusyBox v1.36.1 () multi-call binary.

Usage: sort [-nrughMcszbdfiokt] [-o FILE] [-k START[.OFS][OPTS][,END[.OFS][OPTS]] [-t CHAR] [FILE]...

Sort lines of text

	-o FILE	Output to FILE
	-c	Check whether input is sorted
	-b	Ignore leading blanks
	-f	Ignore case
	-i	Ignore unprintable characters
	-d	Dictionary order (blank or alphanumeric only)
	-n	Sort numbers
	-g	General numerical sort
	-h	Sort human readable numbers (2K 1G)
	-M	Sort month
	-V	Sort version
	-t CHAR	Field separator
	-k N[,M] Sort by Nth field
	-r	Reverse sort order
	-s	Stable (don't sort ties alphabetically)
	-u	Suppress duplicate lines
	-z	NUL terminated input and output
direnv: nix-direnv: minimum required bash version is 5.2 (installed: 5.2.21(1)-release)
direnv: error exit status 1

using NixOS 24.05.20231227.cfc3698 using the nix-direnv option in home-manager

@Mic92
Copy link
Member

Mic92 commented Jan 2, 2024

You are using an old version of nix-direnv. The current version doesn't have this flag.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

nix-direnv fails to correctly recognize bash version
4 participants