aboutsummaryrefslogtreecommitdiff
path: root/src/libcmd/command.cc
AgeCommit message (Collapse)Author
2023-06-19Clean up a few things related to profiles (#8526)John Ericson
- Greatly expand API docs - Clean up code in misc ways - Instead of a complicated single loop on generations, do different operations in successive subsequent steps. - Avoid `ref` in one place where `&` is fine - Just return path instead of mutating an argument in `makeName` Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
2023-04-28nix: Support the --repair flagEelco Dolstra
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
2023-02-20Split out `CmdRepl` and `editorFor`John Ericson
The REPL itself and the `nix repl` CLI are conceptually different things, and thus deserve to be in different files.
2023-02-04Scope down `--derivation` to just the commands that use itJohn Ericson
Per the old FIXME, this flag was on too many commands, and mostly ignored. Now it is just on the commands where it actually has an effect. Per https://github.com/NixOS/nix/issues/7261, I would still like to get rid of it entirely, but that is a separate project. This change should be good with or without doing that.
2022-10-24Improve --profile descriptionMichal Sojka
The description of the --profile option talks about the "update" operation. This is probably meant for operations such as "nix profile install", but the same option is reused in other subcommands, which do not update the profile, such as "nix profile {list,history,diff-closures}". We update the description to make sense in both contexts.
2022-10-12Move some options into a misc categoryEelco Dolstra
This unclutters the per-command options a bit by moving out some global options.
2022-07-11move ignore-try to EvalSettingsBen Burdette
2022-06-02ignore-try flagBen Burdette
2022-05-22remove redundant 'debugMode' flagBen Burdette
2022-05-22commentsBen Burdette
2022-05-20debugRepl ftn pointerBen Burdette
2022-05-19'debugMode'Ben Burdette
2022-05-19de-const evalState exceptionsBen Burdette
2022-05-19Merge branch 'debug-exploratory-PR' into debuggerHook-eval-argBen Burdette
2022-05-19use an expr->StaticEnv table in evalStateBen Burdette
2022-05-16first whack at passing evalState as an arg to debuggerHook.Ben Burdette
2022-05-15remove extra argumentBen Burdette
2022-05-05Style fixesEelco Dolstra
In particular, use std::make_shared and enumerate(). Also renamed some fields to fit naming conventions.
2022-04-29line endingsBen Burdette
2022-04-29incorporate PosIdx changes, symbol changes.Ben Burdette
2022-04-28Merge branch 'master' into debug-merge-masterBen Burdette
2022-04-21don't use full Pos for findPackageFilename/editorForpennae
only file and line of the returned position were ever used, it wasn't actually used a position. as such we may as well use a path+int pair for only those two values and remove a use of Pos that would not work well with a position table.
2022-04-08remove 'debugError', dead codeBen Burdette
2022-04-07Merge remote-tracking branch 'upstream/master' into upstream-mergeBen Burdette
2022-04-07free valmap on exitBen Burdette
2022-04-06show expr pos if DebugTrace one is noPosBen Burdette
2022-03-25add DebugTrace for errorBen Burdette
2022-03-22nix edit: support kakouneHideaki Kawai
2022-03-16formattingBen Burdette
2022-03-14have only one debuggerHook declarationBen Burdette
2022-03-02Move installables-related operationsEelco Dolstra
2022-02-04Merge branch 'master' into debug-stepBen Burdette
2022-02-04print value in breakBen Burdette
2022-01-18Add command 'nix store copy-log'Eelco Dolstra
Fixes #5222.
2022-01-18Factor out --from / --to logicEelco Dolstra
2022-01-08clear screen and show top debug traceBen Burdette
2022-01-08optinoal error; compilesBen Burdette
2022-01-03merge cleanupBen Burdette
2022-01-03Merge branch 'master' into debug-exploratory-PRBen Burdette
2021-12-27more cleanupBen Burdette
2021-12-27remove debug codeBen Burdette
2021-12-27add DebugTrace for the current errorBen Burdette
2021-12-23DebugTraceBen Burdette
2021-12-22DebugStackTracker class in one placeBen Burdette
2021-12-20:d errorBen Burdette
2021-12-11EvalCommand::getEvalState: use gc tracable allocator for EvalStateYorick van Pelt
2021-11-30fix merge issuesBen Burdette
2021-11-25Merge branch 'master' into debug-mergeBen Burdette
2021-11-25more cleanupBen Burdette