Commit graph

8024 commits

Author SHA1 Message Date
Théophane Hufschmitt
16c6c6c963
Merge pull request #6676 from virusdave/dnicponski/scratch/swap_homedir_check_master
Verify this if `$HOME` exists, it is owned by current user in `getHome()`
2022-06-20 21:17:22 +02:00
Fishhh
4ade8a5f25
Fix arity of --exclude flag in nix search
Due to incorrectly using the Handler(vector<string>*) constructor the
`--exclude` flag would swallow all proceeding arguments instead of just
one.
2022-06-20 18:00:32 +02:00
Naïm Favier
d6d0e781bb
Complete flake inputs for all given flakes
Allow `nix build flake1 flake2 --update-input <Tab>` to complete the
inputs of both flakes.

Also do tilde expansion so that `nix build ~/flake --update-input <Tab>`
works.
2022-06-20 04:17:13 +02:00
Dave Nicponski
ca2be509b9 Verify $HOME is owned by current user in getHome(), if it exists.
Useful because a default `sudo` on darwin doesn't clear `$HOME`, so things like `sudo nix-channel --list`
will surprisingly return the USER'S channels, rather than `root`'s.

Other counterintuitive outcomes can be seen in this PR description:
  https://github.com/NixOS/nix/pull/6622
2022-06-17 17:42:08 -04:00
Eelco Dolstra
fd51cdcdd7
Merge remote-tracking branch 'origin/master' into lazy-trees 2022-06-17 13:39:03 +02:00
Théophane Hufschmitt
7e301fd74e
Merge pull request #6620 from maralorn/fix-print-missing
respect print-missing variable in new-style build command
2022-06-16 13:23:15 +02:00
Lorenzo Manacorda
475249db8a libstore: improve warning message on missing sig
Clarifies that the substitute will be ignored/skipped.
2022-06-15 17:34:28 +02:00
Tom Bereknyei
51268ceb79 Merge branch 'master' into nix-repl-flakes 2022-06-15 09:17:03 -04:00
tomberek
dae4a8a6c8
Apply suggestions from code review
Co-authored-by: Théophane Hufschmitt <7226587+thufschmitt@users.noreply.github.com>
2022-06-15 09:02:36 -04:00
Maximilian Bosch
98946e2d9c
nix-shell: restore backwards-compat with old nixpkgs
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] 9d612c393a
[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-13 23:29:28 +02:00
Alexander Bantyev
d82a3dc70d
flake.cc: Make non-flake overrides sticky
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-13 20:49:16 +04:00
Eelco Dolstra
9f58df4c91
Merge pull request #6619 from Jonpez2/patch-1
Add security.csm to ignored-acls
2022-06-13 16:23:13 +02:00
Eelco Dolstra
798efdf10b
Merge pull request #6027 from Ma27/pure-repl
repl: `--option pure-eval true` actually enables pure eval mode
2022-06-13 16:11:46 +02:00
Eelco Dolstra
2fef24f528
Merge pull request #6634 from lovesegfault/fix-getgrouplist
fix(libstore/lock): support users that belong to more than 10 groups
2022-06-13 15:45:09 +02:00
Eelco Dolstra
95eccfd5db
Merge pull request #6648 from andersk/missing-rethrow
Add missing rethrows in conditional exception handlers
2022-06-13 15:37:38 +02:00
Théophane Hufschmitt
03226aa053
Merge pull request #6651 from ncfavier/nix-build-stop-logger
nix-build: stop logger when appropriate
2022-06-13 10:43:14 +02:00
Gabriel Fontes
9f6b4639c2
fix sourcehut brach/tag resolving regression
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-11 16:52:20 -03:00
Naïm Favier
502d7d9092
nix-build: stop logger when appropriate
Reverts b944b588fa in `nix-build.cc`.
2022-06-11 15:17:35 +02:00
Ben Burdette
49ff4ef637 remove unused parameter 2022-06-10 12:22:36 -06:00
Anders Kaseorg
754cd53faf Add missing rethrows in conditional exception handlers
Signed-off-by: Anders Kaseorg <andersk@mit.edu>
2022-06-10 10:52:41 -07:00
Yuriy Taraday
65d09fce22 Mention that -f implies --impure for eval in docs
Right now this is not mentioned anywhere and it is unexpected.
2022-06-10 19:16:17 +04:00
Théophane Hufschmitt
45ebaab665
Merge pull request #6643 from ncfavier/fix-git-again
libfetchers/git: add missing `--git-dir` flags
2022-06-10 14:33:32 +02:00
Eelco Dolstra
5f1340219b
Add builtins.patch
This replaces the 'patches' argument to builtins.fetchTree with
something more generic. So instead of 'builtins.fetchTree { patches =
... }' you can do 'builtins.patch { src = builtins.fetchTree { ... };
patchFiles = ... }'.
2022-06-10 13:10:22 +02:00
Naïm Favier
da8f8668ca
libfetchers/git: add missing --git-dir flags 2022-06-10 12:57:13 +02:00
Eelco Dolstra
2b30df7b46
PatchingInputAccessor: Allow empty lines in patches 2022-06-10 12:44:50 +02:00
Eelco Dolstra
baee9fe7a2
Fix bad exception reported by @layus 2022-06-09 21:33:13 +02:00
Eelco Dolstra
dbe7fcebff
Merge remote-tracking branch 'origin/master' into lazy-trees 2022-06-09 21:27:16 +02:00
Sidharth Kshatriya
7868405d58 nix-env: A small std::move() optimization
Avoids doing a O(n) copy of Strings i.e. std::list<std::string>
2022-06-09 20:01:01 +05:30
Sidharth Kshatriya
3efea3d28a nix-store: small std::move() optimization 2022-06-09 16:25:26 +05:30
Bernardo Meurer
931930feb1 fix(libstore/lock): support users that belong to more than 10 groups
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-08 13:45:41 -04:00
Lorenzo Manacorda
814ddfa5f5 Fix missing ` in key manual 2022-06-08 11:46:50 +02:00
Jonpez2
a7d25d339d
Add security.csm to the default ignore list 2022-06-08 09:32:14 +01:00
Eelco Dolstra
b2dea231cf
Merge pull request #6618 from afishhh/search-exclude
Add `-e`/`--exclude` flag to `nix search`
2022-06-07 19:01:36 +02:00
Fishhh
e009367c8d
Remove redundant std::moves in calls to hiliteMatches 2022-06-07 18:25:52 +02:00
Fishhh
b42358b9be
Add --exclude flag to nix search
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-07 18:25:48 +02:00
Eelco Dolstra
739c358c68
Merge pull request #6602 from cw789/patch-2
Explain exactly what nix-upgrade nix does
2022-06-07 13:08:56 +02:00
Malte Brandy
bf2f25e3d8 respect print-missing variable in new-style build command
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-06 21:15:31 +02:00
Fishhh
d137ceccef
Fix incorrect comment in hiliteMatches 2022-06-05 20:30:18 +02:00
Eelco Dolstra
2097c30b08
Merge pull request #6600 from asymmetric/hash-comment
schema.sql: add comment about hash being in base16
2022-06-03 08:51:07 +02:00
Tom Bereknyei
ffd41d1757 Merge branch 'master' into nix-repl-flakes 2022-06-02 16:58:35 -04:00
Eelco Dolstra
28e08822a3
Avoid unnecessary string copy 2022-06-02 21:26:28 +02:00
Eelco Dolstra
abb80cfa4c
Add operator for concatenating strings and string_views 2022-06-02 21:26:21 +02:00
Eelco Dolstra
81a486c607
Shut up clang warnings 2022-06-02 21:19:54 +02:00
Ben Burdette
8cf6ae8664 use Counter class to count tryEval levels 2022-06-02 12:29:38 -06:00
Ben Burdette
bc0d41e9ba print message with exceptions in a try clause 2022-06-02 12:17:28 -06:00
Ben Burdette
9151dbff88 ignore-try flag 2022-06-02 10:26:46 -06:00
Eelco Dolstra
f70f7db42a
Fix clang error 2022-06-02 16:57:19 +02:00
Eelco Dolstra
7c0f08f79b
Shut up clang warnings 2022-06-02 16:55:28 +02:00
Eelco Dolstra
1dc58110fe
Avoid unnecessary string copy 2022-06-02 16:48:53 +02:00
Eelco Dolstra
e7c42e55e9
Fetch non-flake inputs using lazyFetch() 2022-06-02 16:26:00 +02:00
Eelco Dolstra
1c7d0b716d
Give a better error message in case of unlocked inputs 2022-06-02 16:15:57 +02:00
Chris Wögi
51b3cc151e Explain exactly what nix-upgrade nix does 2022-06-02 15:05:27 +02:00
Eelco Dolstra
1395210a68
Typo 2022-06-02 14:46:19 +02:00
Eelco Dolstra
9d772bbf96
Remove 'nix flake archive'
This is because flakes are no longer substitutable.
2022-06-02 14:41:36 +02:00
Eelco Dolstra
76c71c015b
Typo 2022-06-02 14:04:03 +02:00
Eelco Dolstra
8a0a55fe12
Fix subflake handling
Relative 'path:' flake inputs now use the containing flake's
InputAccessor. This has the following implications:

* They're no longer locked in the lock file.

* They don't cause an additional copy to the store.

* They can reference the containing directory (i.e. a subflake can
  have an input '../foo', so long as it doesn't go outside the
  top-level containing flake).

Note: this is not a complete fix for subflake handling, since the lock
file currently makes it ambiguous what the containing flake is. We'll
probably need to add another field to the lock file for that.

Fixes #6352.
2022-06-02 13:48:55 +02:00
Théophane Hufschmitt
a5f7b934bd
Merge branch 'master' into lto 2022-06-01 17:55:03 +02:00
Lorenzo Manacorda
a9358a6097 schema.sql: add comment about hash being in base16 2022-06-01 14:59:57 +02:00
Eelco Dolstra
6ab3b86cf5
Return narHash when available 2022-06-01 14:20:38 +02:00
Eelco Dolstra
b01ee2a93d
nix flake init: Fix 2022-06-01 13:54:34 +02:00
Eelco Dolstra
da553de7b1
Fix template checking 2022-06-01 13:38:17 +02:00
Eelco Dolstra
6285c91619
nix profile upgrade: Handle unlockable inputs properly 2022-06-01 13:25:13 +02:00
Eelco Dolstra
f917970df8
Set locked flag 2022-06-01 13:16:23 +02:00
Eelco Dolstra
04d5417755
More rename mutable/immutable -> unlocked/locked 2022-06-01 11:39:28 +02:00
Maximilian Bosch
159b5815b5
repl: --option pure-eval true actually enables pure eval mode
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-31 22:20:11 +02:00
Eelco Dolstra
078c80f750
Merge pull request #6582 from NixOS/debug-fetchgit-sigsev
Fix a segfault in the git fetcher
2022-05-31 17:17:37 +02:00
Eelco Dolstra
98bdc18bf6
Merge remote-tracking branch 'origin/master' into lazy-trees 2022-05-31 15:26:03 +02:00
Eelco Dolstra
af23d38019
Merge pull request #6590 from edolstra/fix-noexcept
Fix noexcept violations
2022-05-30 17:45:44 +02:00
Eelco Dolstra
6378f0bb32
RemoteStore::queryRealisationUncached(): Fix potential noexcept violation 2022-05-30 13:27:13 +02:00
Eelco Dolstra
b8faa83742
HttpBinaryCacheStore::getFile(): Don't throw an exception
This violates the noexcept specification.

Fixes #6445.
2022-05-30 13:24:04 +02:00
Eelco Dolstra
8e8e9d8705
Respect the outputSpecified attribute
E.g. 'nix build nixpkgs#libxml2.dev' will build the 'dev' output.
2022-05-30 11:34:47 +02:00
Théophane Hufschmitt
027fd45230 Fix a segfault in the git fetcher
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-27 16:15:28 +02:00
Eelco Dolstra
ec07a70979
Style fix 2022-05-27 11:25:05 +02:00
Sergei Trofimovich
b36d5172cb src/libutil/json.cc: add missing <cstdint> include for gcc-13
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-26 18:37:15 +01:00
Eelco Dolstra
dfbb9a997f
Merge remote-tracking branch 'origin/master' into lazy-trees 2022-05-26 14:11:46 +02:00
Eelco Dolstra
1e67582d75
Merge pull request #6576 from hercules-ci/daemon-increase-socket-backlog
Fix `Connection refused` on daemon socket
2022-05-26 12:43:45 +02:00
Eelco Dolstra
9acc770ce4
Remove pre-C++11 hackiness 2022-05-26 12:40:01 +02:00
Robert Hensing
c156155239 createUnixDomainSocket: listen(unix, 5 -> 100)
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-26 11:24:04 +02:00
Eelco Dolstra
762fa2b2ff
Merge pull request #6570 from edolstra/eof-in-string
Handle EOFs in string literals correctly
2022-05-26 08:13:39 +02:00
Ben Burdette
9068d32e12 remove parens from repl help 2022-05-25 12:55:58 -06:00
Ben Burdette
9a5ea6c359
Merge branch 'master' into debug-exploratory-PR 2022-05-25 10:41:10 -06:00
Ben Burdette
b4c24a29c6 back to ref<EvalState> in NixRepl 2022-05-25 10:21:20 -06:00
Eelco Dolstra
27ebb97d0a
Handle EOFs in string literals correctly
We can't return a STR token without setting a valid StringToken,
otherwise the parser will crash.

Fixes #6562.
2022-05-25 17:58:13 +02:00
Eelco Dolstra
d8398d33c9
Typo 2022-05-25 15:29:27 +02:00
Eelco Dolstra
89a8955e79
Merge remote-tracking branch 'origin/file-fetcher' 2022-05-25 15:15:16 +02:00
Eelco Dolstra
2f8a34cddc
Fix warning 2022-05-25 15:05:39 +02:00
pennae
b092afe77d
Merge branch 'master' into lto 2022-05-25 11:55:13 +00:00
Eelco Dolstra
91b7d5373a
Style tweaks 2022-05-25 12:32:22 +02:00
Maximilian Bosch
b916c08feb
libfetchers: drop getGitDir and hardcode .git
As discussed[1] this is most likely not desirable.

[1] https://github.com/NixOS/nix/pull/6440#issuecomment-1120876248
2022-05-24 14:20:48 +02:00
Ben Burdette
ba035f7dd0 comment 2022-05-23 10:13:47 -06:00
Théophane Hufschmitt
1e7c27cb91
Merge pull request #6560 from ncfavier/patch-1
typo: defaultApps → defaultApp
2022-05-23 17:08:06 +02:00
Théophane Hufschmitt
50ab1587bf
Merge pull request #6532 from flox/show_warning
fix: alignment during flake show of legacyPackages
2022-05-23 09:30:26 +02:00
Ben Burdette
13d02af079 remove redundant 'debugMode' flag 2022-05-22 21:45:24 -06:00
Ben Burdette
7ccb2700c0 comments 2022-05-22 19:15:58 -06:00
Ben Burdette
5bc97fdfa6 change state derefs 2022-05-22 19:12:03 -06:00
Ben Burdette
34ffaa9f57 changning repl to use EvalState& instead of ref 2022-05-22 18:57:45 -06:00
Naïm Camille Favier
81a9bf0ad2
typo: defaultApps → defaultApp 2022-05-21 14:41:24 +02:00
Ben Burdette
982c8a959b remove special tryEval behavior 2022-05-20 12:45:36 -06:00
Ben Burdette
884d591787 debugRepl ftn pointer 2022-05-20 10:33:50 -06:00
Eelco Dolstra
e6cf987201
GitInputScheme::lazyFetch(): Return rev/revCount/ref/lastModified 2022-05-20 15:47:33 +02:00
Eelco Dolstra
ad4b7669db
Set lockedRef correctly 2022-05-20 15:47:08 +02:00
Tom Bereknyei
7a04fb1c56 repl: add repl-flake experimental feature for gating 2022-05-20 08:20:00 -04:00
tomberek
542e36c6e7
Apply suggestions from code review
Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
2022-05-20 01:48:24 -04:00
Tom Bereknyei
db613a85fb repl: allow --file to always utilize autoargs 2022-05-20 01:35:06 -04:00
tomberek
7d7e00272a
Apply suggestions from code review
Style fixes from @edolstra

Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
2022-05-20 01:28:20 -04:00
Ben Burdette
0600df86b8 'debugMode' 2022-05-19 17:01:23 -06:00
Ben Burdette
7ddef73d02 de-const evalState exceptions 2022-05-19 12:44:40 -06:00
Ben Burdette
f9cdb6af8d Merge branch 'debug-exploratory-PR' into debuggerHook-eval-arg 2022-05-19 11:07:18 -06:00
Ben Burdette
357fb84dba use an expr->StaticEnv table in evalState 2022-05-19 10:48:10 -06:00
Tony Olagbaiye
5b8c1deb18 fetchTree: Allow fetching plain files
Add a new `file` fetcher type, which will fetch a plain file over
http(s), or from the local file.

Because plain `http(s)://` or `file://` urls can already correspond to
`tarball` inputs (if the path ends-up with a know archive extension),
the URL parsing logic is a bit convuluted in that:

- {http,https,file}:// urls will be interpreted as either a tarball or a
  file input, depending on the extensions of the path part (so
  `https://foo.com/bar` will be a `file` input and
  `https://foo.com/bar.tar.gz` as a `tarball` input)
- `file+{something}://` urls will be interpreted as `file` urls (with
  the `file+` part removed)
- `tarball+{something}://` urls will be interpreted as `tarball` urls (with
  the `tarball+` part removed)

Fix #3785

Co-Authored-By: Tony Olagbaiye <me@fron.io>
2022-05-19 18:24:49 +02:00
Eelco Dolstra
31d8f3369d
Fix fetchGit 2022-05-19 13:17:05 +02:00
Eelco Dolstra
066ed1c830
Restore previous fetchGit behaviour
For compatibility, it returns a store path again, rather than a
SourcePath.
2022-05-19 12:29:17 +02:00
Tom Bereknyei
f21dec5bef repl: hide flake behavior behind flag and provide warning 2022-05-19 01:02:24 -04:00
Tom Bereknyei
e1f308a1ec repl: provide backward compat with legacy usage 2022-05-18 22:28:15 -04:00
Tom Bereknyei
7534798eed refactor: factor out getValue 2022-05-18 21:36:50 -04:00
tomberek
9f8c1183fa Apply suggestions from code review
Co-authored-by: Théophane Hufschmitt <7226587+thufschmitt@users.noreply.github.com>
2022-05-18 21:21:58 -04:00
Tom Bereknyei
1ca3f6035d repl: update docs with installables 2022-05-18 21:21:38 -04:00
Tom Bereknyei
5640b52834 repl: use installables 2022-05-18 21:20:59 -04:00
Tom Bereknyei
81567a0962 repl: allow loading installables from CLI
repl: search installable with findAlongAttrPath
repl: refactor handling of args
repl: temp
2022-05-18 21:20:59 -04:00
Timothy DeHerrera
06d57ce759 nix repl: load flakes from cli args
If experimental feature "flakes" is enabled, args passed to `nix repl`
will now be considered flake refs and imported using the existing
`:load-flake` machinery.

In addition, `:load-flake` now supports loading flake fragments.
2022-05-18 21:20:59 -04:00
Eelco Dolstra
d7d93ebdc4
Fix CanonPath::parent()
This also fixes flake.lock loading.
2022-05-19 00:08:51 +02:00
Eelco Dolstra
c80b942c6e
Provide a default Input::fetch() that uses lazyFetch() 2022-05-18 23:24:05 +02:00
Eelco Dolstra
df713a5d25
Detect symlink cycles 2022-05-18 23:09:12 +02:00
Eelco Dolstra
593798b2a0
Show a sensible error when a file exists but is not under git control
Example:

  error: access to path '/home/eelco/Dev/patchelf/foo.nix' is forbidden because it is not under Git control; maybe you should 'git add' it to the repository '/home/eelco/Dev/patchelf'?

Fixes #4507.
2022-05-18 22:56:39 +02:00
Théophane Hufschmitt
452ffe5464
Hint at the source file on conflict in flake new
Add a pointer to the source file (from the template) when `nix flake new` (or `init`) encounters an already existing file

Fix #6542
2022-05-18 16:46:13 +02:00
Théophane Hufschmitt
78dc64ec1e
Merge pull request #6544 from ncfavier/getFlake-no-write-lock-file
Do not attempt to write a lock file in builtins.getFlake
2022-05-18 16:41:13 +02:00
Naïm Favier
169384abb2
Do not attempt to write a lock file in builtins.getFlake
Fixes https://github.com/NixOS/nix/issues/6541
2022-05-18 15:45:06 +02:00
Eelco Dolstra
1970d6db12
Fix showing an appropriate RestrictedPathError 2022-05-18 14:20:24 +02:00
zhujun
b8e44dc62b primop_match: fix example letter case in document 2022-05-18 14:05:26 +08:00
Eelco Dolstra
c1a202c348
Remove dead code 2022-05-17 21:53:54 +02:00
Eelco Dolstra
91e641af88
Fix $NIX_PATH access control initialisation 2022-05-17 21:53:54 +02:00
Eelco Dolstra
8be06c9aa1
Fix IFD 2022-05-17 14:04:55 +02:00
Eelco Dolstra
df2aa29690
Improve symlink handling 2022-05-17 13:56:26 +02:00
Eelco Dolstra
2a53574675
resolveExprPath(): Handle symlinks 2022-05-17 12:41:09 +02:00
Eelco Dolstra
fdba67d4fa
Fix access control 2022-05-17 12:18:13 +02:00
Eelco Dolstra
65e1e49cf7
nix-env: Use SourcePath 2022-05-17 00:04:04 +02:00
Eelco Dolstra
7617d15458
Fix git fetcher 2022-05-16 23:29:39 +02:00
Eelco Dolstra
a71f209330
Add CanonPath wrapper to represent canonicalized paths 2022-05-16 23:27:04 +02:00
Ben Burdette
667074b586 first whack at passing evalState as an arg to debuggerHook. 2022-05-16 09:20:51 -06:00
Théophane Hufschmitt
43a2c13672 Make nix::eval_cache::int_t more idiomatic
Don’t explicitely give it a constructor, but use aggregate
initialization instead (also prevents having an implicit coertion, which
is probably good here)
2022-05-16 16:36:21 +02:00
Eli Kogan-Wang
e53349dd6e change priority conflict message 2022-05-16 16:16:06 +02:00
Eli Kogan-Wang
27d0f6747d resolve redundant priority passing, wrap NixInt in eval-cache variant 2022-05-16 15:17:35 +02:00
Eli Kogan-Wang
c81d24f1c7 Add int to eval-cache, bump eval cache schema version 2022-05-16 02:29:29 +02:00
elikoga
0cea59ab4b
Merge branch 'NixOS:master' into master 2022-05-16 01:01:37 +02:00
Ben Burdette
86ba0a702c fix thunk issue 2022-05-15 12:05:51 -06:00
Ben Burdette
6faa56ea1f remove extra argument 2022-05-15 12:05:34 -06:00
Eli Kogan-Wang
be2b19041e Integrate review changes 2022-05-13 22:02:28 +02:00
Tom Bereknyei
8150b93968 fix: alignment during flake show of legacyPackages
Fixes:
https://github.com/NixOS/nix/issues/6240
https://github.com/NixOS/nix/issues/6045
2022-05-13 11:12:11 -04:00
Eelco Dolstra
de35e2d3b4
Fix resolving indirect flakerefs 2022-05-13 14:41:42 +02:00
Eelco Dolstra
bf89cd95a4
Merge pull request #6525 from J-Swift/feature/bash-prefix
Add `bash-prompt-prefix` option
2022-05-13 14:06:07 +02:00
Eelco Dolstra
a0ed002ba9
Fix build 2022-05-12 22:49:54 +02:00
Ben Burdette
2acdb90438 remove debug code 2022-05-12 14:20:45 -06:00
Ben Burdette
2d0d1ec99d remove debug code 2022-05-12 14:15:35 -06:00
Ben Burdette
4f48095c66 Merge branch 'debugThrow' into debug-exploratory-PR 2022-05-12 14:11:35 -06:00
Ben Burdette
1ea13084c9 template-ize debugThrow 2022-05-12 13:59:58 -06:00
Eelco Dolstra
212e28d945
Fix test 2022-05-12 20:47:27 +02:00
Eelco Dolstra
9411299875
Fix GC bug in ExprPath 2022-05-12 20:37:18 +02:00
Eelco Dolstra
9e05daaa9e
Fix flake subdir handling 2022-05-12 19:31:07 +02:00
Eelco Dolstra
1ee5dd6d96
Fix relative path handling in the parser 2022-05-12 18:38:30 +02:00
Eelco Dolstra
cd893a22f5
Make the file cache keyed on SourcePath 2022-05-12 16:48:22 +02:00
Eelco Dolstra
bc57bd2202
Temporarily disable the eval cache 2022-05-12 14:52:34 +02:00
Eelco Dolstra
84c273c503
Fix path concatenation 2022-05-12 14:48:25 +02:00
Eelco Dolstra
b6cf6e5553
ZipInputAccessor: Fix symlink handling 2022-05-12 12:06:50 +02:00
Eelco Dolstra
65c957f0c1
Merge remote-tracking branch 'origin/master' into lazy-trees 2022-05-12 11:31:09 +02:00
Norbert Melzer
831e2743ea fix GitHub URL template 2022-05-12 00:56:39 +02:00
Théophane Hufschmitt
b944b588fa
Merge pull request #6523 from ncfavier/stop-logger-legacy
Stop the logger properly in legacy commands
2022-05-11 16:53:57 +02:00
Eelco Dolstra
feac6d8651
Fix addPath() 2022-05-11 16:29:17 +02:00
Eelco Dolstra
8b5f37ea92
Fix support for coerceToPath() on attrsets with an outPath attribute 2022-05-11 15:48:21 +02:00
Eelco Dolstra
eb966921ca
Fix read-only copyPathToStore() 2022-05-11 14:22:18 +02:00
Eelco Dolstra
95e4376434
Fix eval tests 2022-05-11 13:45:57 +02:00
Eelco Dolstra
087584ef4d
Merge remote-tracking branch 'origin/master' into lazy-trees 2022-05-11 13:34:49 +02:00
Naïm Favier
1461e6cdda
Stop the logger properly in legacy commands
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-05-11 12:58:45 +02:00
Eli Kogan-Wang
aefc6c4f41 Add priority for nix profile install 2022-05-11 12:16:35 +02:00
Eelco Dolstra
54457382f9
Fix static build
https://hydra.nixos.org/build/176211267
2022-05-11 11:36:56 +02:00
Jimmy Reichley
584475acf9
Add documentation for bash-prompt-prefix 2022-05-10 16:55:25 -04:00
Jimmy Reichley
2998527b18
Allow setting bash-prompt-prefix nix develop configuration 2022-05-10 16:53:22 -04:00
Eelco Dolstra
eb957ad6d8
Merge pull request #6497 from danielfullmer/ghe-fetcher-url
Use correct URL for GitHub Enterprise
2022-05-10 19:23:22 +02:00
Eelco Dolstra
a9cbc2857f nix develop: Find bin/bash in the bashInteractive outputs 2022-05-10 16:43:41 +02:00
Eelco Dolstra
b4c6adfd35 Fix findFile(), coerceToPath() 2022-05-10 16:12:48 +02:00
Ben Burdette
7cd7c7c91a
Merge branch 'master' into debug-exploratory-PR 2022-05-09 09:30:44 -06:00
Eelco Dolstra
e7f8aa8bdd Fix copyPathToStore() 2022-05-09 15:29:42 +02:00
Eelco Dolstra
e89d3e0edf Fix resolveExprPath() 2022-05-09 14:28:47 +02:00
Eelco Dolstra
53869fbd42 Add operator for concatenating strings and string_views 2022-05-09 14:28:27 +02:00
Eelco Dolstra
0d3392bef1 Fix build 2022-05-09 12:55:25 +02:00
Eelco Dolstra
30ca717558 Merge remote-tracking branch 'origin/master' into lazy-trees 2022-05-09 11:26:39 +02:00
Jan Tojnar
59d9551c25
libexpr: Fix manual link in error message
It was changed to the old manual in 8895fa70a4
2022-05-08 18:59:00 +02:00
Daniel Fullmer
7a3d5b2ff0 Use correct URL for GitHub Enterprise
For GitHub Enterprise, the API is accessed through a slightly different
URL. See [1], where it says:

> Use http(s)://[hostname]/api/v3 to access the API for GitHub
> Enterprise Server.

Also tested working on a GHE instance.

[1] https://docs.github.com/en/enterprise-server@3.3/rest/guides/getting-started-with-the-rest-api
2022-05-06 13:13:11 -07:00
Andreas Rammhold
059ae7f6c4
Add unit tests for libexpr (#5377)
* libexpr: fix builtins.split example

The example was previously indicating that multiple whitespaces would be
collapsed into a single captured whitespace. That isn't true and was
likely a mistake when being documented initially.

* Fix segfault on unitilized list when printing value

Since lists are just chunks of memory the individual elements in the
list might be unitilized when a programming error happens within Nix.

In this case the values are null-initialized (at least with Boehm GC)
and we can avoid a nullptr deref when printing them.

I ran into this issue while ensuring that new expression tests would
show the actual value on an assertion failure.

This is unlikely to cause any runtime performance regressions as
printing values is not really in the hot path (unless the repl is the
primary use case).

* Add operator<< for ValueTypes

* Add libexpr tests

This introduces tests for libexpr that evalulate various trivial Nix
language expressions and primop invocations that should be good smoke
tests wheter or not the implementation is behaving as expected.
2022-05-06 18:05:27 +02:00
Ben Burdette
fc66f48812 debugError() 2022-05-06 09:09:49 -06:00
Ben Burdette
2c9fafdc9e trying debugThrow 2022-05-06 08:47:21 -06:00
Eelco Dolstra
b470218d9a renderMarkdownToTerminal(): Avoid line overflow
Lowdown doesn't respect '.cols' exactly (maybe because of the
whitespace in front of each line), so adjust .cols a bit.
2022-05-06 13:14:49 +02:00
Eelco Dolstra
33affa0a02
Merge pull request #6483 from NixOS/fix-sourcehut-ref-parsing
Fix the parsing of the sourcehut refs file
2022-05-06 12:24:55 +02:00
Ben Burdette
99d69ac23f fix repl bug 2022-05-05 21:23:03 -06:00
Ben Burdette
dea998b2f2 traceable_allocator 2022-05-05 20:26:10 -06:00
Ben Burdette
f400c5466d rename valmap 2022-05-05 15:43:23 -06:00
Ben Burdette
09fcfee925 don't print the 'break' argument 2022-05-05 15:34:59 -06:00
Ben Burdette
ce304d0154 rename debug commands to be more gdb-like; hide them except in debug mode 2022-05-05 15:24:57 -06:00
Ben Burdette
0ac121a094
Merge branch 'NixOS:master' into debug-exploratory-PR 2022-05-05 13:54:20 -06:00
Eelco Dolstra
58645a78ab builtins.break: Return argument when debugging is not enabled 2022-05-05 17:17:03 +02:00
Eelco Dolstra
dd8b91eebc Style fixes
In particular, use std::make_shared and enumerate(). Also renamed some
fields to fit naming conventions.
2022-05-05 17:17:03 +02:00