1
1
Fork 0
mirror of https://github.com/NixOS/nix.git synced 2025-11-08 19:46:02 +01:00
Commit graph

18 commits

Author SHA1 Message Date
Robert Hensing
6036aaf798 C API: Check output callback order 2025-10-15 22:04:21 +02:00
Robert Hensing
6fa03765ed C API: Propagate nix_store_realise build errors 2025-10-15 15:20:24 +02:00
Robert Hensing
3fb943d130 C API: Make store realise tests multi-platform
... and improve assertions.
2025-10-15 14:55:28 +02:00
Robert Hensing
aace1fb5d6 C API: test nix_store_get_fs_closure 2025-10-15 13:27:09 +02:00
John Ericson
9bc218ca3f Add new C API for working with derivations
Also test the APIs we just added.
2025-09-16 13:25:36 -04:00
John Ericson
8089102164 Separate internal from non-internal unit tests of the C API
This helps us make sure that the external C API is sufficient for the
tasks that we think it is sufficient for.
2025-09-03 22:50:42 +02:00
Sergei Zimmerman
1b7ffa53af
treewide: Remove getUri and replace with getHumanReadableURI where appropriate
The problem with old code was that it used getUri for both the `diskCache`
as well as logging. This is really bad because it mixes the textual human
readable representation with the caching.

Also using getUri for the cache key is really problematic for the S3 store,
since it doesn't include the `endpoint` in the cache key, so it's totally broken.

This starts separating the logging / cache concerns by introducing a
`getHumanReadableURI` that should only be used for logging. The caching
logic now instead uses `getReference().render(/*withParams=*/false)` exclusively.
This would need to be fixed in follow-ups, because that's really fragile and
broken for some store types (but it was already broken before).
2025-08-14 16:47:05 +03:00
John Ericson
3e7879e6df Rewrite StoreConfig::getUri in terms of new StoreConfig::getReference
Rather than having store implementations return a free-form URI string,
have them return a `StoreReference`. This reflects that fact that this
method is supposed to invert `resolveStoreConfig`, which goes from a
`StoreReference` to some `StoreConfig` concrete derived class (based on
the registry).

`StoreConfig::getUri` is kept only as a convenience for the common case
that we want to immediately render the `StoreReference`.

A few tests were changed to use `local://` not `local`, since
`StoreReference` does not encode the `local` and `daemon` shorthands
(and instead desugars them to `local://` and `unix://` right away). I
think that is fine. `local` and `daemon` still work as input.
2025-08-13 19:06:59 -04:00
John Ericson
0ef6f72c9c getUri should be const and on Store::Config not Store
It is a side-effect property of the configuration alone, not the rest of
the store.
2025-08-11 17:44:50 -04:00
Sergei Zimmerman
41af531392
libstore: Correct getUri methods for all stores
Previously `getUri` didn't include store query parameters,
`ssh-ng` didn't include any information at all and the local
store didn't have the path:

```
$ nix store info --store "local?root=/tmp/aaa&require-sigs=false"
Store URL: local
Version: 2.31.0
Trusted: 1
$ nix store info --store "ssh-ng://localhost?remote-program=nix-daemon"
Store URL: ssh-ng://
Version: 2.31.0
Trusted: 1
$ nix store info --store "ssh://localhost?remote-program=nix-store"
Store URL: ssh://localhost
```

This commit changes this to:

```
$ nix store info --store "local?root=/tmp/aaa&require-sigs=false"
Store URL: local?require-sigs=false&root=/tmp/aaa
Version: 2.31.0
Trusted: 1
$ nix store info --store "ssh-ng://localhost?remote-program=nix-daemon"
Store URL: ssh-ng://localhost?remote-program=nix-daemon
Version: 2.31.0
Trusted: 1
$ nix store info --store "ssh://localhost?remote-program=nix-store"
Store URL: ssh://localhost?remote-program=nix-store
```
2025-08-11 20:44:31 +03:00
Eelco Dolstra
01388b3e78 Give unit tests access to a $HOME directory
Also, don't try to access cache.nixos.org in the libstore unit tests.
2025-07-07 11:02:51 +02:00
Sergei Zimmerman
55d12dfc5d
libstore-tests: Don't leak memory in tests
We shouldn't leak memory in unit tests in order
to make enabling ASAN easier.
2025-06-25 00:07:58 +03:00
John Ericson
cc24766fa6 Expose the nix component in header include paths
For example, instead of doing

    #include "nix/store-config.hh"
    #include "nix/derived-path.hh"

Now do

    #include "nix/store/config.hh"
    #include "nix/store/derived-path.hh"

This was originally planned in the issue, and also recent requested by
Eelco.

Most of the change is purely mechanical. There is just one small
additional issue. See how, in the example above, we took this
opportunity to also turn `<comp>-config.hh` into `<comp>/config.hh`.
Well, there was already a `nix/util/config.{cc,hh}`. Even though there
is not a public configuration header for libutil (which also would be
called `nix/util/config.{cc,hh}`) that's still confusing, To avoid any
such confusion, we renamed that to `nix/util/configuration.{cc,hh}`.

Finally, note that the libflake headers already did this, so we didn't
need to do anything to them. We wouldn't want to mistakenly get
`nix/flake/flake/flake.hh`!

Progress on #7876
2025-04-01 11:40:42 -04:00
John Ericson
c204e307ac Cleanup config headers
There are two big changes:

1. Public and private config is now separated. Configuration variables
   that are only used internally do not go in a header which is
   installed.

   (Additionally, libutil has a unix-specific private config header,
   which should only be used in unix-specific code. This keeps things a
   bit more organized, in a purely private implementation-internal way.)

2. Secondly, there is no more `-include`. There are very few config
   items that need to be publically exposed, so now it is feasible to
   just make the headers that need them just including the (public)
   configuration header.

And there are also a few more small cleanups on top of those:

- The configuration files have better names.

- The few CPP variables that remain exposed in the public headers are
  now also renamed to always start with `NIX_`. This ensures they should
  not conflict with variables defined elsewhere.

- We now always use `#if` and not `#ifdef`/`#ifndef` for our
  configuration variables, which helps avoid bugs by requiring that
  variables must be defined in all cases.
2025-03-31 23:28:36 -04:00
John Ericson
f3e1c47f47 Separate headers from source files
The short answer for why we need to do this is so we can consistently do
`#include "nix/..."`. Without this change, there are ways to still make
that work, but they are hacky, and they have downsides such as making it
harder to make sure headers from the wrong Nix library (e..g.
`libnixexpr` headers in `libnixutil`) aren't being used.

The C API alraedy used `nix_api_*`, so its headers are *not* put in
subdirectories accordingly.

Progress on #7876

We resisted doing this for a while because it would be annoying to not
have the header source file pairs close by / easy to change file
path/name from one to the other. But I am ameliorating that with
symlinks in the next commit.
2025-03-31 12:20:25 -04:00
Robert Hensing
2a98168942 C API: Add nix_store_real_path 2024-12-14 17:25:41 +00:00
Robert Hensing
472912f7ca C API: Add nix_store_get_storedir 2024-12-14 17:25:41 +00:00
John Ericson
e65510da56 Move unit tests to the location Meson expects them to be
Everything that is a separate subproject should live in the subprojects
directory.

Progress on #2503

This reverts commit 451f8a8c19.
2024-10-17 15:42:16 -04:00
Renamed from tests/unit/libstore/nix_api_store.cc (Browse further)