Skip to content
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

Replace some bool recursive with a new FileIngestionMethod enum #3455

Merged
merged 11 commits into from May 28, 2020

Conversation

Ericson2314
Copy link
Member

recursive is a rather overloaded identifier in nix. There is the recursive demon enum, various one-off meanings like with traversing requisites or printing derivations, and the way we hash file paths. The daemon one already has an enum, and the one-off bool recursives are fine, but I think the "file ingestion method" ones are common enough that we ought to use a dedicated type for it. Furthermore---unlike the others which really are something juxtaposed with its negation---we just so happen to have two file ingestion methods today, and could easily have more.

src/libstore/store-api.cc Outdated Show resolved Hide resolved
src/libexpr/primops.cc Outdated Show resolved Hide resolved
@@ -73,6 +73,11 @@ const size_t storePathHashLen = 32; // i.e. 160 bits
/* Extension of derivations in the Nix store. */
const std::string drvExtension = ".drv";

enum struct FileIngestionMethod : bool {
Copy link
Member

Choose a reason for hiding this comment

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

Maybe FileIngestionMethod should PathIngestionMethod since it's more than just files. Or maybe PathCopyMode to be a bit less wordy.

Copy link
Member Author

Choose a reason for hiding this comment

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

I wanted something shorter too, but naming it's hard:

  • PathIngestionMethod but we are ingesting the file contents, not just the paths

  • PathCopyMode sometimes there are no nars involved and we aren't copying anything.

Copy link
Member Author

Choose a reason for hiding this comment

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

One thing that will help is I hope to make a FileHash struct for the pair of the ingestion method and the hash; that is a shorter name, and will make a lot of functions take 1 arg less.

Copy link
Member Author

Choose a reason for hiding this comment

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

@edolstra Do you have a name in mind? If not, we've now addressed your other points so I think this ready to go?

@Ericson2314 Ericson2314 mentioned this pull request Mar 31, 2020
src/nix/command.cc Outdated Show resolved Hide resolved
matthewbauer and others added 3 commits May 27, 2020 13:21
This is a different recursive than used in makeFixedOutputPath.
This is much less confusing since recursive is no longer a boolean.
There was an enum there that matched in perfectly.
@edolstra edolstra merged commit de141fc into NixOS:master May 28, 2020
@edolstra
Copy link
Member

Thanks, merged!

@Ericson2314
Copy link
Member Author

@edolstra thank you!!!

@Ericson2314 Ericson2314 deleted the enum-FileIngestionMethod branch May 28, 2020 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants