aboutsummaryrefslogtreecommitdiff
path: root/src
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-16Merge pull request #8049 from edolstra/unexpected-eofEelco Dolstra
Fix "unexpected EOF" errors on macOS
2023-03-16LocalDerivationGoal: set NIX_ATTRS_*_FILE correctly for sandboxed buildsLinus Heckemann
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-15Merge pull request #7690 from ShamrockLee/nix-hash-sriJohn Ericson
nix-hash: support base-64 and SRI format
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-15respect allRefs=1 when using `nix flake prefetch`figsoda
2023-03-15Remove a variable in LocalDerivationGoalEelco Dolstra
2023-03-15Change builderOut from Pipe to AutoCloseFDEelco Dolstra
2023-03-15Move pseudoterminal slave open to childEelco Dolstra
Hopefully this fixes "unexpected EOF" failures on macOS (#3137, #3605, #7242, #7702). The problem appears to be that under some circumstances, macOS discards the output written to the slave side of the pseudoterminal. Hence the parent never sees the "sandbox initialized" message from the child, even though it succeeded. The conditions are: * The child finishes very quickly. That's why this bug is likely to trigger in nix-env tests, since that uses a builtin builder. Adding a short sleep before the child exits makes the problem go away. * The parent has closed its duplicate of the slave file descriptor. This shouldn't matter, since the child has a duplicate as well, but it does. E.g. moving the close to the bottom of startBuilder() makes the problem go away. However, that's not a solution because it would make Nix hang if the child dies before sending the "sandbox initialized" message. * The system is under high load. E.g. "make installcheck -j16" makes the issue pretty reproducible, while it's very rare under "make installcheck -j1". As a fix/workaround, we now open the pseudoterminal slave in the child, rather than the parent. This removes the second condition (i.e. the parent no longer needs to close the slave fd) and I haven't been able to reproduce the "unexpected EOF" with this.
2023-03-14Simplify commonChildInit()Eelco Dolstra
2023-03-13Merge pull request #8033 from lbodor/stop-adding-dot-to-nix-dev-env-pathRobert Hensing
`print-dev-env`: stop inadvertently adding `.` to `PATH`
2023-03-13Fix macOS warningEelco Dolstra
2023-03-12print-dev-env: stop inadvertently adding . to PATHlbodor
2023-03-10Merge pull request #8015 from tweag/progress-during-nix-copyThéophane Hufschmitt
Display progress when running copyPaths (nix copy)
2023-03-09Make findRuntimeRoots() more resilient to disappearing processesEelco Dolstra
I saw this random failure in https://hydra.nixos.org/build/211811692: error: opening /proc/15307/fd: No such process while running nix-collect-garbage in a readfile-context.sh. This is because we're not handling ESRCH errors reading /proc/<pid>/fd. So just move the read inside the try/catch where we do handle it.
2023-03-09Fix another uninitialized variableEelco Dolstra
https://hydra.nixos.org/build/211811494
2023-03-09Display progress when running copyPaths (nix copy)Alexander Bantyev
`nix copy` operations did not show progress. This is quite confusing. Add a `progressSink` which displays the progress during `copyPaths`, pretty much copied from `copyStorePath`. Fixes https://github.com/NixOS/nix/issues/8000
2023-03-08Revert "Disable GC during coroutine execution + test"Théophane Hufschmitt
2023-03-08Fix uninitialized readFromStdIn variableEelco Dolstra
This was causing random failures in tests/ca/substitute.ca: 'nix copy --file ./content-addressed.nix' wouldn't get the default installable '.' applied in InstallablesCommand::load(), so it would do nothing.
2023-03-08Merge pull request #7994 from edolstra/fix-ca-crashEelco Dolstra
Fix crash/hang with CA derivations
2023-03-08Merge pull request #7993 from tweag/fix-profile-gcEelco Dolstra
Fix `nix-collect-garbage -d` with the new profile location
2023-03-08Fix crash/hang with CA derivationsEelco Dolstra
The curl download can outlive DrvOutputSubstitutionGoal (if some other error occurs), so at shutdown setting the promise to an exception will fail because 'this' is no longer valid in the callback. This can manifest itself as a segfault, "corrupted double-linked list" or hang.
2023-03-08Merge pull request #7725 from yorickvP/check-coro-gcThéophane Hufschmitt
Disable GC during coroutine execution + test
2023-03-07Fix `nix-collect-garbage -d` with the new profile locationThéophane Hufschmitt
Low-hanging fix for https://github.com/NixOS/nix/pull/5226#issuecomment-1454669399
2023-03-07Merge pull request #7889 from sidkshatriya/sorted-fetch-pathsThéophane Hufschmitt
Print the store paths to be fetched sorted by StorePath name()
2023-03-06no-op refactor: extract outLink generation into a functionmupdt
2023-03-06Merge pull request #7958 from amesgen/issue-7955Eelco Dolstra
InstallableFlake: Apply nix config in `getCursors`
2023-03-06Merge pull request #7975 from fricklerhandwerk/fix-fetchgitEelco Dolstra
remove indentation in `fetchGit` attribute listing
2023-03-06output paths of store derivations are now addressed explicitlyValentin Gagarin
2023-03-05remove indentation in `fetchGit` attribute listingValentin Gagarin
also reword a confusing sentence and add links to Git terminology
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-04InstallableFlake: Apply nix config in `getCursors`amesgen
2023-03-03Print the store paths to be fetched sorted by StorePath name() and not baseNameSidharth Kshatriya
Presently when nix says something like: ``` these 486 paths will be fetched (511.54 MiB download, 6458.64 MiB unpacked): ...path1 ...path2 ...path3 ... ... ...path486 ``` It sorts path1, path2, path3, ..., path486 in lexicographic order of the store path. After this commit, nix will show path1, path2, path3, ..., path486 sorted by StorePath name() (basically everything after the hash) rather than the store path. This makes it easier to review what exactly is being downloaded at a glance, especially when many paths need to be fetched.
2023-03-03Merge pull request #7918 from zimbatm/fix-empty-nix-store-envEelco Dolstra
treat empty NIX_STORE_DIR env vars as unset
2023-03-03Add talkative msg for coro gc debugYorick van Pelt
2023-03-03fixup: use same style as getEnvzimbatm
2023-03-03fixup: remove warning entirelyzimbatm
fixes https://github.com/NixOS/nix/pull/7918/files/72e1e230517b1e774d2db97cf9d4750e31ebcaa3#r1124211067
2023-03-03Merge pull request #7942 from edolstra/remove-formatEelco Dolstra
Remove FormatOrString and remaining uses of format()
2023-03-03Merge pull request #7605 from tweag/commentsValentin Gagarin
add comments
2023-03-02Merge branch 'master' into paths-from-stdinThéophane Hufschmitt
2023-03-02Merge pull request #7940 from tweag/fix-http-errors-encodingEelco Dolstra
Log the decompressed body in case of http errors
2023-03-02Update src/libutil/util.ccJonas Chevalier
Co-authored-by: Théophane Hufschmitt <7226587+thufschmitt@users.noreply.github.com>
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-02Log the decompressed body in case of http errorsThéophane Hufschmitt
Don't show the users the raw (possibly compressed) error message as everyone isn't able to decompress brotli in their brain.