Quickly add a non-leaf path to the nix store #555

Closed
opened 2024-10-21 22:00:42 +00:00 by lolbinarycat · 9 comments

I am the developer of nix-inst. one of the primary goals of the project is performance, however, there is a major bottleneck:

the only way to create a store object that contains references to other store objects is to build a derivation.

simply using nix-store --add with a directory containing symlinks to the nix store will not work correctly with garbage collection.

Describe the solution you'd like

A nix-store flag that makes --add recurse into the directory and look for symlinks to store paths

Describe alternatives you've considered

change the default behavior of nix-store, add a new subcommand, or gate this feature behind the new cli.

Additional context

this would allow me to nearly double the performance of nix-inst on lix systems.

## Is your feature request related to a problem? Please describe. I am the developer of [nix-inst](https://codeberg.org/binarycat/nix-inst/). one of the primary goals of the project is performance, however, there is a major bottleneck: the only way to create a store object that contains references to other store objects is to build a derivation. simply using `nix-store --add` with a directory containing symlinks to the nix store will not work correctly with garbage collection. ## Describe the solution you'd like A `nix-store` flag that makes `--add` recurse into the directory and look for symlinks to store paths ## Describe alternatives you've considered change the default behavior of `nix-store`, add a new subcommand, or gate this feature behind the new cli. ## Additional context this would allow me to nearly double the performance of nix-inst on lix systems.
Owner

you are looking for nix-store --import. you will have to create the format it expects manually because we have no writers for it, and considering that the thing we think you are asking for (scanning any directory for references and adding those as dependencies) is fundamentally unsound that's about as good as it gets.

you are looking for `nix-store --import`. you will have to create the format it expects manually because we have no writers for it, and considering that the thing we think you are asking for (scanning any directory for references and adding those as dependencies) is fundamentally unsound that's about as good as it gets.
Author

the thing we think you are asking for (scanning any directory for references and adding those as dependencies) is fundamentally unsound

how so? do you just mean in terms of garbage collection, or...?

> the thing we think you are asking for (scanning any directory for references and adding those as dependencies) is fundamentally unsound how so? do you just mean in terms of garbage collection, or...?
Owner

how so? do you just mean in terms of garbage collection, or...?

without a bound on which references to scan for the scan result depends on the current state of the store, which is entirely against the stated goal of making store objects reproducible.

> how so? do you just mean in terms of garbage collection, or...? without a bound on which references to scan for the scan result depends on the current state of the store, which is entirely against the stated goal of making store objects reproducible.
Author

without a bound on which references to scan for the scan result depends on the current state of the store, which is entirely against the stated goal of making store objects reproducible.

do you think i mean just any file containing a store path? i'm specifically referring to absolute symlinks to /nix/store.

just scan all symlinks (without following symlinks!), and error if any of them point to a non-existent store path.

if an "upper bound" is needed, i can provide that, i mean, i can provide a full list of references too, even.

nix-store --import requires building an intermediate NAR archive, which is an undesirable amount of I/O.

> without a bound on which references to scan for the scan result depends on the current state of the store, which is entirely against the stated goal of making store objects reproducible. do you think i mean just any file containing a store path? i'm specifically referring to absolute symlinks to /nix/store. just scan all symlinks (without following symlinks!), and error if any of them point to a non-existent store path. if an "upper bound" is needed, i can provide that, i mean, i can provide a full list of references too, even. `nix-store --import` requires building an intermediate NAR archive, which is an undesirable amount of I/O.
Owner

just scan all symlinks (without following symlinks!), and error if any of them point to a non-existent store path.

that changes absolutely nothing about the soundness issue. no restriction on the path set makes the entire thing not reproducible, which is not something we should add as a feature.

if an "upper bound" is needed, i can provide that, i mean, i can provide a full list of references too, even.

great! format that as a dump archive and pipe it into nix-store --import. that archive doesn't need to hit the disk, and whether you do the reading and scanning or lix does is immaterial.

> just scan all symlinks (without following symlinks!), and error if any of them point to a non-existent store path. that changes absolutely nothing about the soundness issue. no restriction on the path set makes the entire thing not reproducible, which is not something we should add as a feature. > if an "upper bound" is needed, i can provide that, i mean, i can provide a full list of references too, even. great! format that as a dump archive and pipe it into `nix-store --import`. that archive doesn't need to hit the disk, and whether you do the reading and scanning or lix does is immaterial.
Author

ok, anywhere i can actually find a description of the format used by nix-store --import? i tried reading the relevant code but C++ code is really hard to grep through due to lack of a fn keyword.

ok, anywhere i can actually find a description of the format used by `nix-store --import`? i tried reading the relevant code but C++ code is really hard to grep through due to lack of a fn keyword.
Owner

unfortunately we do not have good documentation on the formats for neither NARs nor the dump archive format of nix-store --import. at this point your best bet is to read archive.cc and (i'm guessing) import-export.cc for the relevant functions.

unfortunately we do not have good documentation on the formats for neither NARs nor the dump archive format of `nix-store --import`. at this point your best bet is to read `archive.cc` and (i'm guessing) `import-export.cc` for the relevant functions.
Owner

if this information isn't arriving too late to be useful to you, we have an implementation of a writer for that format as evil_nar.py or a similarly named Python file in the lix repo, along with a NAR implementation.

if this information isn't arriving too late to be useful to you, we have an implementation of a writer for that format as evil_nar.py or a similarly named Python file in the lix repo, along with a NAR implementation.
Owner

but yes, i think this should be wontfix because we can generate the desired thing very precisely today using an implementation of the import format. reference scanning assumes that we already know the subset of store paths that might appear and thus the idea as proposed cannot be implemented.

but yes, i think this should be wontfix because we can generate the desired thing very precisely today using an implementation of the import format. reference scanning assumes that we already know the subset of store paths that *might* appear and thus the idea as proposed cannot be implemented.
jade closed this issue 2024-11-10 02:50:21 +00:00
jade added the
Status
wontfix
label 2024-11-10 02:50:36 +00:00
Sign in to join this conversation.
No milestone
No project
No assignees
3 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: lix-project/lix#555
No description provided.