forked from NixOS/nix
-
Notifications
You must be signed in to change notification settings - Fork 12
Add nix nario command
#215
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
Merged
Merged
Changes from 4 commits
Commits
Show all changes
17 commits
Select commit
Hold shift + click to select a range
8859883
Args::Flag: Add required attribute
edolstra 46c4b13
Add `nix nario` command
edolstra 7c95e2c
Add a new nario format that can be imported using O(1) memory
edolstra da64b9e
Improve UsageError formatting
edolstra 9db6c98
Merge remote-tracking branch 'detsys/main' into export-import
edolstra 097b3ac
Apply suggestions from code review
edolstra a05acc8
Factor out --no-check-sigs
edolstra 5b79d59
nix nario import: Require signatures by default
edolstra c5656c3
Apply suggestions from code review
edolstra 29fa056
nix store sign: Use required attribute
edolstra 427ecd3
Test nario format 2
edolstra 590d67c
nario: Don't use full store paths in the new format
edolstra 7241615
Use serializer for std::optional<StorePath>
edolstra 84b27da
Note that nario version 1 requires --no-check-sigs
edolstra 17de7b2
Improve error message
edolstra ee303c5
Refuse to read/write narios from ttys
edolstra db4e80b
Use nario format 2 in the example
edolstra File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,30 @@ | ||
| R""( | ||
|
|
||
| # Examples | ||
|
|
||
| * Export the closure of building `nixpkgs#hello`: | ||
|
edolstra marked this conversation as resolved.
Outdated
|
||
|
|
||
| ```console | ||
| # nix nario export --format 1 -r nixpkgs#hello > dump | ||
| ``` | ||
|
|
||
| It can be imported in another store: | ||
|
edolstra marked this conversation as resolved.
Outdated
|
||
|
|
||
| ```console | ||
| # nix nario import < dump | ||
| ``` | ||
|
|
||
| # Description | ||
|
|
||
| This command prints on standard output a serialization of the specified store paths in `nario` format. This serialization can be imported into another store using `nix nario import`. | ||
|
edolstra marked this conversation as resolved.
Outdated
|
||
|
|
||
| References of a path are not exported by default; use `-r` to export a complete closure. | ||
| Paths are exported in topographically sorted order (i.e. if path `X` refers to `Y`, then `Y` appears before `X`). | ||
|
|
||
|
edolstra marked this conversation as resolved.
Outdated
|
||
| You must specify the desired `nario` version. Currently the following versions are supported: | ||
|
|
||
| * `1`: This version is compatible with the legacy `nix-store --export` and `nix-store --import` commands. It should be avoided because it is not memory-efficient on import. | ||
|
|
||
| * `2`: The latest version. Recommended. | ||
|
|
||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| )"" | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Error message may reference alias instead of primary flag name.
The
longFlagsmap contains both primary flag names and aliases pointing to the sameFlagobject (lines 24-26). When iterating incheckArgs(), if a required flag is missing, the error message will use whichever name the iterator encounters first—potentially an alias. This could confuse users who expect the primary flag name in error messages.Apply this diff to filter out aliases, matching the pattern in
toJSON()(line 527):void Args::checkArgs() { for (auto & [name, flag] : longFlags) { + if (flag->aliases.count(name)) + continue; if (flag->required && flag->timesUsed == 0) throw UsageError("required argument '%s' is missing", "--" + name); } }📝 Committable suggestion
🤖 Prompt for AI Agents