Commit graph

15681 commits

Author SHA1 Message Date
Tom Hubrecht 127ee1abe7 primops: Run iwyu and update includes
Change-Id: Ic3f48d6fca6ca1ae444475f7ccdee6220da946de
2024-05-30 11:19:13 +02:00
Tom Hubrecht 5541723b60 primops: Explicit registering of primops
Change-Id: I05e72d2bfdc715d9e27cc672ac35619310b0864d
2024-05-30 10:54:54 +02:00
Tom Hubrecht 09139554a8 primops.cc: cleanup
Change-Id: Iae0580e8f44988b8452aef77e67ca2495c342bf6
2024-05-30 10:29:15 +02:00
Tom Hubrecht 8035abdc37 primops: Move addErrorContext to primops/context.cc
Also refactor the file to sort the builtins and add the implementation
of EvalState::realiseContext

Change-Id: I518425316c56fc628d62d14d3718f20b87b6dd39
2024-05-30 10:27:09 +02:00
Tom Hubrecht c96f5bcdd2 primops: Move toXML to primops/toXML.cc
Change-Id: I8da29345903015e38b9832f0d9b4011dc5bbb17b
2024-05-30 10:14:52 +02:00
Tom Hubrecht a93af3f92f primops: Move functions to primops/json.cc
Moved builtins: fromJSON, toJSON

Change-Id: I3ae74a42bd036203b24b39fbd6b346f56d3812f3
2024-05-30 10:13:46 +02:00
Tom Hubrecht c3ffa21778 primops: Move functions to primops/system.cc
Moved builtins: exec, getEnv

Change-Id: Ie1b64e4ea8c71f5f64a80ab890a467f5194b884c
2024-05-30 10:13:46 +02:00
Tom Hubrecht 2279c39bea primops: Move functions to primops/debug.cc
Moved builtins: deepSeq, seq, trace, unsafeGetAttrPos

Change-Id: I95cfaf2487fde61256f506e0d7254c5a0b32b1a3
2024-05-30 10:13:46 +02:00
Tom Hubrecht 0bf532b0c1 primops: Move genericClosure to attrset.cc
Change-Id: I0f8ae3dfcc1a4e4ce6e631e13e5b63ac03c1cd74
2024-05-30 10:08:38 +02:00
Tom Hubrecht 1e1cc1d741 primops: Move derivationStrict to primops/derivation.cc
Change-Id: I778c85b8429ccc3af01e45ea608543d67414864f
2024-05-30 10:08:38 +02:00
Tom Hubrecht 4e448e78f7 primops: Move functions to primops/path.cc
Moved builtins: dirOf, filterSource, findFile, outputOf, path,
pathExists, placeholder, toPath, readDir, readFile, readFileType,
storePath, toFile

realisePath has also been moved

Change-Id: Ie30efc61ca530ececedf3d3002a9553d2e8a9c60
2024-05-30 10:08:38 +02:00
Tom Hubrecht 468d30e053 primops: Move functions to primops/import.cc
Moved builtins: import, importNative, scopedImport

Change-Id: I7c525a03f877ad4a6586e055b37f8e4db51ad721
2024-05-30 09:58:00 +02:00
Tom Hubrecht d3b1d1fb37 primops: Move functions to primops/types.cc
Moved builtins: functionArgs, isAttrs, isBool, isFloat, isFunction,
isInt, isList isNull, isPath, isString, typeOf

A generic prim_isType(type) is defined to factorise the same code

Change-Id: Ic9941a60802cb4c067482261ba35022075f1ea88
2024-05-30 09:58:00 +02:00
Tom Hubrecht 00416ee50b primops: Move functions to primops/arithmetic.cc
Moved builtins: add, bitAnd, bitOr, bitXor, ceil, div, floor, mul, sub

Change-Id: Ia144579ee219fab751281157a5a3d73a4aa9ee40
2024-05-30 09:58:00 +02:00
Tom Hubrecht 7f1ebde7b8 primops: Move functions to primops/list.cc
Moved builtins: all, any, concatLists, concatMap, elem, elemAt, filter,
foldl', head, length, listToAttrs, map, partition, sort, tail

The CompareValues struct has been moved to primops.hh

Change-Id: Ifc5457298215fd20c96aa8acac65749ed42c28dd
2024-05-30 08:48:49 +02:00
Tom Hubrecht 95968c44eb primops: Move functions to primops/hash.cc
Moved builtins: hashFile, hashString

The function realisePath has also been declared in primops.hh

Change-Id: I295c2f1964b0496e449f4e23f0299ce972bbca04
2024-05-30 08:48:49 +02:00
Tom Hubrecht 7f9f2f7835 primops: Move functions to primops/string.cc
Moved builtins: baseNameOf, compareVersions, concatStringsSep, match,
parseDrvName, replaceStrings, split, splitVersion, stringLength,
substring, toString

Change-Id: I0daf1eb5263fbadcfe4917a4bf017be0ac9bf939
2024-05-30 08:48:49 +02:00
Tom Hubrecht 84e80fa97d primops: Move functions to primops/control.cc
Moved builtins: abort, break, throw, tryEval

Change-Id: I6198b201325a7029cf011b868f87bef7f4272f8a
2024-05-30 08:48:49 +02:00
Tom Hubrecht 0ba37444da primops: Move functions to primops/attrset.cc
Moved builtins: attrNames, attrValues, catAttrs, getAttr, groupBy,
hasAttr, intersectAttrs, mapAttrs, removeAttrs, zipAttrsWith

Change-Id: I55e2c9ef40ece5ba5bf4a96cae655f481d0b140b
2024-05-30 02:15:22 +02:00
terru - 71b32bb87c Merge "package: don't run shellHook in nested nix-shells" into main 2024-05-28 10:01:37 +00:00
terru - 7a12bc2007 package: don't run shellHook in nested nix-shells
If a nested nix-shell is run inside a nix-shell, then the outer shell's
shellHook will be passed through and run again, unless the nested shell
defines its own.

With lix's hook, this can be annoying: forgetting to exit its nix-shell,
cd'ing to another repository & entering a nested nix-shell will happily
install lix's pre-commit hook in it.

This change makes lix's hook return early in such cases.

Change-Id: I91cb6eb6668f3a8eace36ecbdb01eb367861d77b
2024-05-27 22:09:57 +02:00
terru - 0b91a4b0ec shell.nix: conform to documentation
According to doc/manual/src/contributing/hacking.md, all development
shells should also be available in classic nix using the -A argument
to nix-shell, e.g.

  nix-shell -A native-clangStdenvPackages

This was not actually the case; flake-compat generates attrsets like

  nix-shell -A devShells.x86_64-linux.native-clangStdenvPackages

instead. These are unwieldy to use, so rather than changing the docs,
this changes the shell.nix file to result in the documented behavior.

Change-Id: I0920ccbdfddacf371f0aeaae7e290db65cf76ee7
2024-05-27 16:47:40 +02:00
Qyriad 2cd1ef2201 Merge "libfetchers: fix URL logging" into main 2024-05-27 14:20:15 +00:00
Qyriad ec5039653d Merge "Revert "bump the extra --version info from info to notice, -vv -> -v"" into main 2024-05-26 21:51:05 +00:00
eldritch horrors ed6b3165ea worker: process timeouts first, and exclusively
check goals for timeouts first, and their activity fds only if no
timeout has occurred. checking for timeouts *after* activity sets
us up for assertion failures by running multiple build completion
notifiers, the first of which will kill/reap the the goal process
and consuming the Pid instance. when the second notifier attempts
to do the same it will core dump with an assertion failure in Pid
and take down not only the single goal, but the entire daemon and
all goals it was building. luckily this is rare in practice since
it requires a build to both finish and time out at the same time.

writing a test for this is not feasible due to how much it relies
on scheduling to actually trigger the underlying bug, but on idle
machines it can usually be triggered by running multiple sleeping
builds with timeout set to the sleep duration and `--keep-going`:

    nix-build --timeout 10 --builders '' --keep-going -E '
      with import <nixpkgs> {};
      builtins.genList
        (i: runCommand "foo-${toString i}" {} "sleep 10")
        100
    '

Change-Id: I394d36b2e5ffb909cf8a19977d569bbdb71cb67b
2024-05-26 20:57:09 +00:00
Qyriad 742c62a6eb docstrings: NixRepl::getDerivationPath: exceptions directly thrown
getDerivationPath() directly throws nix::Error for invalid derivations

Change-Id: I81ead950060b789794fa683b61c6349fece1690d
2024-05-26 17:19:26 +00:00
Qyriad 9f16a20f3d Revert "bump the extra --version info from info to notice, -vv -> -v"
This reverts commit d003dcd7f4.

d0390b5cf¹ bumped the default verbosity of nix3 commands, making this
change obsolete.

[1]: d0390b5cf2

Change-Id: I1ddc36ea4514cd8d2855ff334accf6e98c210879
2024-05-26 11:15:10 -06:00
Maximilian Bosch 5986a720d4 Merge "git putFile: support flake maximalists" into main 2024-05-26 10:16:40 +00:00
Qyriad ebd00b2d0b libfetchers: fix URL logging
8c06b7b43¹ made libfetchers log the URL being fetched just before the
actual fetch, particularly in case something freezes. This used the base
URL, to not include query parameters, as the Nixpkgs lib tests assume
that stderr logs will be equal across shallow and non-shallow git
fetches (and shallow fetches have the ?shallow=1 query parameter).

8c06b7b43 assumed that the `base` field of ParsedURL would be populated,
as the comment simply says "URL without query/fragment"... but
apparently it is not populated when the URL being fetched is *already*
fetched, which caused libfetchers to log things like

fetching gitlab input ''

which is. silly. but you know, busted lix be busted.

Anyway, with this commit we just remove the query params before printing
instead, which seems to do the right thing

[1]: 8c06b7b431

Change-Id: I9b9988992029aa6abef786f20b66e68c2ebb97d4
2024-05-25 19:37:38 -06:00
Artemis Tosini 53e2b0740c
libstore: remove duplicate builder variable
The `builder` local variable and duplicate `args.push_back` are no
longer required since the Darwin sandbox stopped using `sandbox-exec`.
The `drv->isBuiltin` check is not required either, as args are not
accessed when the builder is builtin.

Change-Id: I80b939bbd6f727b01793809921810ff09b579d54
2024-05-25 22:14:55 +00:00
jade dd53bce476 Merge "libstore: parse the buildMode instead of unchecked cast" into main 2024-05-25 17:42:09 +00:00
alois31 ddfe379a6b Merge "libstore/build: always enable seccomp filtering and no-new-privileges" into main 2024-05-25 04:21:53 +00:00
jade 2a7a824d83 libstore: parse the buildMode instead of unchecked cast
Change-Id: Icf6af7935e8f139bef36b40ad475e973aa48855c
2024-05-24 20:45:05 -06:00
Qyriad 5b4b216fac Merge "nix3-upgrade-nix: fix when there are differing pnames" into main 2024-05-25 02:20:24 +00:00
Qyriad 1c0f3c540e Merge changes I3ab84cc5,Iba34ad42 into main
* changes:
  nix3: always use the same verbosity default (info)
  libfetchers: log fetches by URL just before they happen
2024-05-25 01:52:44 +00:00
Qyriad f3f68fcfac nix3-upgrade-nix: fix when there are differing pnames
Change-Id: I19c7e24a4d46137127e76b7bb133e0184d73d1b6
2024-05-25 01:50:32 +00:00
Qyriad 076c19e0d1 change "evaluating file" logs to debug
I can't imagine wanting this unless you are debugging something (in
which case it's very useful)

Change-Id: I90c6f182c18486e9f6b15a59379bbb8e88fb8e7f
2024-05-24 23:03:08 +00:00
alois31 f047e4357b libstore/build: always enable seccomp filtering and no-new-privileges
Seccomp filtering and the no-new-privileges functionality improve the security
of the sandbox, and have been enabled by default for a long time. In
#265 it was decided that they
should be enabled unconditionally. Accordingly, remove the allow-new-privileges
(which had weird behavior anyway) and filter-syscall settings, and force the
security features on. Syscall filtering can still be enabled at build time to
support building on architectures libseccomp doesn't support.

Change-Id: Iedbfa18d720ae557dee07a24f69b2520f30119cb
2024-05-24 21:19:29 +00:00
Qyriad d0390b5cf2 nix3: always use the same verbosity default (info)
Change-Id: I3ab84cc583e3e8b1c05a8ae1a7a087204f513d03
2024-05-24 15:15:42 -06:00
Qyriad 8c06b7b431 libfetchers: log fetches by URL just before they happen
Addresses but does not close #305, as we still need an indicator for
frozen fetches.

Change-Id: Iba34ad42dc1c8772f7da249b90fe794b041bbf73
2024-05-24 15:15:42 -06:00
jade 19ea351642 Merge "clang-tidy: work with angle brackets and external projects" into main 2024-05-24 19:11:26 +00:00
Qyriad adfc22c3e3 Merge "make CTRL+Z work in the REPL" into main 2024-05-24 17:37:33 +00:00
Qyriad 933f1f48a2 Merge "justfile: remove --quiet from just test" into main 2024-05-24 17:37:25 +00:00
Qyriad 65da3e7199 make CTRL+Z work in the REPL
Editline just wasn't being built with --enable-sigstop lol

Change-Id: I35a78f74ea100d97f26b2b41990deb373fd9cd9a
2024-05-24 03:10:12 +00:00
Qyriad 2b397c6629 Merge "add editorconfig for markdown" into main 2024-05-24 03:08:25 +00:00
jade 745b5d3d4f clang-tidy: work with angle brackets and external projects
Also fix the readme

Change-Id: I422dff5536bf01d43983621aa01035bd77ac0252
2024-05-24 02:22:58 +00:00
Qyriad e1d2fb4a65 add editorconfig for markdown
Change-Id: I493fc37fde425fc5c5c24f9b077bdc235271233c
2024-05-24 02:22:44 +00:00
Qyriad bb6d43b63b justfile: remove --quiet from just test
`meson test` refuses to let `--verbose` (which shows the entire
invocation and stdio) override `--quiet`, but if neither are specified
in the justfile then you can use either `just test -q` or `just test -v`

Change-Id: I449e13084ce64666b7ee2ab4280818782fb8185a
2024-05-24 02:22:25 +00:00
Pierre Bourdon 6922d67eb3 package.nix: add meta.mainProgram
nix-repl> lib.getExe (builtins.getFlake ".").packages.x86_64-linux.nix
"/nix/store/ajps2zn5hlap0l2abvnfdaphg8k0789r-lix-2.90.0pre20240524_dirty/bin/nix"

Fixes #316.

Change-Id: Iec3125dc2dc99d100beb6357f7d1555456924ddc
2024-05-24 02:15:45 +00:00
jade d1fa446454 [emergency revert]: make pname nix once more
Embarrassingly, I submitted a CL overriding submit requirements since
I thought it was spurious failures. However, the CI failure was in fact
real, and I have hopefully learned my lesson. The CI failure is that:

```
vm-test-run-nix-upgrade-nix> machine # installing 'nix-2.18.1'
vm-test-run-nix-upgrade-nix> machine # building '/nix/store/2b6fdf7wvahd00bg2ff0393bhd597a0h-user-environment.drv'...
vm-test-run-nix-upgrade-nix> machine # error: Unable to build profile. There is a conflict for the following files:
vm-test-run-nix-upgrade-nix> machine #
vm-test-run-nix-upgrade-nix> machine #          /nix/store/dn6mhhr92bh3ad0n4pd1538ww88khjii-nix-2.18.1/lib/libboost_context.so
vm-test-run-nix-upgrade-nix> machine #          /nix/store/w4vffn9iq0znk8bcg5i2giij90xy6db6-lix-2.90.0pre20240523_c97e171/lib/libboost_context.so
vm-test-run-nix-upgrade-nix> machine # error: builder for '/nix/store/2b6fdf7wvahd00bg2ff0393bhd597a0h-user-environment.drv' failed with exit code 1
vm-test-run-nix-upgrade-nix> machine # error: program '/nix/store/w4vffn9iq0znk8bcg5i2giij90xy6db6-lix-2.90.0pre20240523_c97e171/bin/nix-env' failed with exit code 100
```

This is definitely caused by the pname not being the same, so we had
better revert that part of the change until we know we won't regress
anything by doing this.

Fixes: https://gerrit.lix.systems/c/lix/+/1152/5
Change-Id: I0e9d573987f2819c106fb7cea87410fa75152274
2024-05-24 01:33:42 +00:00