Fix invalid store paths making it into the store #327

Open
opened 2024-05-18 14:26:17 +00:00 by puck · 8 comments
Owner

When running builtins.toFile "hi.drv" "meow" the code errors, but also leaves behind the store path that it wrote to unregistered. We should make it impossible to represent these kinds of situations, and use this to remove the entire requireValidPath logic, which (afaict) is the only use of this edge case.

When running `builtins.toFile "hi.drv" "meow"` the code errors, but also leaves behind the store path that it wrote to unregistered. We should make it impossible to represent these kinds of situations, and use this to remove the entire `requireValidPath` logic, which (afaict) is the only use of this edge case.
puck added the
bug
E/hard
Area/store
labels 2024-05-18 14:26:50 +00:00
Owner

Is this also cursed with nix-store --add?

Is this also cursed with nix-store --add?
Author
Owner

sure is!

puckipedia@marisa ~> echo meow2 > hi.drv
puckipedia@marisa ~> nix-store --add hi.drv
error: error parsing derivation '/nix/store/l0dh39vqa4q9zinvfky51080d69rlfxp-hi.drv': error: expected string 'D'
puckipedia@marisa ~ [1]> cat /nix/store/l0dh39vqa4q9zinvfky51080d69rlfxp-hi.drv
meow2
sure is! ``` puckipedia@marisa ~> echo meow2 > hi.drv puckipedia@marisa ~> nix-store --add hi.drv error: error parsing derivation '/nix/store/l0dh39vqa4q9zinvfky51080d69rlfxp-hi.drv': error: expected string 'D' puckipedia@marisa ~ [1]> cat /nix/store/l0dh39vqa4q9zinvfky51080d69rlfxp-hi.drv meow2 ```
Owner

hahahahahaha lmao

i noticed this when taking someone's .drv file for another repro and finding that it has the wrong store path compared to if it were instantiated by nix code.

i would like to be able to load .drvs into the store, but the current behaviour is just busted.

hahahahahaha lmao i noticed this when taking someone's .drv file for another repro and finding that it has the wrong store path compared to if it were instantiated by nix code. i would like to be able to load .drvs into the store, but the current behaviour is just busted.
Author
Owner

it can; it just needs the right references passed in too.

it can; it just needs the right references passed in too.
Owner

should nix-store --add on a .drv file then actually set the references properly? why aren't they set properly in the status quo?

should `nix-store --add` on a .drv file then actually set the references properly? why aren't they set properly in the status quo?
Author
Owner

it should be possible to pass in a list of desired references, maybe? nix-store --add by default doesn't set any references. but this requires a bit better API design to make it work nicely (and not break because you're trying to add non-text references to a text store path)

it should be possible to pass in a list of desired references, maybe? `nix-store --add` by default doesn't set any references. but this requires a bit better API design to make it work nicely (and not break because you're trying to add non-text references to a text store path)
Owner

it should be possible to pass in a list of desired references, maybe

are these not enumerated in the .drv file itself? That's what I mean, I guess: a .drv has one canonical path right?

> it should be possible to pass in a list of desired references, maybe are these not enumerated in the .drv file itself? That's what I mean, I guess: a .drv has one canonical path right?
Author
Owner

.drv files are stored in the store as identical to builtins.toFile paths, and i'm .. not sure it strictly checks whether the references in the store path match up the references inside the .drv? but this could be entirely wrong.

.drv files are stored in the store as identical to `builtins.toFile` paths, and i'm .. not sure it strictly checks whether the references in the store path match up the references inside the `.drv`? but this could be entirely wrong.
Sign in to join this conversation.
No milestone
No project
No assignees
2 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#327
No description provided.