Commit graph

9821 commits

Author SHA1 Message Date
Robert Hensing 40254092dd
Merge pull request #9770 from hercules-ci/refactor-rename-derivation-isPure
Refactor rename derivation type `isPure`
2024-01-27 11:24:20 +01:00
Robert Hensing 49b25ea85c refactor: Impure derivation type isPure -> isImpure
To quote the method doc:

Non-impure derivations can still behave impurely, to the degree permitted
by the sandbox. Hence why this method isn't `isPure`: impure derivations
are not the negation of pure derivations. Purity can not be ascertained
except by rather heavy tools.
2024-01-27 11:00:10 +01:00
John Ericson b83a2fb6dd
Merge pull request #9776 from pennae/parser-refactor
Refactor the parser somewhat
2024-01-26 23:56:48 -05:00
John Ericson 365b831e6f
Minor formatting tweaks 2024-01-26 23:11:31 -05:00
John Ericson 1aec7771d4 Add missing #include for rlim_t
My local build in the shell was failing while CI was fine; not sure why
that is but having the include here is definitely more correct.

Per the POSIX spec, this is where it is supposed to be gotten
https://pubs.opengroup.org/onlinepubs/009695399/basedefs/sys/resource.h.html
2024-01-26 22:34:31 -05:00
Rebecca Turner 3a124d1e88
Increase stack size on macOS as well as Linux
The code works fine on macOS, but the default stack size we attempt to
set is larger than what my system will allow (Nix attempts to set the
stack size to 67108864, but the maximum allowed is 67092480), so I've
instead used the requested stack size or the maximum allowed, whichever
is smaller.

I've also added an error message if setting the stack size fails. It
looks like this:

> Failed to increase stack size from 8372224 to 67108864 (maximum
> allowed stack size: 67092480): Invalid argument
2024-01-26 09:40:41 -08:00
Valentin Gagarin 30bdee5c3b
update docs on fetchGit shallow clone behavior (#9704) 2024-01-26 17:26:08 +00:00
Théophane Hufschmitt 8df68a213f
Merge pull request #9849 from 13x1/patch-1
Fix typo in primops.cc (and therefore Nix docs)
2024-01-25 16:11:49 +01:00
lexi 08f38a3a40
Fix typo in primops.cc (and therefore Nix docs)
This also fixes the typo in the Nix docs at https://nixos.org/manual/nix/unstable/language/builtins.
2024-01-25 15:30:51 +01:00
John Ericson a9e10a1dbd Make StoreConfig::getDefaultSystemFeatures a static method
This makes something in Hydra bit simpler. If someday the default
depends on the other config options, we can always change it back.
2024-01-24 21:34:31 -05:00
Robert Hensing 5b7bfd2d6b
Merge pull request #9754 from 9999years/print-value-when-coercion-fails
Print the value in `error: cannot coerce` messages
2024-01-24 12:48:39 +01:00
Théophane Hufschmitt 69d0ae27e3
Merge pull request #9841 from obsidiansystems/float-speed-factor
Convert `Machine::speedFactor` from a non-neg int to a non-neg float
2024-01-24 11:28:54 +01:00
John Ericson 1e24db6f9a Convert Machine::speedFactor from a non-neg int to a non-neg float
The short motivation is to match Hydra, so we can de-dup.

The long version is layed out in
https://github.com/NixOS/nix/issues/9840.
2024-01-24 01:03:07 -05:00
tomberek 1c260fa6d1
Merge pull request #9481 from iFreilicht/disallow-nix-search-without-search-terms
nix search: Disallow empty regex
2024-01-23 20:59:52 -05:00
tomberek 775d59f1fa
Merge pull request #8893 from 9999years/fix-8882
Log what `nix flake check` does
2024-01-23 20:38:23 -05:00
Rebecca Turner 83bb494a30
Print the value in error: cannot coerce messages
This extends the `error: cannot coerce a TYPE to a string` message
to print the value that could not be coerced. This helps with debugging
by making it easier to track down where the value is being produced
from, especially in errors with deep or unhelpful stack traces.
2024-01-23 15:15:41 -08:00
John Ericson 0aa85088de Factor out Machine::systemSupported
There's just enough logic (the `"builtin"` special case) that makes this
worthy of its own method.
2024-01-23 12:53:51 -05:00
John Ericson 870acc2892 Add API docs to Machine methods 2024-01-23 12:50:48 -05:00
John Ericson 739032762a Make Machine::systemTypes a set not vector
This is more conceptually correct (the order does not matter), and also
matches what Hydra already does.

(Nix and Hydra matching is needed for dedup
https://github.com/NixOS/hydra/issues/1164)
2024-01-23 12:30:26 -05:00
Eelco Dolstra b6aee9a93f
Merge pull request #9833 from obsidiansystems/ssh-arg-split
Make `SSHMaster::startCommand` work on an args list
2024-01-23 14:34:41 +01:00
Robert Hensing 08bf2846df
Merge pull request #9653 from obsidiansystems/improve-parse-sink
Improve the `ParseSink` interface
2024-01-23 01:04:57 +01:00
John Ericson 6365bbfa81 Improve the FileSystemObjectSink interface
More invariants are enforced in the type, and less state needs to be
stored in the main sink itself. The method here is roughly that known as
"session types".

Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2024-01-22 18:01:21 -05:00
John Ericson 966d6fcd01 ParseSink -> FileSystemObjectSink
Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2024-01-22 18:01:18 -05:00
John Ericson b71673109c Make SSHMaster::startCommand work on an args list
This avoids split-on-whitespace errors:

- No more `bash -c` needed

- No more `shellEscape` needed

- `remote-program` ssh store setting also cleanly supports args (e.g.
  `nix daemon`)

- `ssh` uses `--` to separate args for SSH from args for the command to
  run.

and will help with Hydra dedup.

Some code taken from #6628.

Co-Authored-By: Alexander Bantyev <balsoft@balsoft.ru>
2024-01-22 17:46:57 -05:00
Maximilian Bosch 81499a0b93
libexpr: print value of what is attempted to be called as function
Low-hanging fruit in the spirit of #9753 and #9754 (means 9999years did
all the hard work already).

This basically prints out what was attempted to be called as function,
i.e.

  map (import <nixpkgs> {}) [ 1 2 3 ]

now gives the following error message:

    error:
           … while calling the 'map' builtin
             at «string»:1:1:
                1| map (import <nixpkgs> {}) [ 1 2 3 ]
                 | ^

           … while evaluating the first argument passed to builtins.map

           error: expected a function but found a set: { _type = "pkgs"; AAAAAASomeThingsFailToEvaluate = «thunk»; AMB-plugins = «thunk»; ArchiSteamFarm = «thunk»; BeatSaberModManager = «thunk»; CHOWTapeModel = «thunk»; ChowCentaur = «thunk»; ChowKick = «thunk»; ChowPhaser = «thunk»; CoinMP = «thunk»;  «18783 attributes elided»}
2024-01-22 22:41:42 +01:00
Robert Hensing 5f72a97092
Merge pull request #9753 from 9999years/print-value-on-type-error
Print the value in `value is X while a Y is expected` error
2024-01-22 22:18:16 +01:00
John Ericson e960b28230 Factor our ServeProto::BasicServerConnection::handshake
We'll need this for unit testing.

Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2024-01-22 12:43:11 -05:00
John Ericson 4a5ca576da Factor out ServeProto::BasicClientConnection::handshake Hydra to share 2024-01-22 12:43:11 -05:00
John Ericson 4580bed3e4 LegacySSHStore::openConnection move more logic inside catch block
Broader error handling logic is more robust.
2024-01-22 12:43:11 -05:00
John Ericson ce2f714e6d Start factoring out the serve protocol for Hydra to share
Factor out `ServeProto::BasicClientConnection` for Hydra to share

- `queryValidPaths`: Hydra uses the lock argument differently than Nix,
  so we un-hard-code it.

- `buildDerivationRequest`: Just the request half, as Hydra does some
  things between requesting and responding.

Co-authored-by: Robert Hensing <roberth@users.noreply.github.com>
2024-01-22 12:43:03 -05:00
Rebecca Turner cb7fbd4d83
Print value on type error
Adds the failing value to `value is <TYPE> while a <TYPE> is expected`
error messages.
2024-01-22 08:56:02 -08:00
John Ericson 316e50cc7c Fix if...if...else ambiguity
This can be parsed two ways. Add a pair of braces so it must be parsed
the intended way.
2024-01-22 10:33:40 -05:00
John Ericson 176dcd5c61
Merge pull request #9626 from jvns/locked-input
Make fetchTree locked input error message clearer
2024-01-22 09:31:59 -05:00
pennae 80b84710b8
Update src/libexpr/eval.cc
Co-authored-by: John Ericson <git@JohnEricson.me>
2024-01-22 15:15:53 +01:00
John Ericson b2066c3574
Merge pull request #9521 from fricklerhandwerk/conf-reword-max-jobs
reword description of the `max-jobs` setting
2024-01-22 08:29:12 -05:00
Théophane Hufschmitt c8d33bca8d
Merge pull request #9822 from obsidiansystems/algo-vs-hash-algo
Start standardizing hash algo flags
2024-01-22 11:08:24 +01:00
Théophane Hufschmitt f51409cf98
Merge pull request #9805 from yshui/prefetch-unpack
Add --unpack to nix store prefetch-file
2024-01-22 10:51:50 +01:00
John Ericson 202c5e2afc Start standardizing hash algo flags
Do this if we want to do `--hash-algo` everywhere, and not `--algo` for
hash commands.

The new `nix hash convert` is updated. Deprecated new CLI commands are
left as-is (`nix hash path` needs to be redone and is also left as-is).
2024-01-20 17:29:35 -05:00
John Ericson a93b204c27
Merge pull request #9348 from obsidiansystems/json-formats
Document JSON formats
2024-01-20 17:22:39 -05:00
John Ericson edf3ecc497 Document JSON formats
Good to document these formats separately from commands that happen to
use them.

Eventually I would like this and `builtins.derivation` to refer to a
store section on derivations that is authoritative, but that doesn't yet
exist, and will take some time to make. So I think we're just best off
merging this now as is.

Co-authored-by: Valentin Gagarin <valentin.gagarin@tweag.io>
2024-01-20 17:03:47 -05:00
Rebecca Turner d75a5f427a
Print how many checks are run 2024-01-20 00:04:06 -08:00
Rebecca Turner 9404ce36e4
Print derivation paths
Also be more consistent with quotes around attribute paths
2024-01-20 00:04:05 -08:00
Rebecca Turner 49221493e2
Log what nix flake check does
There's still room for improvement, but this produces much more
informative output with `-v`:

```
$ nix flake check -v
evaluating flake...
checking flake output 'checks'...
checking derivation checks.aarch64-darwin.ghcid-ng-tests...
checking derivation checks.aarch64-darwin.ghcid-ng-clippy...
checking derivation checks.aarch64-darwin.ghcid-ng-doc...
checking derivation checks.aarch64-darwin.ghcid-ng-fmt...
checking derivation checks.aarch64-darwin.ghcid-ng-audit...
checking flake output 'packages'...
checking derivation packages.aarch64-darwin.ghcid-ng...
checking derivation packages.aarch64-darwin.ghcid-ng-tests...
checking derivation packages.aarch64-darwin.default...
checking flake output 'apps'...
checking flake output 'devShells'...
checking derivation devShells.aarch64-darwin.default...
running flake checks...
warning: The check omitted these incompatible systems: aarch64-linux, x86_64-darwin, x86_64-linux
Use '--all-systems' to check all.
```
2024-01-20 00:02:35 -08:00
John Ericson 356352c370 Add missing --hash-algo flag to nix store add 2024-01-19 23:11:18 -05:00
Robert Hensing 382fa51ff0
Merge pull request #9794 from hercules-ci/queryPathInfoFromClientCache
refactor: Extract `Store::queryPathInfoFromClientCache`
2024-01-19 17:33:52 +01:00
Robert Hensing d19627e8b4 refactor: Remove throw from queryPathInfoFromClientCache
Return a value instead of throwing.

Rather than the more trivial refactor of wrapping the return value in
another std::optional, we retain the meaning of the outer optional:
"we know at least something."

So we have changed:
return nullopt    -> return nullopt
throw InvalidPath -> return make_optional(nullptr)
return vpi        -> return make_optional(vpi)
2024-01-19 17:01:19 +01:00
Robert Hensing 8983ee8b2e refactor: Un-callback transform Store::queryPathInfoFromClientCache
This part of the code was not necessarily callback based.
Removing CPS is always nice; particularly if there's no loss of
functionality, like here.
2024-01-19 17:01:19 +01:00
Yuxuan Shui 75a6e6dd0e Add --unpack to nix store prefetch-file 2024-01-19 15:53:45 +00:00
Théophane Hufschmitt 10165c7593
Merge pull request #9811 from DavHau/fix-git-auth
fetchTree/fetchGit: re-enable shallow fetching
2024-01-19 16:14:41 +01:00
John Ericson 57d6284eb7
Merge pull request #9812 from NixOS/remove-n-shorthand-for---mode
Remove a nonsensical shorthand flag in `nix store add`
2024-01-19 08:34:43 -05:00