aboutsummaryrefslogtreecommitdiff
path: root/src/nix-env
AgeCommit message (Collapse)Author
2023-03-31Ensure all headers have `#pragma once` and are in API docsJohn Ericson
`///@file` makes them show up in the internal API dos. A tiny few were missing `#pragma once`.
2023-03-30Split nix-env and nix-store documentation per-subcommandAlexander Bantyev
Documentation on "classic" commands with many sub-commands are notoriously hard to discover due to lack of overview and anchor links. Additionally the information on common options and environment variables is not accessible offline in man pages, and therefore often overlooked by readers. With this change, each sub-command of nix-store and nix-env gets its own page in the manual (listed in the table of contents), and each own man page. Also, man pages for each subcommand now (again) list common options and environment variables. While this makes each page quite long and some common parameters don't apply, this should still make it easier to navigate as that additional information was not accessible on the command line at all. It is now possible to run 'nix-store --<subcommand> --help` to display help pages for the given subcommand. Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
2023-03-23Factor out the generation of the profile/channel directoryThéophane Hufschmitt
Make sure that all the code paths use the same one, and that the backwards-compatibility measures are probably in place when needed
2023-03-02Remove FormatOrString and remaining uses of format()Eelco Dolstra
2023-02-10A setting to follow XDG Base Directory standardAlexander Bantyev
XDG Base Directory is a standard for locations for storing various files. Nix has a few files which seem to fit in the standard, but currently use a custom location directly in the user's ~, polluting it: - ~/.nix-profile - ~/.nix-defexpr - ~/.nix-channels This commit adds a config option (use-xdg-base-directories) to follow the XDG spec and instead use the following locations: - $XDG_STATE_HOME/nix/profile - $XDG_STATE_HOME/nix/defexpr - $XDG_STATE_HOME/nix/channels If $XDG_STATE_HOME is not set, it is assumed to be ~/.local/state. Co-authored-by: Théophane Hufschmitt <7226587+thufschmitt@users.noreply.github.com> Co-authored-by: Tim Fenney <kodekata@gmail.com> Co-authored-by: pasqui23 <pasqui23@users.noreply.github.com> Co-authored-by: Artturin <Artturin@artturin.com> Co-authored-by: John Ericson <Ericson2314@Yahoo.com>
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-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-02Merge remote-tracking branch 'origin/master' into coerce-stringEelco Dolstra
2022-12-13Introduce AbstractPosEelco Dolstra
This makes the position object used in exceptions abstract, with a method getSource() to get the source code of the file in which the error originated. This is needed for lazy trees because source files don't necessarily exist in the filesystem, and we don't want to make libutil depend on the InputAccessor type in libfetcher.
2022-11-16Replace src/libutil/json.cc with nlohmann json generationYorick van Pelt
2022-09-07WIP: broken merge but need a git checkpointGuillaume Maudoux
2022-08-19nix-env: don't output incomplete JSONNaïm Favier
2022-06-09nix-env: A small std::move() optimizationSidharth Kshatriya
Avoids doing a O(n) copy of Strings i.e. std::list<std::string>
2022-05-11Stop the logger properly in legacy commandsNaïm Favier
Ensures the logger is stopped on exit in legacy commands. Without this, when using `nix-build --log-format bar` and stopping nix with CTRL+C, the bar is not cleared from the screen.
2022-04-29Merge remote-tracking branch 'origin/master' into coerce-stringGuillaume Maudoux
2022-04-21store Symbols in a table as well, like positionspennae
this slightly increases the amount of memory used for any given symbol, but this increase is more than made up for if the symbol is referenced more than once in the EvalState that holds it. on average every symbol should be referenced at least twice (once to introduce a binding, once to use it), so we expect no increase in memory on average. symbol tables are limited to 2³² entries like position tables, and similar arguments apply to why overflow is not likely: 2³² symbols would require as many string instances (at 24 bytes each) and map entries (at 24 bytes or more each, assuming that the map holds on average at most one item per bucket as the docs say). a full symbol table would require at least 192GB of memory just for symbols, which is well out of reach. (an ofborg eval of nixpks today creates less than a million symbols!)
2022-04-21replace most Pos objects/ptrs with indexes into a position tablepennae
Pos objects are somewhat wasteful as they duplicate the origin file name and input type for each object. on files that produce more than one Pos when parsed this a sizeable waste of memory (one pointer per Pos). the same goes for ptr<Pos> on 64 bit machines: parsing enough source to require 8 bytes to locate a position would need at least 8GB of input and 64GB of expression memory. it's not likely that we'll hit that any time soon, so we can use a uint32_t index to locate positions instead.
2022-03-22Don't hide repeated values while generating manifest.nixEelco Dolstra
Fixes #6243.
2022-03-18Merge remote-tracking branch 'origin/master' into coerce-stringGuillaume Maudoux
2022-03-17Merge pull request #6242 from ncfavier/print-output-namesThéophane Hufschmitt
nix-env: always print output names in JSON and XML
2022-03-16nix-env: print a final newline after JSONNaïm Favier
2022-03-16nix-env: always print output names in JSON and XMLNaïm Favier
The current `--out-path` flag has two disadvantages when one is only concerned with querying the names of outputs: - it requires evaluating every output's `outPath`, which takes significantly more resources and runs into more failures - it destroys the information of the order of outputs so we can't tell which one is the main output This patch makes the output names always present (replacing paths with `null` in JSON if `--out-path` isn't given), and adds an `outputName` field.
2022-03-13nix-env: Add a suggestion for when there's a name collision in channelsArtturin
help new users find a solution to their problem ./result/bin/nix-env -qa hello warning: name collision in input Nix expressions, skipping '/home/artturin/.nix-defexpr/channels_root/master' suggestion: remove 'master' from either the root channels or the user channels hello-2.12 hello-2.12
2022-03-04Add detailed error mesage for coerceTo{String,Path}Guillaume Maudoux
2022-03-03Use C++11-style initializerEelco Dolstra
Co-authored-by: John Ericson <git@JohnEricson.me>
2022-03-02Add EvalState::coerceToStorePath() helperEelco Dolstra
This is useful whenever we want to evaluate something to a store path (e.g. in get-drvs.cc). Extracted from the lazy-trees branch (where we can require that a store path must come from a store source tree accessor).
2022-02-25Remove std::string alias (for real this time)Eelco Dolstra
Also use std::string_view in a few more places.
2022-02-25xml-writer: Remove std aliasesEelco Dolstra
2022-02-21Remove std::vector aliasEelco Dolstra
2022-02-04Make most calls to determinePos() lazyEelco Dolstra
2022-02-04Merge branch 'issue-3505' of https://github.com/kamadorueda/nixEelco Dolstra
2022-01-24Do not suppress errors in nix-env from feedback by EelcoFarid Zakaria
2022-01-21forceValue: make pos mandatoryKevin Amado
- Make passing the position to `forceValue` mandatory, this way we remember people that the position is important for better error messages - Add pos to all `forceValue` calls
2022-01-15Make queryJSON not bail immediately on an assertion or errorFarid Zakaria
2022-01-06Check for `--meta` before emitting it for `--json`Farid Zakaria
Check that the meta flag is present when emitting JSON query information for `nix-env`. fixes #5882
2022-01-06Add outputs to JSON queryFarid Zakaria
Emit output information when printing JSON information and `--out-paths` is requested. fixes #5877
2022-01-04Remove non-method mk<X> functionsEelco Dolstra
2022-01-04Remove non-method mkString()Eelco Dolstra
2022-01-04Ensure that attrsets are sortedEelco Dolstra
Previously you had to remember to call value->attrs->sort() after populating value->attrs. Now there is a BindingsBuilder helper that wraps Bindings and ensures that sort() is called before you can use it.
2021-12-01Merge branch 'nix-env-install-suggestions' of https://github.com/tweag/nixEelco Dolstra
2021-11-25Support range-based for loop over list valuesEelco Dolstra
2021-11-19Use warn to print a warningAlex Shabalin
2021-11-18Offer suggestions for nix-env -iAlex Shabalin
Closes https://github.com/NixOS/nix/issues/972
2021-10-25toJSON: report error position for fancier outputShay Bergmann
Given flake: ```nix { description = "nix json error provenance"; inputs = {}; outputs = { self }: { jsonFunction = _: "function"; json = builtins.toJSON (_: "function"); }; } ``` - Before: ```console ❯ nix eval --json .#jsonFunction error: cannot convert a function to JSON ``` - After: ```console ❯ nix eval --json .#jsonFunction error: cannot convert a function to JSON at /nix/store/b7imf1c2j4jnkg3ys7fsfbj02s5j0i4f-source/testflake/flake.nix:4:5: 3| outputs = { self }: { 4| jsonFunction = _: "function"; | ^ 5| json = builtins.toJSON (_: "function"); ```
2021-09-14Fix quotesEelco Dolstra
2021-09-14Add "nix profile rollback" commandEelco Dolstra
2021-08-30TidyRobert Hensing
2021-08-29Force all Pos* to be non-nullRobert Hensing
This fixes a class of crashes and introduces ptr<T> to make the code robust against this failure mode going forward. Thanks regnat for the idea of a ref<T> without overhead! Closes #4895 Closes #4893 Closes #5127 Closes #5113
2021-04-05Rename BuildableJohn Ericson