aboutsummaryrefslogtreecommitdiff
path: root/src
AgeCommit message (Collapse)Author
2022-06-15Apply suggestions from code reviewtomberek
Co-authored-by: Théophane Hufschmitt <7226587+thufschmitt@users.noreply.github.com>
2022-06-13nix-shell: restore backwards-compat with old nixpkgsMaximilian Bosch
Basically an attempt to resume fixing #5543 for a breakage introduced earlier[1]. Basically, when evaluating an older `nixpkgs` with `nix-shell` the following error occurs: λ ma27 [~] → nix-shell -I nixpkgs=channel:nixos-18.03 -p nix error: anonymous function at /nix/store/zakqwc529rb6xcj8pwixjsxscvlx9fbi-source/pkgs/top-level/default.nix:20:1 called with unexpected argument 'inNixShell' at /nix/store/zakqwc529rb6xcj8pwixjsxscvlx9fbi-source/pkgs/top-level/impure.nix:82:1: 81| 82| import ./. (builtins.removeAttrs args [ "system" "platform" ] // { | ^ 83| inherit config overlays crossSystem; This is a problem because one of the main selling points of Nix is that you can evaluate any old Nix expression and still get the same result (which also means that it *still evaluates*). In fact we're deprecating, but not removing a lot of stuff for that reason such as unquoted URLs[2] or `builtins.toPath`. However this property was essentially thrown away here. The change is rather simple: check if `inNixShell` is specified in the formals of an auto-called function. This means that { inNixShell ? false }: builtins.trace inNixShell (with import <nixpkgs> { }; makeShell { name = "foo"; }) will show `trace: true` while args@{ ... }: builtins.trace args.inNixShell (with import <nixpkgs> { }; makeShell { name = "foo"; }) will throw the following error: error: attribute 'inNixShell' missing This is explicitly needed because the function in `pkgs/top-level/impure.nix` of e.g. NixOS 18.03 has an ellipsis[3], but passes the attribute-set on to another lambda with formals that doesn't have an ellipsis anymore (hence the error from above). This was perhaps a mistake, but we can't fix it anymore. This also means that there's AFAICS no proper way to check if the attr-set that's passed to the Nix code via `EvalState::autoCallFunction` is eventually passed to a lambda with formals where `inNixShell` is missing. However, this fix comes with a certain price. Essentially every `shell.nix` that assumes `inNixShell` to be passed to the formals even without explicitly specifying it would break with this[4]. However I think that this is ugly, but preferable: * Nix 2.3 was declared stable by NixOS up until recently (well, it still is as long as 21.11 is alive), so most people might not have even noticed that feature. * We're talking about a way shorter time-span with this change being in the wild, so the fallout should be smaller IMHO. [1] https://github.com/NixOS/nix/commit/9d612c393abc3a73590650d24bcfe2ee57792872 [2] https://github.com/NixOS/rfcs/pull/45#issuecomment-488232537 [3] https://github.com/NixOS/nixpkgs/blob/release-18.03/pkgs/top-level/impure.nix#L75 [4] See e.g. the second expression in this commit-message or the changes for `tests/ca/nix-shell.sh`.
2022-06-13flake.cc: Make non-flake overrides stickyAlexander Bantyev
Overrides for inputs with flake=false were non-sticky, since they changed the `original` in `flake.lock`. This fixes it, by using the same locked original for both flake and non-flake inputs.
2022-06-13Merge pull request #6619 from Jonpez2/patch-1Eelco Dolstra
Add security.csm to ignored-acls
2022-06-13Merge pull request #6027 from Ma27/pure-replEelco Dolstra
repl: `--option pure-eval true` actually enables pure eval mode
2022-06-13Merge pull request #6634 from lovesegfault/fix-getgrouplistEelco Dolstra
fix(libstore/lock): support users that belong to more than 10 groups
2022-06-13Merge pull request #6648 from andersk/missing-rethrowEelco Dolstra
Add missing rethrows in conditional exception handlers
2022-06-13Merge pull request #6651 from ncfavier/nix-build-stop-loggerThéophane Hufschmitt
nix-build: stop logger when appropriate
2022-06-11fix sourcehut brach/tag resolving regressionGabriel Fontes
nixos/nix#6290 introduced a regex pattern to account for tags when resolving sourcehut refs. nixos/nix#4638 reafactored the code, accidentally treating the pattern as a regular string, causing all non-HEAD ref resolving to break. This fixes the regression and adds more test cases to avoid future breakage.
2022-06-11nix-build: stop logger when appropriateNaïm Favier
Reverts b944b588fa280b0555b8269c0f6d097352f8716f in `nix-build.cc`.
2022-06-10Add missing rethrows in conditional exception handlersAnders Kaseorg
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2022-06-10Mention that -f implies --impure for eval in docsYuriy Taraday
Right now this is not mentioned anywhere and it is unexpected.
2022-06-10Merge pull request #6643 from ncfavier/fix-git-againThéophane Hufschmitt
libfetchers/git: add missing `--git-dir` flags
2022-06-10libfetchers/git: add missing `--git-dir` flagsNaï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-06-09nix-store: small std::move() optimizationSidharth Kshatriya
2022-06-08fix(libstore/lock): support users that belong to more than 10 groupsBernardo Meurer
The manpage for `getgrouplist` says: > If the number of groups of which user is a member is less than or > equal to *ngroups, then the value *ngroups is returned. > > If the user is a member of more than *ngroups groups, then > getgrouplist() returns -1. In this case, the value returned in > *ngroups can be used to resize the buffer passed to a further > call getgrouplist(). In our original code, however, we allocated a list of size `10` and, if `getgrouplist` returned `-1` threw an exception. In practice, this caused the code to fail for any user belonging to more than 10 groups. While unusual for single-user systems, large companies commonly have a huge number of POSIX groups users belong to, causing this issue to crop up and make multi-user Nix unusable in such settings. The fix is relatively simple, when `getgrouplist` fails, it stores the real number of GIDs in `ngroups`, so we must resize our list and retry. Only then, if it errors once more, we can raise an exception. This should be backported to, at least, 2.9.x.
2022-06-08Fix missing ` in key manualLorenzo Manacorda
2022-06-08Add security.csm to the default ignore listJonpez2
2022-06-07Merge pull request #6618 from afishhh/search-excludeEelco Dolstra
Add `-e`/`--exclude` flag to `nix search`
2022-06-07Remove redundant `std::move`s in calls to `hiliteMatches`Fishhh
2022-06-07Add `--exclude` flag to `nix search`Fishhh
If a package's attribute path, description or name contains matches for any of the regexes specified via `-e` or `--exclude` that package is excluded from the final output.
2022-06-07Merge pull request #6602 from cw789/patch-2Eelco Dolstra
Explain exactly what nix-upgrade nix does
2022-06-06respect print-missing variable in new-style build commandMalte Brandy
Currently nix-build prints the "printMissing" information by default, nix build doesn’t. People generally don‘t notice this because the standard log-format of nix build would not display the printMissing output long enough to perceive the information. This addresses https://github.com/NixOS/nix/issues/6561
2022-06-05Fix incorrect comment in `hiliteMatches`Fishhh
2022-06-03Merge pull request #6600 from asymmetric/hash-commentEelco Dolstra
schema.sql: add comment about hash being in base16
2022-06-02Merge branch 'master' into nix-repl-flakesTom Bereknyei
2022-06-02Avoid unnecessary string copyEelco Dolstra
2022-06-02Add operator for concatenating strings and string_viewsEelco Dolstra
2022-06-02Shut up clang warningsEelco Dolstra
2022-06-02Explain exactly what nix-upgrade nix doesChris Wögi
2022-06-01Merge branch 'master' into ltoThéophane Hufschmitt
2022-06-01schema.sql: add comment about hash being in base16Lorenzo Manacorda
2022-05-31repl: `--option pure-eval true` actually enables pure eval modeMaximilian Bosch
To quote Eelco in #5867: > Unfortunately we can't do > > evalSettings.pureEval.setDefault(false); > > because then we have to do the same in main.cc (where > pureEval is set to true), and that would allow pure-eval > to be disabled globally from nix.conf. Instead, a command should specify that it should be impure by default. Then, `evalSettings.pureEval` will be set to `false;` unless it's overridden by e.g. a CLI flag. In that case it's IMHO OK to be (theoretically) able to override `pure-eval` via `nix.conf` because it doesn't have an effect on commands where `forceImpureByDefault` returns `false` (i.e. everything where pure eval actually matters). Closes #5867
2022-05-31Merge pull request #6582 from NixOS/debug-fetchgit-sigsevEelco Dolstra
Fix a segfault in the git fetcher
2022-05-30Merge pull request #6590 from edolstra/fix-noexceptEelco Dolstra
Fix noexcept violations
2022-05-30RemoteStore::queryRealisationUncached(): Fix potential noexcept violationEelco Dolstra
2022-05-30HttpBinaryCacheStore::getFile(): Don't throw an exceptionEelco Dolstra
This violates the noexcept specification. Fixes #6445.
2022-05-30Respect the outputSpecified attributeEelco Dolstra
E.g. 'nix build nixpkgs#libxml2.dev' will build the 'dev' output.
2022-05-27Fix a segfault in the git fetcherThéophane Hufschmitt
The git fetcher code used to dereference the (potentially empty) `ref` input attribute. This was magically working, probably because the compiler somehow outsmarted us, but is now blowing up with newer nixpkgs versions. Fix that by not trying to access this field while we don't know for sure that it has been defined. Fix #6554
2022-05-27Style fixEelco Dolstra
2022-05-26src/libutil/json.cc: add missing <cstdint> include for gcc-13Sergei Trofimovich
Without the change llvm build fails on this week's gcc-13 snapshot as: src/libutil/json.cc: In function 'void nix::toJSON(std::ostream&, const char*, const char*)': src/libutil/json.cc:33:22: error: 'uint16_t' was not declared in this scope 33 | put(hex[(uint16_t(*i) >> 12) & 0xf]); | ^~~~~~~~ src/libutil/json.cc:5:1: note: 'uint16_t' is defined in header '<cstdint>'; did you forget to '#include <cstdint>'? 4 | #include <cstring> +++ |+#include <cstdint> 5 |
2022-05-26Merge pull request #6576 from hercules-ci/daemon-increase-socket-backlogEelco Dolstra
Fix `Connection refused` on daemon socket
2022-05-26Remove pre-C++11 hackinessEelco Dolstra
2022-05-26createUnixDomainSocket: listen(unix, 5 -> 100)Robert Hensing
This solves the error error: cannot connect to socket at '/nix/var/nix/daemon-socket/socket': Connection refused on build farm systems that are loaded but operating normally. I've seen this happen on an M1 mac running a loaded hercules-ci-agent. Hercules CI uses multiple worker processes, which may connect to the Nix daemon around the same time. It's not unthinkable that the Nix daemon listening process isn't scheduled until after 6 workers try to connect, especially on a system under load with many workers. Is the increase safe? The number is the number of connections that the kernel will buffer while the listening process hasn't `accept`-ed them yet. It did not - and will not - restrict the total number of daemon forks that a client can create. History The number 5 has remained unchanged since the introduction in nix-worker with 0130ef88ea in 2006.
2022-05-26Merge pull request #6570 from edolstra/eof-in-stringEelco Dolstra
Handle EOFs in string literals correctly
2022-05-25remove parens from repl helpBen Burdette
2022-05-25Merge branch 'master' into debug-exploratory-PRBen Burdette
2022-05-25back to ref<EvalState> in NixReplBen Burdette
2022-05-25Handle EOFs in string literals correctlyEelco Dolstra
We can't return a STR token without setting a valid StringToken, otherwise the parser will crash. Fixes #6562.