Skip to content

Conversation

edolstra
Copy link
Member

Motivation

The new CLI still lacks equivalents for nix-store --export and nix-store --import. This adds a subcommand nix nario with the following operations:

  • nix nario export: Replaces nix-store --export. It requires a --format flag to specify the desired nario version. Currently only 1 is supported. I have another PR incoming (DeterminateSystems@555b2a5) that introduces a new version that adds missing metadata (like signatures) and can be unpacked in constant memory.
  • nix nario import: Replaces nix-store --import.
  • nix nario list: Had no equivalent in the old CLI. It shows the contents of a nario file.

In the old CLI, we lacked a name for the file format used by nix-store --export/--import. @cole-h suggested nario analogously to cpio, since it's a concatenation of NARs with some metadata.

Context


Add 👍 to pull requests you find important.

The Nix maintainer team uses a GitHub project board to schedule and track reviews.

This replaces `nix-store --export` and `nix-store --import`.
@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 Sep 12, 2025
@edolstra edolstra mentioned this pull request Sep 12, 2025
86 tasks
static const uint32_t exportMagicV1 = 0x4558494e;

void exportPaths(Store & store, const StorePathSet & paths, Sink & sink)
void exportPaths(Store & store, const StorePathSet & paths, Sink & sink, unsigned int version)
Copy link
Contributor

Choose a reason for hiding this comment

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

Could version be an enum instead? That would be slightly more self-documenting.

@Malix-Labs
Copy link

Malix-Labs commented Sep 12, 2025

That is great, but what does "nario" mean?

@cole-h
Copy link
Member

cole-h commented Sep 12, 2025

Just like cpio was derived from "copy in and out" (according to Wikipedia), one could imagine nario being "NAR in and out".

* Export the closure of building `nixpkgs#hello`:

```console
# nix nario export --format 1 -r nixpkgs#hello > dump
Copy link
Member

@Mic92 Mic92 Sep 13, 2025

Choose a reason for hiding this comment

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

Maybe useful?

Suggested change
# nix nario export --format 1 -r nixpkgs#hello > dump
# nix nario export --format 1 -r nixpkgs#hello > dump
# nix nario export --format 1 -r nixpkgs#hello | zstd > dump.zst

It can be imported in another store:

```console
# nix nario import < dump
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
# nix nario import < dump
# nix nario import < dump
# zstd -d < dump | nix nario import

@Mic92 Mic92 requested a review from Copilot September 13, 2025 08:37
Copilot

This comment was marked as outdated.


ref<Store> openStore() const override
{
abort();
Copy link
Member

@Mic92 Mic92 Sep 13, 2025

Choose a reason for hiding this comment

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

Suggested change
abort();
throw Error('ListingStore cannot be opened');

void run(ref<Store> store) override
{
FdSource source(getStandardInput());
importPaths(*store, source, NoCheckSigs); // FIXME
Copy link
Member

Choose a reason for hiding this comment

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

Should be addressed or replaced by a better comment what needs to be fixed here.

Copy link
Member

@roberth roberth left a comment

Choose a reason for hiding this comment

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

That is great, but what does "nario" mean?

Just like cpio was derived from "copy in and out" (according to Wikipedia), one could imagine nario being "NAR in and out".

For cpio that works out, because it encodes all the things a cp command would copy.
In our case, that does not apply. A NAR only encodes a file system object; not a store object, so the name is misleading. It suggests that the command is only sufficient for nix nar operations, but it unlike those commands, it must interact with a store.

It's a different sce-nario. (Sorry, couldn't help it, but it wasn't enough to get rid of "it's a-me, nario")

Please consider assigning a more accurate name.

@Mic92
Copy link
Member

Mic92 commented Sep 14, 2025

  • nix closure import|export|list
  • nix nar-closure import|export|list

@edolstra
Copy link
Member Author

@Mic92 I considered "nix-closure" or something like that, but the problem is that it's not necessarily a closure (namely if you don't pass -r).

@roberth
Copy link
Member

roberth commented Sep 17, 2025

The command could be nix store export?

For the format, if it's not a closure, it's still a set, so a store path set.
Alternatively, the format could be Legacy Store Export, because we'll have a new extensible one
We should probably require the format to be specified explicitly so that a new and/or extensible/self-describing format can be made the default later; otherwise the CLI will be stuck on a bad default forever.
See

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.

6 participants