aboutsummaryrefslogtreecommitdiff
path: root/src/nix/copy.cc
AgeCommit message (Collapse)Author
2023-03-15Make command infra less stateful and more regularJohn Ericson
Already, we had classes like `BuiltPathsCommand` and `StorePathsCommand` which provided alternative `run` virtual functions providing the implementation with more arguments. This was a very nice and easy way to make writing command; just fill in the virtual functions and it is fairly clear what to do. However, exception to this pattern were `Installable{,s}Command`. These two classes instead just had a field where the installables would be stored, and various side-effecting `prepare` and `load` machinery too fill them in. Command would wish out those fields. This isn't so clear to use. What this commit does is make those command classes like the others, with richer `run` functions. Not only does this restore the pattern making commands easier to write, it has a number of other benefits: - `prepare` and `load` are gone entirely! One command just hands just hands off to the next. - `useDefaultInstallables` because `defaultInstallables`. This takes over `prepare` for the one case that needs it, and provides enough flexiblity to handle `nix repl`'s idiosyncratic migration. - We can use `ref` instead of `std::shared_ptr`. The former must be initialized (so it is like Rust's `Box` rather than `Option<Box>`, This expresses the invariant that the installable are in fact initialized much better. This is possible because since we just have local variables not fields, we can stop worrying about the not-yet-initialized case. - Fewer lines of code! (Finally I have a large refactor that makes the number go down not up...) - `nix repl` is now implemented in a clearer way. The last item deserves further mention. `nix repl` is not like the other installable commands because instead working from once-loaded installables, it needs to be able to load them again and again. To properly support this, we make a new superclass `RawInstallablesCommand`. This class has the argument parsing and completion logic, but does *not* hand off parsed installables but instead just the raw string arguments. This is exactly what `nix repl` needs, and allows us to instead of having the logic awkwardly split between `prepare`, `useDefaultInstallables,` and `load`, have everything right next to each other. I think this will enable future simplifications of that argument defaulting logic, but I am saving those for a future PR --- best to keep code motion and more complicated boolean expression rewriting separate steps. The "diagnostic ignored `-Woverloaded-virtual`" pragma helps because C++ doesn't like our many `run` methods. In our case, we don't mind the shadowing it all --- it is *intentional* that the derived class only provides a `run` method, and doesn't call any of the overridden `run` methods. Helps with https://github.com/NixOS/rfcs/pull/134
2022-01-18Add command 'nix store copy-log'Eelco Dolstra
Fixes #5222.
2022-01-18Factor out --from / --to logicEelco Dolstra
2021-09-27run(): MoveEelco Dolstra
2021-07-22copyPaths: Pass store by referenceEelco Dolstra
2021-05-17Enfore the use of properly built paths in libcmdregnat
Replace `DerivedPathWithHints` by a new `BuiltPath` type that serves as a proof that the corresponding path has been built.
2021-02-25Use `RealisedPath`s in `copyPaths`regnat
That way we can copy the realisations too (in addition to the store paths themselves)
2021-01-28Add a new Cmd type working on RealisedPathsregnat
Where a `RealisedPath` is a store path with its history, meaning either an opaque path for stuff that has been directly added to the store, or a `Realisation` for stuff that has been built by a derivation This is a low-level refactoring that doesn't bring anything by itself (except a few dozen extra lines of code :/ ), but raising the abstraction level a bit is important on a number of levels: - Commands like `nix build` have to query for the realisations after the build is finished which is fragile (see 27905f12e4a7207450abe37c9ed78e31603b67e1 for example). Having them oprate directly at the realisation level would avoid that - Others like `nix copy` currently operate directly on (built) store paths, but need a bit more information as they will need to register the realisations on the remote side
2021-01-13Convert option descriptions to MarkdownEelco Dolstra
2020-12-21Add 'nix copy' manpageEelco Dolstra
2020-10-06Remove static variable name clashesEelco Dolstra
This was useful for an experiment with building Nix as a single compilation unit. It's not very useful otherwise but also doesn't hurt...
2020-07-15nix: Fix examplesEelco Dolstra
2020-07-15Clean up RealiseModeEelco Dolstra
2020-06-17Merge remote-tracking branch 'origin/master' into flakesEelco Dolstra
2020-06-16Remove StorePath::clone() and related functionsEelco Dolstra
2020-05-05Merge remote-tracking branch 'origin/master' into flakesEelco Dolstra
2020-05-05nix --help: Group commandsEelco Dolstra
2020-05-04Flag: Use designated initializersEelco Dolstra
2020-04-29nix copy: Build derivationsEelco Dolstra
Fixes $ nix copy .#hydraJobs.vendoredCrates --to /tmp/nix error: path '/nix/store/...' is not valid
2020-04-29nix copy: Move --from / --to checkEelco Dolstra
This means you now get an error message *before* stuff gets built: $ nix copy .#hydraJobs.vendoredCrates error: you must pass '--from' and/or '--to' Try 'nix --help' for more information.
2019-12-10Make the Store API more type-safeEelco Dolstra
Most functions now take a StorePath argument rather than a Path (which is just an alias for std::string). The StorePath constructor ensures that the path is syntactically correct (i.e. it looks like <store-dir>/<base32-hash>-<name>). Similarly, functions like buildPaths() now take a StorePathWithOutputs, rather than abusing Path by adding a '!<outputs>' suffix. Note that the StorePath type is implemented in Rust. This involves some hackery to allow Rust values to be used directly in C++, via a helper type whose destructor calls the Rust type's drop() function. The main issue is the dynamic nature of C++ move semantics: after we have moved a Rust value, we should not call the drop function on the original value. So when we move a value, we set the original value to bitwise zero, and the destructor only calls drop() if the value is not bitwise zero. This should be sufficient for most types. Also lots of minor cleanups to the C++ API to make it more modern (e.g. using std::optional and std::string_view in some places).
2019-12-05Make subcommand construction in MultiCommand lazyEelco Dolstra
(cherry picked from commit a0de58f471c9087d8e6cc60a6078f9940a125b15)
2019-07-10nix copy: Rename --substitute to --substitute-on-destinationEelco Dolstra
'--substitute' was being shadowed by the regular '--substitute' (the short-hand for '--option substitute true'). Fixes #2983.
2018-09-27Don't talk about a "current folder build output"Eelco Dolstra
Presumably this refers to ./default.nix but the support for that in 'nix' is tenuous. Also folders are a Mac thing.
2018-08-02s3 binary cache: support specifying an endpointGraham Christensen
Works for uploading and not downloading.
2018-03-30nix copy: add an example with S3zimbatm
I couldn't find a good example how to use it with non-us-east-1 buckets.
2018-02-21nix-copy: fix examplesJörg Thalheim
maybe a left-over from nix-store -r ?
2017-10-24nix: Respect -I, --arg, --argstrEelco Dolstra
Also, random cleanup to argument handling.
2017-09-27nix copy: make recursive by defaultEelco Dolstra
2017-09-08nix copy: Add --substitute flagEelco Dolstra
2017-09-08nix copy: Add examplesEelco Dolstra
2017-09-06nix build: Add --out-link and --no-link optionsEelco Dolstra
2017-08-16nix copy: Add --no-check-sigs flagEelco Dolstra
2017-07-30Replace Unicode quotes in user-facing strings by ASCIIJörg Thalheim
Relevant RFC: NixOS/rfcs#4 $ ag -l | xargs sed -i -e "/\"/s/’/'/g;/\"/s/‘/'/g"
2017-03-16nix copy: Make -r option use the "from" storeEelco Dolstra
Previously, we tried to compute the closure in the local store, which obviously doesn't work.
2017-03-16copyPaths(): Use queryValidPaths() to reduce SSH latencyEelco Dolstra
2016-11-10build-remote: Implement in C++Shea Levy
2016-09-02Merge openStore and openStoreAt with default argumentsShea Levy
2016-05-04Add a copyStorePath() utility functionEelco Dolstra
2016-04-25Improved logging abstractionEelco Dolstra
This also gets rid of --log-type, since the nested log type isn't useful in a multi-threaded situation, and nobody cares about the "pretty" log type.
2016-04-22Factor out parallel processing of work items that have dependenciesEelco Dolstra
2016-04-22nix copy: ParalleliseEelco Dolstra
2016-04-22Add "nix copy" commandEelco Dolstra
This replaces nix-push. For example, $ nix copy --to file:///tmp/cache -r $(type -p firefox) copies the closure of firefox to the specified binary cache. And $ nix copy --from file:///tmp/cache --to s3://my-cache /nix/store/abcd... copies between two binary caches. It will also replace nix-copy-closure, once we have an SSHStore class, e.g. $ nix copy --from ssh://alice@machine /nix/store/abcd...