aboutsummaryrefslogtreecommitdiff
path: root/src/nix
AgeCommit message (Collapse)Author
2023-03-20Move enabled experimental feature to libutil structJohn Ericson
This is needed in subsequent commits to allow the settings and CLI args infrastructure itself to read this setting.
2023-03-19docs: quote URL literalsfigsoda
2023-03-17Merge pull request #7891 from mupdt/shared-fs-out-linksJohn Ericson
no-op refactor: extract outLink generation into a function
2023-03-15Merge pull request #7750 from obsidiansystems/no-args-prepareJohn Ericson
Make command infra less stateful and more regular
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-03-16nix-hash: support base-64 and SRI formatYueh-Shun Li
Add the --base64 and --sri flags for the Base64 and SRI format output. Add the --base16 flag to explicitly specify the hexadecimal format. Add the --to-base64 and --to-sri flag to convert a hash to the above mentioned format.
2023-03-12print-dev-env: stop inadvertently adding . to PATHlbodor
2023-03-06no-op refactor: extract outLink generation into a functionmupdt
2023-03-06output paths of store derivations are now addressed explicitlyValentin Gagarin
2023-03-05clarify definition of "installable"Valentin Gagarin
the term was hard to discover, as its definition and explanation were in a very long document lacking an overview section. search did not help because it occurs so often. - clarify wording in the definition - add an overview of installable types - add "installable" to glossary - link to definition from occurrences of the term - be more precise about where store derivation outputs are processed - installable Nix expressions must evaluate to a derivation Co-authored-by: Adam Joseph <54836058+amjoseph-nixpkgs@users.noreply.github.com>
2023-03-05make descriptions of each installable type an own subsectionValentin Gagarin
this is easier to edit, provides anchors for free, and renders correctly on the terminal without additional effort.
2023-03-02Remove FormatOrString and remaining uses of format()Eelco Dolstra
2023-03-02Get rid of some unchecked calls to std::coutEelco Dolstra
2023-03-02nix store cat: Use writeFull()Eelco Dolstra
Fixes #7939.
2023-03-01Merge pull request #7788 from ↵Valentin Gagarin
bobvanderlinden/pr-improve-nix-profile-install-error Improve error on conflict for nix profile install
2023-03-01nix-profile: add FIXME about using C++20 std::rangesBob van der Linden
2023-02-28nix-profile-install: show helpful error upon package conflictBob van der Linden
Whenever a file conflict happens during "nix profile install" an error is shown that was previously thrown inside builtins.buildEnv. We catch BuildProfileConflictError here so that we can provide the user with more useful instructions on what to do next. Most notably, we give the user concrete commands to use with all parameters already filled in. This avoids the need for the user to look up these commands in manual pages.
2023-02-21Merge pull request #7755 from obsidiansystems/mix-read-only-modeThéophane Hufschmitt
Make `--read-only` a separate mixin
2023-02-20Merge pull request #7863 from obsidiansystems/test-derivation-to-jsonRobert Hensing
Move Derivation JSON printing logic to lib and test it
2023-02-20Make `--read-only` a separate mixinJohn Ericson
It is independent of SourceExprCommand, which is about parsing installables, except for the fact that parsing installables is one of the many things influenced by read-only mode.
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-20Split out `InstallableFlake` and `InstallableAttrPath`John Ericson
2023-02-19Move `Derivation` toJSON logic to libnixstoreJohn Ericson
2023-02-13Merge pull request #7744 from obsidiansystems/split-installable-store-pathtomberek
Factor out `InstallableStorePath` to its own file, dedup
2023-02-10daemon.cc: Rename UserSettings -> AuthorizationSettingsRobert Hensing
This is a bit more accurate. It's a private name, but before you know it, someone might make it public!
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.
2023-02-03Factor out `InstallableStorePath` to its own file, dedupJohn Ericson
`nix app` had something called `InstallableDerivedPath` which is actually the same thing. We go with the later's name because it has become more correct. I originally did this change (more hurriedly) as part of #6225 --- a mini store-only Nix and a full Nix need to share this code. In the first RFC meeting for https://github.com/NixOS/rfcs/pull/134 we discussed how some splitting of the massive `installables.cc` could begin prior, as that is a good thing anyways. (@edolstra's words, not mine!) This would be one such PR.
2023-02-03Merge pull request #7739 from obsidiansystems/user-settingsEelco Dolstra
Move `trustedUsers` and `allowedUsers` to separate config struct
2023-02-02Move `trustedUsers` and `allowedUsers` to separate config structJohn Ericson
These settings are not needed for libstore at all, they are just used by the nix daemon *command* for authorization on unix domain sockets. My moving them to a new configuration struct just in that file, we avoid them leaking anywhere else. Also, it is good to break up the mammoth `Settings` struct in general. Issue #5638 tracks this. The message is not changed because I do not want to regress in convenience to the user. Just saying "this connection is not trusted" doesn't tell them out to fix the issue. The ideal thing to do would be to somehow parameterize `processCommand` on how the error should be displayed, so different sorts of connections can display different information to the user based on how authentication is performed for the connection in question. This, however, is a good bit more work, so it is left for the future. This came up with me thinking about the tcp:// store (#5265). The larger project is not TCP *per se*, but the idea that it should be possible for something else to manage access control to services like the Nix Daemon, and those services simply trust or trust the incoming connection as they are told. This is a more capability-oriented way of thinking about trust than "every server implements its own auth separately" as we are used to today. Its very great that libstore itself already implements just this model, and so via this refactor I basically want to "enshrine" that so it continues to be the case.
2023-02-02Get rid of the `authHook` parameter on `processConnection`John Ericson
This is (morally) dead code. As @edolstra pointed out in https://github.com/NixOS/nix/pull/5226#discussion_r1073470813, this is no longer needed. I created this in 8d4162ff9e940ea9e2f97b07f3030a722695901a, so it is fitting that I now destroy it :).
2023-02-01Merge pull request #7723 from yorickvP/nix-store-ping-jsonEelco Dolstra
nix store ping: add --json flag
2023-02-01Merge pull request #7667 from dramforever/flake-search-attrThéophane Hufschmitt
Better error message for nix search when attr is not found
2023-01-31nix flake show: Ignore empty attrsetsRobert Hensing
For frameworks it's important that structures are as lazy as possible to prevent infinite recursions, performance issues and errors that aren't related to the thing to evaluate. As a consequence, they have to emit more attributes than strictly (sic) necessary. However, these attributes with empty values are not useful to the user so we omit them.
2023-01-31nix store ping: try to print json if connect() fails aswellYorick van Pelt
2023-01-31nix store ping: add --json flagYorick van Pelt
2023-01-31Fix extra "." in CmdSearch::getDefaultFlakeAttrPathsdramforever
No other getDefaultFlakeAttrPaths implementation has this trailing dot, and the dot can show up in error messages like: error: flake '...' does not provide attribute 'packages.x86_64-linux.', ...
2023-01-30Avoid some `StorePath` <-> `Path` round tripsJohn Ericson
Avoid needless work and throwing away invariants. These conversions date back to when `StorePath` was in Rust and there were issues with it missing utility methods.
2023-01-30Merge pull request #5226 from NixOS/client-side-profilesEelco Dolstra
Move the default profiles to the user’s home
2023-01-27apply showAllSystems to legacyPackages as wellMax
2023-01-27Merge remote-tracking branch 'nixos/master' into pr-flake-show-foreignThéophane Hufschmitt
2023-01-23Merge pull request #7595 from cole-h/show-setting-valueEelco Dolstra
nix/show-config: allow getting the value of a specific setting
2023-01-19Revert "Revert "Merge pull request #6204 from layus/coerce-string""Guillaume Maudoux
This reverts commit 9b33ef3879a764bed4cc2404a08344c3a697a646.
2023-01-18Revert "Merge pull request #6204 from layus/coerce-string"Robert Hensing
This reverts commit a75b7ba30f1e4f8b15e810fd18e63ee9552e0815, reversing changes made to 9af16c5f742300e831a2cc400e43df1e22f87f31.
2023-01-17Move the default profiles to the user’s homeThéophane Hufschmitt
Rather than using `/nix/var/nix/{profiles,gcroots}/per-user/`, put the user profiles and gcroots under `$XDG_DATA_DIR/nix/{profiles,gcroots}`. This means that the daemon no longer needs to manage these paths itself (they are fully handled client-side). In particular, it doesn’t have to `chown` them anymore (removing one need for root). This does change the layout of the gc-roots created by nix-env, and is likely to break some stuff, so I’m not sure how to properly handle that.
2023-01-16flake check: Recognize well known community attributesRobert Hensing
This avoids warning fatigue, making `nix flake check` more effective.
2023-01-12nix/show-config: allow getting the value of a specific settingCole Helbling
Instead of needing to run `nix show-config --json | jq -r '."warn-dirty".value'` to view the value of `warn-dirty`, you can now run `nix show-config warn-dirty`.
2023-01-11Remove default constructor from `OutputsSpec`John Ericson
This forces us to be explicit. It also requires to rework how `from_json` works. A `JSON_IMPL` is added to assist with this.
2023-01-11Split `OutputsSpec` and `ExtendedOutputsSpec`, use the former moreJohn Ericson
`DerivedPath::Built` and `DerivationGoal` were previously using a regular set with the convention that the empty set means all outputs. But it is easy to forget about this rule when processing those sets. Using `OutputSpec` forces us to get it right.
2023-01-11Rename `OutputPath` -> `ExtendedOutputPath`John Ericson
Do this prior to making a new more limitted `OutputPath` we will use in more places.
2023-01-11Improve `OutputsSpec` slightlyJohn Ericson
A few little changes preparing for the rest.