-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Expose flake directory to nix fmt
as NIX_FLAKE_DIR
env var
#13143
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
base: master
Are you sure you want to change the base?
Conversation
@@ -72,6 +94,12 @@ struct CmdFormatterRun : MixFormatter, MixJSON | |||
auto evalState = getEvalState(); | |||
auto evalStore = getEvalStore(); | |||
|
|||
auto flakeRef = parseFlakeRef(fetchSettings, ".", std::filesystem::current_path().string()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The flakeref should be obtained from the installable returned by parseInstallable()
below. flakeRef.input
has a method getSourcePath()
that returns the physical path of a flake, if any.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
flakeRef.input
has a methodgetSourcePath()
that returns the physical path of a flake, if any.
This worked, thanks!
The flakeref should be obtained from the installable returned by
parseInstallable()
below
I haven't been able to get this working. The issue is that parseInstallable()
returns a Installable
, but I need it to be a FlakeInstallable
(which is a descendant class of Installable
). I suppose I know that my installable is actually a FlakeInstallable
, should I be casting/asserting this? If yes, how?
b4a86f6
to
5caf343
Compare
This type was defined in `DerivationBuilderImpl`, but it could live happily in `environment-variables.h`, so I put it there.
nix fmt
as FLAKE_DIR
env varnix fmt
as NIX_FLAKE_DIR
env var
This was discussed in NixOS#8034. I personally like `NIX_FLAKE_DIR`, which hopefully avoids some ambiguity around with subflakes. I only implemented this for `nix fmt` because it doesn't let you point at a flake not on your filesystem.
nix fmt
as NIX_FLAKE_DIR
env varnix fmt
as NIX_FLAKE_DIR
env var
/* Convert `env` to a list of strings suitable for `execve`'s `envp` argument. */ | ||
Strings toEnvp(Environment env) | ||
{ | ||
Strings envStrs; | ||
for (auto & i : env) { | ||
envStrs.push_back(i.first + "=" + i.second); | ||
} | ||
|
||
return envStrs; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@edolstra, should I also move this to src/libutil/environment-variables.cc
?
You need an `extern` dance to access `environ`, and apparently `execvpe` doesn't exist on macOS :(
This was discussed in #8034. I personally like
NIX_FLAKE_DIR
, which hopefully avoids some ambiguity around with subflakes.I only implemented this for
nix fmt
because it doesn't let you point at a flake not on your filesystem.Motivation
Context
Add 👍 to pull requests you find important.
The Nix maintainer team uses a GitHub project board to schedule and track reviews.