Commit Graph
62 Commits
Author SHA1 Message Date
Tom Hubrechtandeldritch horrors 128159a717 repl: Fix the use command
The culprit was a space added at the wrong place, which messed with c++
raw strings.

Fixes #1178

Change-Id: Ic1e09cb7215d9a6dd2d13fd92242649b0e1fcd13
(cherry picked from commit cbeb4fcd69)
2026-04-07 14:06:19 +00:00
Tom Hubrecht d52033fc77 nix/develop: Don't ignore SSL_CERT_FILE when its value is meaningful
Change-Id: I31e85a5995edc40ed2e687077ffdf563e717abb4
2026-02-28 12:32:45 +00:00
Tom Hubrecht 7d764670c8 nix/path-info: Don't print missing paths as no fetch can be done
Fixes #323

Let's now all go an a little rant about spaghetti code...

The result of this code is that the missing paths are not printed
anymore. The basic issue was that the parent class of this command is
StorePathsCommand, which inherits from BuiltPathsCommand, and their
purpose is to work on path that are clearly in the store, building them
if needed (and ofc telling the user about what's missing), the sequance
of calls is:

- BuiltPathsCommand::run(ref<Store> store, Installables && installables)
- Installable::toBuiltPaths( *getEvaluator()->begin(aio()),
getEvalStore(), store, realiseMode, operateOn, installables);
  where operateOn is Output by default, realiseMode is Derivation, so
the only thing that can be built are the derivations for the required
installables
- Installable::build(state, evalStore, store, mode, installables)
- Installable::build2(state, evalStore, store, mode, installables,
bMode)

And that final call has the following:

```
    switch (mode) {

    case Realise::Nothing:
    case Realise::Derivation:
        state.aio.blockOn(printMissing(store, pathsToBuild, lvlError));
```

So there were two options, hack a new spaghetti in the existing
spaghetti code, or condense all those calls that are actually useless in
our case because they mostly transform a list of installables into a map
from installables to their BuiltPath which are then iterated to retrieve
the final outputs, whereas it is possible to directly get the required
paths in a much more efficient manner and without printing unrequired
stuff through a multitude of intertwined function calls by simply
replacing one method that was previously inherited from the grandparent
class

Change-Id: I1d2baaef5a099cd98b63b5346f2613914c6cd2ac
2026-01-18 20:25:39 +00:00
Tom Hubrecht f431464382 libutil/hash: Simplify some parts
Use a span representing the underlying hash, this allows comparing based
on those spans. Other minor tweaks to the header file.

Change-Id: Ie05960439e60500109083c06d347d6cdf41bfda8
2026-01-12 15:56:05 +01:00
Tom Hubrecht e29263b638 libutil/hash: Add default values for Hash::to_string
The sane default is to print in SRI format, and include the hash type

Change-Id: I7efcb5dcfbe56c82dbf1928e2bb35cdd3ff089c6
2026-01-10 18:26:15 +00:00
Tom Hubrecht 16d884bd1f fix(log-format): Apply the required setting with the nix2 cli
Fixes #1099

Change-Id: I658743aae7ec7a7f295c849079166a5940d93e82
2026-01-10 18:12:01 +00:00
Tom Hubrecht 1bd381654c libutil/hash: Drop printHash16or32 function
Its only use is in nix prefetch, inline it there instead

Change-Id: Ibb60df41a205cde2a4f383e8cff05dc6d4c032b8
2026-01-07 16:04:52 +00:00
Tom Hubrecht b482ebbbc8 treewide: Rename Base to HashFormat
Co-authored-by: Yueh-Shun Li <shamrocklee@posteo.net>

`base` is ambiguous, since it's not about the digital bases, but about
the format of hashes. Base16, Base32 and Base64 are all character maps
for binary encoding.

Documentation of the format is also added.

Cherry-pick of:
https://github.com/NixOS/nix/pull/7708/commits/838c70f62116328ce01cb41a01886e4f1b9a727f
https://github.com/NixOS/nix/pull/7708/commits/5043e6cf4ea537dfe599470797c5b310ab0e94b9

Change-Id: Ief5425f3c2056a4cca75838091e4dfa5cca88872
2026-01-06 11:22:06 +00:00
Tom Hubrecht 7b8947ea63 tests/evalNixpkgs: Split out into its own file and set NIX_CONFIG
This adds a way to control the deprecated features that need to be
enable while evaluating the specific nixpkgs version

Change-Id: Ia2b9a29f1966d4d5f32239a36ba8270330007da9
2026-01-04 23:00:24 +00:00
Tom Hubrecht cfedc951b6 tests/nixpkgsLib: Split out into its own file and set NIX_CONFIG
This avoids rebuilding Lix each time we need to modify the lib tests
(as flake.nix stays unchanged), and adds a way to control the deprecated
features that need to be enable while evaluating the nixpkgs lib
testsuite

Change-Id: I2baa1cf90effcaf9d53337c6a7a5b24d6297178c
2026-01-04 22:52:32 +00:00
Tom Hubrecht 0ebb1c524d daemon: Make the error more explicit when the sandbox group tries to connect
Fixes #1069

Change-Id: I32ece312b0a1c4fbbc21902d71a15c6ff40b3aed
2025-12-14 20:43:20 +01:00
Tom Hubrecht b2b95775bd misc: Really fix the unused-variable warning
When everything else has failed, cast it to the void

Change-Id: I8f9769e60c359a6a17151e9199749f5c7042566f
2025-12-14 20:43:20 +01:00
Tom Hubrecht 5157fbaf2c testWithNix: Don't depend on CppNix
Change-Id: Ia0903d93796c30e370d99d02877cc93c258b8f32
2025-12-14 15:20:16 +01:00
Tom Hubrecht 36a61d922c lix-clang-tidy: Avoid using llvm::Twine
> A Twine is not intended for use directly and should not be stored

Change-Id: Ie243d109bc3feb75867ed748c5e4cbcddfafd3e1
2025-12-09 17:13:36 +01:00
Tom Hubrecht 5d21b8262b clang-tidy: enable bugprone-multi-level-implicit-pointer-conversion
The default clang version in nixos 25.05 was llvm 19, we are now even
past that

Change-Id: Ieb62616fb87c4d2a8d892136a7164822aa1eceb6
2025-12-09 14:51:43 +00:00
Tom Hubrecht 50c47c340f misc: Remove unused private field, move unused variable in #if, remove virtual specifier
Those are new warnings that come with a more up-to-date llvm

Fixes #1066

Co-authored-by: eldritch horrors <pennae@lix.systems>

Change-Id: I305d0d810d12a5e8d31c7d89e0cdb3a82df71556
2025-12-09 14:29:35 +01:00
Tom Hubrecht 3db533c637 clang-tidy: enable bugprone-implicit-widening-of-multiplication-result
Change-Id: I7c7bae6c27aa59da23097ec89305cfc60ec9e8e3
2025-12-09 08:32:37 +00:00
Tom Hubrecht 8ebe893854 clang-tidy: enable lix-fixincludes
The reorganization has been done

Change-Id: Ib8eec6656f375f8329fe4caefd009369aa36d8f2
2025-12-07 14:05:39 +00:00
Tom Hubrecht 1a304964aa package: Add libllvm to the inputs when linting
This should allow better stacktraces when clang-tidy fails miserably on
aarch64 machines

Change-Id: Ia795cf1dc012bd8f06b429d97184b88c80dd72cb
2025-12-07 11:40:03 +01:00
Tom Hubrecht 543ae33d26 functional2: Increase timeout in the cycles detection test
On a busy CI the 1s timeout is not always enough

Change-Id: Ie39be01ae8818df8c9026d28907f5b145a452e3b
2025-12-06 22:33:19 +00:00
Tom Hubrecht 1bfbbe2415 nix-shell: Add NIX_SHELL_LEVEL variable
This contains the depth of nix shells nesting.

Fixes #826

Co-authored-by: Qyriad <qyriad@qyriad.me>

Change-Id: If584c9d02730d6c857636dafdeab0c01f4ec8e0f
2025-12-01 12:02:45 +00:00
Tom Hubrecht 0c6d299e16 libexpr/eval: Deprecate shadowing <nix/fetchurl.nix>
If the NIX_PATH shadows internal files, this will often break things,
hence we forbid it.

Fixes #998

Change-Id: I70e5d389532ada1c9f910c60281abe565e3ce6bb
2025-11-30 12:28:54 +00:00
Tom Hubrecht cb0f9b9590 libstore/transfer: Warn by default instead of throw for destination changes
Fixes #1004

Change-Id: I2d583fbad40b3c95e37b70167a81c8fb492d5668
2025-11-26 14:42:52 +01:00
Tom Hubrecht 0c70cc6259 libutil: Reintroduce compile assertion that was mistakenly dropped
https://git.lix.systems/lix-project/lix/commit/74513483bc5572d988a059b8e964662d66f1667f
removed this check which is actually load-bearing for Lix (c.f.
https://git.lix.systems/lix-project/lix/commit/96a36833084f66b79ba778e719862b8219557773
).

Fixes #677

Change-Id: I3cc9a16c64c5189f788c510609afcf8bad997741
2025-11-26 01:56:00 +00:00
Tom Hubrecht 0167bf56f5 libstore/getDefaultSubstituters: Add information when a substituters cannot be setup
Fixes #1034

Change-Id: Ic65ef955c4eb44766926e9b3ef4dcb4b94820a16
2025-11-24 12:08:30 +00:00
Tom Hubrecht 26de2b79c2 nix/develop: Set default outputs attribute
When using `builtins.derivation`, the `outputs` list can be omitted, and
in that case, it defaults to `[ "out" ]`, set this default when building
the shell derivation for `nix develop`

Fixes: #556
Change-Id: I4dc77d060f30ee499e186ec919de30bd3e5c53bb
2025-11-24 09:56:14 +00:00
Tom Hubrecht 395fe68127 tests/clang-tidy: Run on all supported platforms
Fixes #1013

Change-Id: I7388e4eb4728c34f2e21756438020e28b4f1cfca
2025-11-24 07:22:15 +00:00
Tom Hubrecht 748a975aa0 libexpr/builtins: Fixup scopedImport documentation
Change-Id: I01cbc628a0334a1d1e6347d987089262c08e7cee
2025-11-23 08:58:17 +01:00
Tom Hubrecht ea99f26b25 libexpr/builtins: Document fetchMercurial
Change-Id: Ic849bd6dd10374b717d3fc257da25208f2c45525
2025-11-23 08:58:17 +01:00
Tom Hubrecht 3cf5ad0164 libexpr/builtins: Document unsafeDiscardStringContext
Co-authored-by: eldritch horrors <pennae@lix.systems>

Change-Id: I4ebbbc9d32152f296a2553f2fd324dacf8af02d8
2025-11-23 08:58:17 +01:00
Tom Hubrecht fd273186c6 libexpr/builtins: Document appendContext
Change-Id: Ic45e0d4f6f1646552a7162bd8916f63fc11e5e62
2025-11-23 07:26:15 +00:00
Tom Hubrecht 94ca4fd7b4 treefmt: Add meson/clang-tidy to the list of files checked by ruff
Change-Id: I3141286069844588a721cd4e523a284ef3a359c8
2025-11-22 13:19:40 +01:00
Tom Hubrecht 8558cf781a libexpr/builtins: Document derivationStrict
Co-authored-by: eldritch horrors <pennae@lix.systems>
Co-authored-by: Qyriad <qyriad@qyriad.me>

Change-Id: I4cf95683da54efe830514f3a6795057cadd223c6
2025-11-21 14:59:03 +01:00
Tom Hubrecht 428a0bcb5e nix/run: Move argument parsing in the ifdef
Most of the arguments are only used on linux platforms

Change-Id: Iab79a3edf346257a2cd1c6e18ead2f1f77c7cc6d
2025-11-21 11:56:38 +00:00
Tom Hubrecht 170f092ce2 gc: Unify UX across the 3 cli ways to collect garbage
There are currently 4 different ways to run garbage collection using
lix:
- `nix-collect-garbage`
- `nix-store --gc`
- `nix store gc`
- (using the daemon directly)

As they were written all at different times, their output varies (and is
broken in some case). This unifies the display of informations in the
following ways:

- The list of paths in the results is always printed (in the nix3 cli it
is hidden unless `-v` is passed)
- The number of paths in the result set is always displayed
- The size of deleted paths is only shown when actually deleting things
(as it would have been 0B in any case)

Fixes #905

Change-Id: I40d9ec7c6d76795f6c6dd30df196d1e855bdb9db
2025-11-20 11:53:18 +00:00
Tom Hubrecht ff231b9b52 libexpr/builtins: Document addErrorContext
Change-Id: I94eee0ccba3fcdc587783800d59ac572ed44f69a
2025-11-20 09:25:10 +00:00
Tom HubrechtandEelco Dolstra f01555105a libexpr/builtins: Document scopedImport
This also allows removing a static initialization of a primop.

Co-authored-by: Eelco Dolstra <edolstra@gmail.com>
Change-Id: I74da68205630f658b239e4327bf5e27bfc1b91da
2025-11-20 09:25:10 +00:00
Tom Hubrecht 04a4b15991 libcmd/copy: Check the validity of the options if required
This is done at the start of the command call, which allows not building
expensive things if the arguments are incorrect anyway.

Fixes #687

Change-Id: Ic924fe2115cf760684c6fdf7987279e96ab00286
2025-11-19 14:45:52 +00:00
Tom HubrechtandRaito Bezarius ac3b742510 libexpr/symbol-table: remove unused field from SymbolTable::symbols
Change-Id: Id16ba5c9b7941757746d0cb79eb14463845aadb1
2025-06-10 13:58:08 +02:00
Tom Hubrecht e468102508 fix: Consider fetchGit locked when narHash is present
`fetchGit` has been modified a long time ago to use fetchTree, however,
we don't care about `lastModified` because we are not in a flake
context, this hack introduces a `git-locked` type of input that only
cares about `narHash` being present. This is needed to avoid fetching
the remote repo each time `fetchGit` is evaluated whith the result
present in the store.

Change-Id: I521c6fcccf8cf12945594f205d7fd4c8c2cf89e9
2025-05-28 22:24:23 +00:00
Tom HubrechtandLix Systems Gerrit 0d72109ada Merge "libfetchers: factorize inputFromAttrs" into main 2025-05-28 19:54:37 +00:00
Tom Hubrecht 76524b92ee libfetchers: factorize inputFromAttrs
Each `inputFromAttrs` is roughly the same function in each class, we
check that the attributes given are correct (in term of keys and other
types) then we coppy the attributes. Instead of having the same code
copied in 10 places, set it in the parent class and specify what is
specific per child class.

Change-Id: If9aecb76cff1e28a1ef6668d83d825686cce8353
2025-05-22 14:00:19 +02:00
Tom HubrechtandLix Systems Gerrit 885dde9c3d Merge "libstore: Show illegal path references in fixed-outputs derivations" into main 2025-05-08 20:19:15 +00:00
a8da0df671 libstore: Show illegal path references in fixed-outputs derivations
This allows debugging the errors by pinpointing the offenders, instead
of trying to blindly guess what could have possibly gone wrong.

The wording has been improved to better explain the failure.

Closes #530

Co-authored-by: Ben Millwood <thebenmachine+git@gmail.com>
Change-Id: I84ba5d2d81e5d1867f53bd3bc80e615cab9fe274
2025-05-08 20:23:12 +02:00
Tom Hubrecht 834133c1d5 chore(docker.nix): Replace mapAttrsFlatten by mapAttrsToList
The former is deprecated

Change-Id: I9e2a7656e257afe321183b7f6c30deab47ebb61a
2025-04-25 11:13:11 +02:00
Tom Hubrecht a5e2376350 documentation: Explain how a float will be transformed into a string
`prim_toString` uses `state.coerceToString`, which in turns defers to
`std::to_string` for floats, which 'Converts a floating point value to a
string as if by std::sprintf(buf, "%f", value)'.
Finally, the `%f` specifier 'Converts floating-point number to the
decimal notation in the style [-]ddd.ddd. Precision specifies the exact
number of digits to appear after the decimal point character. The
default precision is 6.'

Closes #747

Change-Id: I42339651005d20f272459cf9f80b274f2076b1e3
2025-03-18 13:42:25 +01:00
Tom Hubrecht a39ba22ff7 util.hh: Delete remaining file and clean up headers
Change-Id: Ic1f68e6af658e94ef7922841dd3ad4c69551ef56
2024-05-29 12:38:51 +02:00
Tom Hubrecht f0eb650ee8 util.hh: Move nativeSystem to local-derivation-goal.cc
Change-Id: I74565fbfd3aeedef8f50465808fac712b84e47ad
2024-05-29 11:42:42 +02:00
Tom Hubrecht d73c40ff3d util.hh: Move stuff to types.hh
Change-Id: Ia852306a4b8aac6856dc42bc69e4b58b53a0d67c
2024-05-29 11:42:42 +02:00
Tom Hubrecht 74513483bc util.cc: Delete remaining file
Change-Id: I2b47848904f2ce7bd78b83738e99a4c9da627751
2024-05-29 11:42:42 +02:00
Tom Hubrecht 93ebb3e7df util.{hh,cc}: Move ignoreException to error.{hh,cc}
Change-Id: Iae6464217a55c313a983e5c651b26a4a1e446706
2024-05-29 11:42:42 +02:00
Tom Hubrecht 8b6d2d3915 util.{hh,cc}: Split out namespaces.{hh,cc}
Change-Id: I8fd3f3b50c15ede29d489066b4e8d99c2c4636a6
2024-05-29 11:41:16 +02:00
Tom Hubrecht f79ee66646 util.{hh,cc}: Split out users.{hh,cc}
Change-Id: I1bd92479a2cb7e5c2c2e1541b80474adb05ea0df
2024-05-29 11:01:34 +02:00
Tom Hubrecht b910551120 util.{hh,cc}: Split out strings.{hh,cc}
Change-Id: I4f642d1046d56b5db26f1b0296ee16a0e02d444a
2024-05-29 11:01:34 +02:00
Tom Hubrecht 5b5a75979a util.{hh,cc}: Split out unix-domain-socket.{hh,cc}
Change-Id: I3f9a628e0f8998b6146f5caa8ae9842361a66b8b
2024-05-29 11:01:34 +02:00
Tom Hubrecht e81ed5f12d util.{hh,cc}: Split out child.{hh,cc}
Change-Id: Iec4824e071f537b17dd62dbb8c01b8eec14e9783
2024-05-29 11:01:34 +02:00
Tom Hubrecht 2473e1253d util.{hh,cc}: Split out current-process.{hh,cc}
Change-Id: I77095b9d37e85310075bada7a076ccd482c28e47
2024-05-29 11:01:34 +02:00
Tom Hubrecht 9a52e4688c util.{hh,cc}: Split out processes.{hh,cc}
Change-Id: I39280dc40ca3f7f9007bc6c898ffcf760e2238b7
2024-05-29 11:01:34 +02:00
Tom Hubrecht 8cd9aa24a8 util.{hh,cc}: Split out file-descriptor.{hh,cc}
Change-Id: I0dd0f9a9c2003fb887e076127e7f825fd3289c76
2024-05-29 09:54:47 +02:00
Tom Hubrecht 6b5078c815 util.{hh,cc}: Split out file-system.{hh,cc}
Change-Id: Ifa89a529e7e34e7291eca87d802d2f569cf2493e
2024-05-29 09:54:47 +02:00
Tom Hubrecht 81bdf8d2d6 util.{hh,cc}: Split out terminal.{hh,cc}
Change-Id: I9de2296b4012d50f540124001d54d6ca3be4c6da
2024-05-29 09:54:47 +02:00
Tom Hubrecht 6fd6795bc4 util.{hh,cc}: Split out environment-variables.{hh,cc}
Change-Id: Icff0aa33fda5147bd5dbe256a0b9d6a6c8a2c3f6
2024-05-28 11:29:29 +02:00