aboutsummaryrefslogtreecommitdiff
AgeCommit message (Collapse)Author
2023-08-18Merge pull request #8653 from hercules-ci/gitignore-.cacheRobert Hensing
.gitignore: Add .cache/
2023-08-18Merge pull request #8832 from hercules-ci/positive-source-filterJohn Ericson
Add positive source filter
2023-08-18Merge pull request #8840 from iFreilicht/tests-for-nix-replRobert Hensing
Add tests for repl formatting with and without :p
2023-08-17Test repl formatting with and without :pFelix Uhl
2023-08-16Merge pull request #8833 from hercules-ci/jobcategory-docEelco Dolstra
Document jobCategory()
2023-08-16Merge pull request #8825 from trofi/search-path-prefixEelco Dolstra
src/libexpr/search-path.cc: avoid out-of-bounds read on string_view
2023-08-16Document jobCategory()Robert Hensing
2023-08-16Add gc root for nixpkgs/lib contentRobert Hensing
2023-08-16GC root for fetched nixpkgs/lib contentRobert Hensing
2023-08-16Add positive source filterRobert Hensing
Source filtering is a really cool Nix feature that lets us avoid a lot of rebuilds, which speeds up the iteration cycle a lot in cases where the relevant source files aren't actually modified. We used to have a source filter that marked a few files as irrelevant, but this is the wrong approach, as we have many more files that are irrelevant. We may call this negative filtering. This commit switches the source filtering to positive filtering, which is a lot more robust. Instead of marking which files we don't need we marked the files that we do need. It's a superior approach because it is fail safe. Instead of allowing build performance problems to creep in over time, we require that all source inputs are declared. I shouldn't have to explain that declaring inputs is a good practice, so I'll stop over-explaining here. I do have to acknowledge that this will cause a build failure when the filter is incomplete. This is *good*, because it's the only realistic way we could be reminded of these problems. These events will be infrequent, so the small cost of extending the filter is worth it, compared to the hidden cost of longer dev cycles for things like tests, docker image, etc, etc. (Also rebuilding Nix for stupid unnecessary reasons makes my blood boil)
2023-08-14src/libexpr/search-path.cc: avoid out-of-bounds read on string_viewSergei Trofimovich
Without the change build with `-D_GLIBCXX_ASSERTIONS` exposes testsuite assertion: $ gdb src/libexpr/tests/libnixexpr-tests Reading symbols from src/libexpr/tests/libnixexpr-tests... (gdb) break __glibcxx_assert_fail (gdb) run (gdb) bt in std::__glibcxx_assert_fail(char const*, int, char const*, char const*)@plt () from /mnt/archive/big/git/nix/src/libexpr/libnixexpr.so in std::basic_string_view<char, std::char_traits<char> >::operator[] (this=0x7fffffff56c0, __pos=4) at /nix/store/r74fw2j8rx5idb0w8s1s6ynwwgs0qmh9-gcc-14.0.0/include/c++/14.0.0/string_view:258 in nix::SearchPath::Prefix::suffixIfPotentialMatch (this=0x7fffffff5780, path=...) at src/libexpr/search-path.cc:15 in nix::SearchPathElem_suffixIfPotentialMatch_partialPrefix_Test::TestBody (this=0x555555a17540) at src/libexpr/tests/search-path.cc:62 As string sizes are usigned types `(a - b) > 0` effectively means `a != b`. While the intention should be `a > b`. The change fixes test suite pass.
2023-08-14Merge pull request #8813 from obsidiansystems/outputOfRobert Hensing
Create (experimental) `outputOf` primop.
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-14Rework evaluator `SingleDerivedPath` infraJohn Ericson
`EvalState::mkSingleDerivedPathString` previously contained its own inverse (printing, rather than parsing) in order to validate what was parsed. Now that is pulled out into its own separate function: `EvalState::coerceToSingleDerivedPath`. In additional that pulled out logic is deduplicated with `EvalState::mkOutputString` via `EvalState::mkOutputStringRaw`, which is itself deduplicated (and generalized) with `DownstreamPlaceholder::mkOutputStringRaw`. All these changes make the unit tests simpler. (We would ideally write more unit tests for `mkSingleDerivedPathString` `coerceToSingleDerivedPath` directly, but we cannot yet do that because the IO in reading the store path won't work when the dummy store cannot hold anything. Someday we'll have a proper in-memory store which will work for this.) Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2023-08-14Rename `optOutputPath` to `optStaticOutputPath`John Ericson
This choice of variable name makes it more clear what is going on. Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2023-08-11Merge pull request #8735 from obsidiansystems/defexprRobert Hensing
Factor out `nix-defexpr` path computation
2023-08-11Merge pull request #8369 from obsidiansystems/inductive-derived-pathtomberek
Make the Derived Path family of types inductive for dynamic derivations
2023-08-10Merge pull request #8622 from pwaller/issue-8615Théophane Hufschmitt
Try to realise CA derivations during queryMissing
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-09Try to realise CA derivations during queryMissingPeter Waller
This enables nix to correctly report what will be fetched in the case that everything is a cache hit. Note however that if an intermediate build of something which is not cached could still cause products to end up being substituted if the intermediate build results in a CA path which is in the cache. Fixes #8615. Signed-off-by: Peter Waller <p@pwaller.net>
2023-08-08Merge pull request #8805 from tweag/fix-add-to-store-existingThéophane Hufschmitt
[V2] Fix misread of source if path is already valid
2023-08-08Test the parallel copy over ssh-ngThéophane Hufschmitt
Regression test for https://github.com/NixOS/nix/issues/6253
2023-08-07Merge pull request #8786 from Ma27/fix-why-depends-preciseEelco Dolstra
nix/why-depends: fix output of `--precise`
2023-08-07Merge pull request #8322 from tweag/stabilize-discard-referencesThéophane Hufschmitt
Stabilize `discard-references`
2023-08-07Merge pull request #8769 from edolstra/generalize-tarball-urlsEelco Dolstra
Don't require .tar/.zip extension for tarball flakerefs
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-07Merge pull request #8692 from obsidiansystems/add-another-xp-checkThéophane Hufschmitt
Feature gate `DownstreamPlaceholder::unknownCaOutput`
2023-08-07Fix misread of source if path is already validSimon Rainerson
When receiving a stream of NARs through the ssh-ng protocol, an already existing path would cause the NAR archive to not be read in the stream, resulting in trying to parse the NAR as a ValidPathInfo. This results in the error message: error: not an absolute path: 'nix-archive-1' Fixes #6253 Usually this problem is avoided by running QueryValidPaths before AddMultipleToStore, but can arise when two parallel nix processes gets the same response from QueryValidPaths. This makes the problem more prominent when running builds in parallel.
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-04nix/why-depends: fix output of `--precise`Maximilian Bosch
I haven't checked when this was exactly introduced, but on Nix 2.16 I realized that the additional lines inserted when using `--precise` are completely separated from the tree: nix why-depends /nix/store/ccgr4faaxys39s091qridxg1947lggh4-evcxr-0.14.2 /nix/store/b7hvml0m3qmqraz1022fwvyyg6fc1vdy-gcc-12.2.0 --precise --extra-experimental-features nix-command /nix/store/ccgr4faaxys39s091qridxg1947lggh4-evcxr-0.14.2 → /nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0 → /nix/store/b7hvml0m3qmqraz1022fwvyyg6fc1vdy-gcc-12.2.0 └───bin/evcxr: …':'}.PATH=${PATH/':''/nix/store/lcf37pgp3rgww67v9x2990hbfwx96c1w-gcc-wrapper-12.2.0/bin'':'/':'}… └───bin/cpp: …k disable=SC2193.[[ "/nix/store/b7hvml0m3qmqraz1022fwvyyg6fc1vdy-gcc-12.2.0/bin/cpp" = *++ ]] &&… This is apparently because `std::cout` is buffered and flushed in the end whereas the rest of the output isn't. The fix is rather simple, just use `logger->cout` as it's already the case for the rest of the code. This way we also don't need to insert additional newlines in the `hits` map since that's something the logger takes care of. Also added a small test to make sure that the layout of this is somehow tested to reduce the risk of further regressions here.
2023-08-03Merge pull request #8774 from NixLayeredStore/experimental-storesThéophane Hufschmitt
Add infra for experimental store implementations
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-08-02Merge pull request #8765 from NixLayeredStore/refactor-store-verifyJohn Ericson
More cleanups for `LocalStore::verifyPath`
2023-08-02Factor out `nix-defexpr` path computationJohn Ericson
Avoid duplicated code, and also avoid "on the fly" path construction (which makes it harder to keep track of which paths we use). The factored out code doesn't create the Nix state dir anymore, but this is fine because other in nix-env and nix-channel does: - nix-channel: Line 158 in this commit - nix-env: Line 1407 in this commit
2023-08-02Add comment explaining the use of `readDirectory(realStoreDir)`John Ericson
2023-08-02local-store verifying: Rename `store` to something more clearJohn Ericson
It is not a `Store` but a `StorePathSet`.
2023-08-02Merge pull request #8762 from obsidiansystems/split-out-eval-settingsEelco Dolstra
Move evaluator settings (type and global) to separate file/header
2023-08-02Merge pull request #8767 from NixOS/stop-removing-labelsEelco Dolstra
labeler: Stop removing labels
2023-08-01Don't require .tar/.zip extension for tarball flakerefsEelco Dolstra
Special-casing the file name is rather ugly, so we shouldn't do that. So now any {file,http,https} URL is handled by TarballInputScheme, except for non-flake inputs (i.e. inputs that have the attribute `flake = false`).
2023-07-31labeler: Stop removing labelsRobert Hensing
> Whether or not to remove labels when matching files are reverted or no longer changed by the PR https://github.com/actions/labeler#inputs
2023-07-31`LocalStore::verifyPath`: Try to clarify data flow with more scopesJohn Ericson
It was initially unclear to me which of these are temporary state for the verify paths computation, and which of these are the results of that computation to be used in the rest of the function. Now, it is clear, and enforced.
2023-07-31`LocalStore::verifyPath`: Use `StorePathSet` for `store` local varJohn Ericson
We don't care about non-store-paths in there (things like `.links`, are, in fact, allowed). So let's just skip them up front and be more strongly typed.
2023-07-31Merge pull request #8754 from NixLayeredStore/refactor-store-verifyJohn Ericson
Refactor `verifyPath` to take `StorePath` instead of `Path`
2023-07-31Refactor verifyPath to take StorePath instead of Path.Ben Radford
This way we avoid having to convert from Path to StorePath and vice versa in the body of verifyPath.
2023-07-31Move evaluator settings (type and global) to separate file/headerJohn Ericson
2023-07-31Merge pull request #8607 from hercules-ci/toJSON-traceEelco Dolstra
toJSON: Add attribute path to trace
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-25Merge pull request #8741 from ncfavier/clarify-rl-notes-nested-attrs-mergeJohn Ericson
doc: clarify release notes about nested attribute merges