Skip to content

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

Open
wants to merge 3 commits into
base: master
Choose a base branch
from

Conversation

jfly
Copy link
Contributor

@jfly jfly commented May 7, 2025

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.

@github-actions github-actions bot added documentation new-cli Relating to the "nix" command with-tests Issues related to testing. PRs with tests have some priority labels May 7, 2025
@jfly jfly force-pushed the issue-8034-nix-fmt branch from b5bd4cf to 1858f55 Compare May 7, 2025 02:45
@jfly jfly force-pushed the issue-8034-nix-fmt branch 3 times, most recently from 5caf343 to 262938d Compare May 7, 2025 18:25
@jfly jfly changed the title WIP/RFC: expose flake directory to nix fmt as FLAKE_DIR env var WIP/RFC: expose flake directory to nix fmt as NIX_FLAKE_DIR env var May 7, 2025
@jfly jfly force-pushed the issue-8034-nix-fmt branch from 262938d to 4996d89 Compare May 7, 2025 18:27
@jfly jfly changed the title WIP/RFC: expose flake directory to nix fmt as NIX_FLAKE_DIR env var Expose flake directory to nix fmt as NIX_FLAKE_DIR env var May 7, 2025
@jfly jfly marked this pull request as ready for review May 7, 2025 18:27
@jfly jfly requested a review from Ericson2314 as a code owner May 7, 2025 18:27
jfly added 3 commits May 14, 2025 14:50
This type was defined in `DerivationBuilderImpl`, but it could live
happily in `environment-variables.h`, so I put it there.
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.
You need an `extern` dance to access `environ`, and apparently `execvpe`
doesn't exist on macOS :(
@jfly jfly force-pushed the issue-8034-nix-fmt branch from 26c5803 to 282be12 Compare May 14, 2025 22:14
@jfly jfly requested review from xokdvium and edolstra May 14, 2025 22:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation new-cli Relating to the "nix" command with-tests Issues related to testing. PRs with tests have some priority
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants