Skip to content

docs: document NH_FILE and NH_ATTRP env vars#686

Merged
NotAShelf merged 1 commit into
nix-community:masterfrom
tfrancisl:docs/file-attpr-etc
Jun 13, 2026
Merged

docs: document NH_FILE and NH_ATTRP env vars#686
NotAShelf merged 1 commit into
nix-community:masterfrom
tfrancisl:docs/file-attpr-etc

Conversation

@tfrancisl

@tfrancisl tfrancisl commented Jun 12, 2026

Copy link
Copy Markdown
Contributor

Sanity Checking

  • I have read and understood the contribution guidelines
  • I have updated the changelog as per my changes
  • I have tested, and self-reviewed my code
  • Style and consistency
    • I ran nix fmt to format my Nix code
    • I ran cargo fmt to format my Rust code
    • I have added appropriate documentation to new code
    • My changes are consistent with the rest of the codebase
  • Correctness
    • I ran cargo clippy and fixed any new linter warnings.
  • If new changes are particularly complex:
    • My code includes comments in particularly complex areas to explain the
      logic
    • I have documented the motive for those changes in the PR body or commit
      description.
  • Tested on platform(s):
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin

Add a 👍 reaction to pull requests you find important.



Putting this up because I recently switched from using a flake based config to a non-flake config. I had been running nh os switch --file . nixosConfigurations.<hostname> from my local clone of my nix config repo, but also saw these two vars in the codebase.

These two vars were not previously documented in the README at docs/README.md or the man-page at xtasks/src/man.rs, but they are entirely functional, similar to NH_FLAKE, implemented in crates/nh-core/src/installable.rs. So, I am simply documenting them so others feel confident using them in their nix/nixos configs.

After these changes in my config, I can run nh os switch from anywhere on nixos to switch, so these vars definitely work as expected. I'll test this on darwin as well but I suspect the results will be the same.

@coderabbitai

coderabbitai Bot commented Jun 12, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 54d27119-1f2c-4e26-a4d6-b406d7d7f3a4

📥 Commits

Reviewing files that changed from the base of the PR and between 31c0e9f and 547e60a.

📒 Files selected for processing (2)
  • docs/README.md
  • xtask/src/man.rs
✅ Files skipped from review due to trivial changes (2)
  • xtask/src/man.rs
  • docs/README.md

📝 Walkthrough

Walkthrough

This PR adds documentation for two environment variables (NH_FILE and NH_ATTRP) used by nh os switch to resolve non-flake Nix configurations; entries are added to the generated manpage ENVIRONMENT section and the README Command Examples explaining $NH_FILE#$NH_ATTRP.

Changes

Environment Variable Documentation

Layer / File(s) Summary
NH_FILE and NH_ATTRP documentation in manpage and README
xtask/src/man.rs, docs/README.md
Manpage entries for NH_FILE and NH_ATTRP are added to the ENVIRONMENT section, and the README "Command Examples" section is updated to clarify that nh os switch can use NH_FILE and NH_ATTRP together as $NH_FILE#$NH_ATTRP.

Possibly related PRs

  • nix-community/nh#566: Corrects NH_ATTRNH_ATTRP naming in help/display and parsing for file-related installables.

Suggested reviewers

  • NotAShelf
🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely summarizes the main change: documenting two environment variables (NH_FILE and NH_ATTRP).
Description check ✅ Passed The description is directly related to the changeset, explaining the motivation for documenting the two environment variables and confirming their functionality.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/README.md`:
- Around line 351-355: The README example has a typo: it uses NH_ATTPR but the
implemented env var is NH_ATTRP; update the example expression to use NH_ATTRP
so it matches the implementation in installable.rs (the NH_FILE/NH_ATTRP
handling in crates/nh-core/src/installable.rs). Ensure both mentions of the
attribute variable in the docs and the example expression are corrected to
NH_ATTRP to avoid confusion.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 219d32e6-b2f9-4aa7-95e8-6ec320c7f66b

📥 Commits

Reviewing files that changed from the base of the PR and between 6c2365d and 31c0e9f.

📒 Files selected for processing (2)
  • docs/README.md
  • xtask/src/man.rs

Comment thread docs/README.md
@tfrancisl tfrancisl force-pushed the docs/file-attpr-etc branch from 31c0e9f to 547e60a Compare June 13, 2026 14:23
@NotAShelf NotAShelf added the allow-no-changelog Doesen't need a CHANGELOG.md entry. label Jun 13, 2026
@NotAShelf NotAShelf merged commit 7c4004c into nix-community:master Jun 13, 2026
9 of 10 checks passed
@NotAShelf

Copy link
Copy Markdown
Member

Thanks :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

allow-no-changelog Doesen't need a CHANGELOG.md entry.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants