Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions .github/workflows/nix-github-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,11 @@ jobs:
path: /nix
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v31
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: cachix/cachix-action@v16
if: ${{ ! env.NAMESPACE_RUNNER }}
with:
name: nix-community
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
- run: nix build -L ".#${{ matrix.attr }}"
tests:
strategy:
Expand All @@ -64,7 +67,11 @@ jobs:
github_access_token: ${{ secrets.GITHUB_TOKEN }}
extra_nix_config: |
accept-flake-config = true
- uses: DeterminateSystems/magic-nix-cache-action@main
- uses: cachix/cachix-action@v16
if: ${{ ! env.NAMESPACE_RUNNER }}
with:
name: nix-community
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"
- name: Build
run: nix develop -c bash -c 'meson setup -Db_sanitize=address,undefined build && ninja -C build'
- name: Run tests
Expand Down
16 changes: 13 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,16 +40,18 @@ executable.
## Further options

```console
$ nix-eval-jobs --help
USAGE: nix-eval-jobs [options] expr

--apply apply the derivation to the provided Nix expression
--apply Apply provided Nix function to each derivation. The result of this function will be serialized as a JSON value and stored inside `"extraValue"` key of the json line output.
--arg Pass the value *expr* as the argument *name* to Nix functions.
--arg-from-file Pass the contents of file *path* as the argument *name* to Nix functions.
--arg-from-stdin Pass the contents of stdin as the argument *name* to Nix functions.
--argstr Pass the string *string* as the argument *name* to Nix functions.
--check-cache-status Check if the derivations are present locally or in any configured substituters (i.e. binary cache). The information will be exposed in the `cacheStatus` field of the JSON output.
--constituents whether to evaluate constituents for Hydra's aggregate feature
--debug Set the logging verbosity level to 'debug'.
--eval-store
The [URL of the Nix store](@docroot@/command-ref/new-cli/nix3-help-stores.md#store-url-format)
The [URL of the Nix store](@docroot@/store/types/index.md#store-url-format)
to use for evaluation, i.e. to store derivations (`.drv` files) and inputs referenced by them.

--expr treat the argument as a Nix expression
Expand All @@ -58,6 +60,12 @@ USAGE: nix-eval-jobs [options] expr
--gc-roots-dir garbage collector roots directory
--help show usage information
--impure allow impure expressions
--include
Add *path* to search path entries used to resolve [lookup paths](@docroot@/language/constructs/lookup-path.md)

This option may be given multiple times.

Paths added through `-I` take precedence over the [`nix-path` configuration setting](@docroot@/command-ref/conf-file.md#conf-nix-path) and the [`NIX_PATH` environment variable](@docroot@/command-ref/env-common.md#env-NIX_PATH).

--log-format Set the format of log output; one of `raw`, `internal-json`, `bar` or `bar-with-logs`.
--max-memory-size maximum evaluation memory size in megabyte (4GiB per worker by default)
Expand All @@ -66,7 +74,9 @@ USAGE: nix-eval-jobs [options] expr
--override-flake Override the flake registries, redirecting *original-ref* to *resolved-ref*.
--override-input Override a specific flake input (e.g. `dwarffs/nixpkgs`).
--quiet Decrease the logging verbosity level.
--reference-lock-file Read the given lock file instead of `flake.lock` within the top-level flake.
--repair During evaluation, rewrite missing or corrupted files in the Nix store. During building, rebuild missing or corrupted store paths.
--show-input-drvs Show input derivations in the output for each derivation. This is useful to get direct dependencies of a derivation.
--show-trace print out a stack trace in case of evaluation errors
--verbose Increase the logging verbosity level.
--workers number of evaluate workers
Expand Down
5 changes: 4 additions & 1 deletion src/eval-args.cc
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ MyArgs::MyArgs() : MixCommonArgs("nix-eval-jobs") {

addFlag(
{.longName = "apply",
.description = "apply the derivation to the provided Nix expression",
.description =
"Apply provided Nix function to each derivation. "
"The result of this function will be serialized as a JSON value "
"and stored inside `\"extraValue\"` key of the json line output.",
.labels = {"expr"},
.handler = {&applyExpr}});

Expand Down
2 changes: 1 addition & 1 deletion src/worker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,7 @@ void worker(
nix::printValueAsJSON(*state, true, vRes, nix::noPos,
ss, context);

reply.update(nlohmann::json::parse(ss.str()));
reply["extraValue"] = nlohmann::json::parse(ss.str());
}

auto drv = Drv(attrPathS, *state, *packageInfo, args,
Expand Down
20 changes: 10 additions & 10 deletions tests/test_eval.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,16 +245,16 @@ def test_apply() -> None:

# Check that nix-eval-jobs applied the expression correctly
# and extracted 'version' as 'version' and 'name' as 'the-name'
assert results[0]["the-name"] == "job1"
assert results[0]["version"] is None
assert results[1]["the-name"].startswith("nix-")
assert results[1]["version"] is not None
assert results[2]["the-name"] == "package-with-deps"
assert results[2]["version"] is None
assert results[3]["the-name"] == "drvB"
assert results[3]["version"] is None
assert results[4]["the-name"].startswith("nix-")
assert results[4]["version"] is not None
assert results[0]["extraValue"]["the-name"] == "job1"
assert results[0]["extraValue"]["version"] is None
assert results[1]["extraValue"]["the-name"].startswith("nix-")
assert results[1]["extraValue"]["version"] is not None
assert results[2]["extraValue"]["the-name"] == "package-with-deps"
assert results[2]["extraValue"]["version"] is None
assert results[3]["extraValue"]["the-name"] == "drvB"
assert results[3]["extraValue"]["version"] is None
assert results[4]["extraValue"]["the-name"].startswith("nix-")
assert results[4]["extraValue"]["version"] is not None


@pytest.mark.infiniterecursion
Expand Down