aboutsummaryrefslogtreecommitdiff
path: root/doc
AgeCommit message (Collapse)Author
2023-08-14Create `outputOf` primop.John Ericson
In the Nix language, given a drv path, we should be able to construct another string referencing to one of its output. We can do this today with `(import drvPath).output`, but this only works for derivations we already have. With dynamic derivations, however, that doesn't work well because the `drvPath` isn't yet built: importing it like would need to trigger IFD, when the whole point of this feature is to do "dynamic build graph" without IFD! Instead, what we want to do is create a placeholder value with the right string context to refer to the output of the as-yet unbuilt derivation. A new primop in the language, analogous to `builtins.placeholder` can be used to create one. This will achieve all the right properties. The placeholder machinery also will match out the `outPath` attribute for CA derivations works. In 60b7121d2c6d4322b7c2e8e7acfec7b701b2d3a1 we added that type of placeholder, and the derived path and string holder changes necessary to support it. Then in the previous commit we cleaned up the code (inspiration finally hit me!) to deduplicate the code and expose exactly what we need. Now, we can wire up the primop trivally! Part of RFC 92: dynamic derivations (tracking issue #6316) Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2023-08-10Make the Derived Path family of types inductive for dynamic derivationsJohn Ericson
We want to be able to write down `foo.drv^bar.drv^baz`: `foo.drv^bar.drv` is the dynamic derivation (since it is itself a derivation output, `bar.drv` from `foo.drv`). To that end, we create `Single{Derivation,BuiltPath}` types, that are very similar except instead of having multiple outputs (in a set or map), they have a single one. This is for everything to the left of the rightmost `^`. `NixStringContextElem` has an analogous change, and now can reuse `SingleDerivedPath` at the top level. In fact, if we ever get rid of `DrvDeep`, `NixStringContextElem` could be replaced with `SingleDerivedPath` entirely! Important note: some JSON formats have changed. We already can *produce* dynamic derivations, but we can't refer to them directly. Today, we can merely express building or example at the top imperatively over time by building `foo.drv^bar.drv`, and then with a second nix invocation doing `<result-from-first>^baz`, but this is not declarative. The ethos of Nix of being able to write down the full plan everything you want to do, and then execute than plan with a single command, and for that we need the new inductive form of these types. Co-authored-by: Robert Hensing <roberth@users.noreply.github.com> Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
2023-08-07Stabilize `discard-references`Théophane Hufschmitt
It has been there for a few releases now (landed in 2.14.0), doesn't seem to cause any major issue and is wanted in a few places (https://github.com/NixOS/nix/pull/7087#issuecomment-1544471346).
2023-08-06Merge pull request #8760 from iFreilicht/fix-json-load-assertion-errorsJohn Ericson
Fix derivation load assertion errors
2023-08-05Fix derivation load assertion errorsFelix Uhl
When loading a derivation from a JSON, malformed input would trigger cryptic "assertion failed" errors. Simply replacing calls to `operator []` with calls to `.at()` was not enough, as this would cause json.execptions to be printed verbatim. Display nice error messages instead and give some indication where the error happened. *Before:* ``` $ echo 4 | nix derivation add error: [json.exception.type_error.305] cannot use operator[] with a string argument with number $ nix derivation show nixpkgs#hello | nix derivation add Assertion failed: (it != m_value.object->end()), function operator[], file /nix/store/8h9pxgq1776ns6qi5arx08ifgnhmgl22-nlohmann_json-3.11.2/include/nlohmann/json.hpp, line 2135. $ nix derivation show nixpkgs#hello | jq '.[] | .name = 5' | nix derivation add error: [json.exception.type_error.302] type must be string, but is object $ nix derivation show nixpkgs#hello | jq '.[] | .outputs = { out: "/nix/store/8j3f8j-hello" }' | nix derivation add error: [json.exception.type_error.302] type must be object, but is string ``` *After:* ``` $ echo 4 | nix derivation add error: Expected JSON of derivation to be of type 'object', but it is of type 'number' $ nix derivation show nixpkgs#hello | nix derivation add error: Expected JSON object to contain key 'name' but it doesn't $ nix derivation show nixpkgs#hello | jq '.[] | .name = 5' | nix derivation add error: Expected JSON value to be of type 'string' but it is of type 'number' $ nix derivation show nixpkgs#hello | jq '.[] | .outputs = { out: "/nix/store/8j3f8j-hello" }' | nix derivation add error: … while reading key 'outputs' error: Expected JSON value to be of type 'object' but it is of type 'string' ```
2023-08-02Add infra for experimental store implemenationsJohn Ericson
This is analogous to that for experimental settings and flags that we have also added as of late.
2023-07-31toJSON: Add attribute path to traceRobert Hensing
2023-07-25Add `parseFlakeRef` and `flakeRefToString` builtins (#8670)Alex Ameen
Over the last year or so I've run into several use cases where I need to parse and/or serialize URLs for use by `builtins.fetchTree` or `builtins.getFlake`, largely in order to produce _lockfile-like_ files for lang2nix frameworks or tools which use `nix` internally to drive builds. I've gone through the painstaking process of emulating `nix::FlakeRef::fromAttrs` and `nix::parseFlakeRef` several times with mixed success; but these are difficult to create and even harder to maintain if I hope to stay aligned with changes to the real parser/serializer. I understand why adding new `builtins` isn't something we want to do flagrantly. I'm recommending this addition simply because I keep encountering use cases where I need to parse/serialize these URIs in `nix` expressions, and I want a reliable solution. Co-authored-by: Eelco Dolstra <edolstra@gmail.com> Co-authored-by: John Ericson <git@JohnEricson.me>
2023-07-25doc: clarify release notes about nested attribute mergesNaïm Favier
2023-07-24Release notesEelco Dolstra
2023-07-21parser: merge nested dynamic attributesNaïm Favier
Fixes https://github.com/NixOS/nix/issues/7115
2023-07-20fix broken links (#8722)Valentin Gagarin
2023-07-20revert anchor prefix for builtin constantsValentin Gagarin
the original change broke many pre-existing anchor links. also change formatting of the constants listing slightly: - the type should not be part of the anchor - add highlight to the "impure only" note
2023-07-19Merge pull request #8680 from NixLayeredStore/test-groupsJohn Ericson
Introduce notion of a test group, use for CA tests
2023-07-19clarify wording on args@ default handling (#8596)Valentin Gagarin
* clarify wording on args@ default handling Most importantly use shorter sentences and emphasize the key point that defaults aren't taken into account Co-authored-by: Robert Hensing <roberth@users.noreply.github.com> Co-authored-by: John Ericson <git@JohnEricson.me>
2023-07-19Merge pull request #7973 from fricklerhandwerk/remove-channelsRobert Hensing
remove the Channels section
2023-07-19fix broken linksValentin Gagarin
2023-07-19do not mention output attributesValentin Gagarin
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2023-07-19note that naming convention is from AutotoolsValentin Gagarin
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2023-07-19expand on the system type in hacking guideValentin Gagarin
2023-07-19list moving parts of channelsValentin Gagarin
2023-07-19revert channel files overviewValentin Gagarin
2023-07-19remove redundant information from channel profile descriptionValentin Gagarin
2023-07-19remove the Channels sectionValentin Gagarin
this is a how-to guide which should not be in the reference manual. it also refers to `nix-env`, which should not be the first thing readers of the reference manual encounter, as it behaves very differently in spirit from the rest of Nix. slightly reword the documentation to be more concise and informative.
2023-07-18Introduce notion of a test group, use for CA testsJohn Ericson
Grouping our tests should make it easier to understand the intent than one long poorly-arranged list. It also is convenient for running just the tests for a specific component when working on that component. We need at least one test group so this isn't dead code; I decided to collect the tests for the `ca-derivations` and `dynamic-derivations` experimental features in groups. Do ```bash make ca.test-group -jN ``` and ```bash make dyn-drv.test-group -jN ``` to try running just them. I originally did this as part of #8397 for being able to just the local overlay store alone. I am PRing it separately now so we can separate general infra from new features. Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
2023-07-16Nix Reference Manual: keep nix expressions uptodate with nixpkgs (#8703)Sinan Mohd
2023-07-11Expanded test suiteMathnerd314
* Lang now verifies errors and parse output * Some new miscellaneous tests * Easy way to update the tests * Document workflow in manual * Use `!` not `~` as separater char for sed It is confusing to use `~` when we are talking about paths and home directories! * Test test suite itself (`test/lang-test/infra.sh`) Additionally, run shellcheck on `tests/lang.sh` to help ensure it is correct, now that is is more complex. Co-authored-by: Robert Hensing <roberth@users.noreply.github.com> Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
2023-06-30fetchClosure: Docs and error message improvementsRobert Hensing
Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
2023-06-30doc: Improve `fetchClosure` documentationRobert Hensing
2023-06-30doc: TypoRobert Hensing
2023-06-30Merge pull request #8589 from jfroche/sign-paths-as-allowed-userEelco Dolstra
Allow to sign path as unprivileged user
2023-06-27Split testing into its own page in the contribution guideJohn Ericson
`hacking.md` has gotten really big!
2023-06-27Trailing commas in redirectsJohn Ericson
This avoids diff noise when more are added. Unlike with JSON, this is allowed in JS.
2023-06-27Allow to sign path as unprivileged userJean-François Roche
User can now sign path as unprivileged/allowed user refs #1708
2023-06-27Automatically document builtin constantsJohn Ericson
This is done in roughly the same way builtin functions are documented. Also auto-link experimental features for primops, subsuming PR #8371. Co-authored-by: Eelco Dolstra <edolstra@gmail.com> Co-authored-by: Robert Hensing <roberth@users.noreply.github.com> Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
2023-06-27Don't say this when we still pollute the global scopeJohn Ericson
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2023-06-27Switch example to a primop this is less ill-advisedJohn Ericson
Any primop will do for this, so might as well use one that isn't impure. Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2023-06-22Better document build failure exit codesJohn Ericson
- Improved API docs from comment - Exit codes are for `nix-build`, not just `nix-store --release` - Make note in tests so the magic numbers are not surprising Picking up where #8387 left off.
2023-06-22Merge pull request #8565 from obsidiansystems/profile-delete-docsJohn Ericson
Clarify docs on deleting generations, including fixing a mistake
2023-06-22Merge pull request #8556 from fricklerhandwerk/hacking-headingsValentin Gagarin
hacking guide: use more self-descriptive section headings
2023-06-21Clarify docs on deleting generations, including fixing a mistakeJohn Ericson
Deleting store info corrected (there is a foot-gun in Nix with `--delete-generations old`!) Also a few things are cleaned up based on feedback. Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io> Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
2023-06-21do not use "target", as it's a loaded term in the domain of compilersValentin Gagarin
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2023-06-21add redirects to changed anchorsValentin Gagarin
2023-06-21fix anchor linkValentin Gagarin
2023-06-20use more self-descriptive section headingsValentin Gagarin
2023-06-20Merge pull request #8532 from fricklerhandwerk/nix.conf-sectionsValentin Gagarin
split nix.conf man page into sections
2023-06-20clarify setting options on the command lineValentin Gagarin
2023-06-20clarify read order for configuration settingsValentin Gagarin
2023-06-20split configuration file page into sectionsfricklerhandwerk
this makes it easier to scan for specific information, such as the format of command line flags
2023-06-20add links to environment variables documentationfricklerhandwerk