Skip to content

Commit

Permalink
Merge branch 'NixOS:master' into 387440-apio-udev-rules
Browse files Browse the repository at this point in the history
  • Loading branch information
zh4ngx authored Mar 11, 2025
2 parents 10ed745 + 68ba7da commit 8e1e635
Show file tree
Hide file tree
Showing 1,537 changed files with 32,062 additions and 182,090 deletions.
3 changes: 3 additions & 0 deletions .git-blame-ignore-revs
Original file line number Diff line number Diff line change
Expand Up @@ -235,3 +235,6 @@ ef85e0daa092c9eae0d32c7ce16b889728a5fbc0
d89ad6c70e0e89aaae75e9f886878ea4e103965a
e0fe216f4912dd88a021d12a44155fd2cfeb31c8
80d5b411f6397d5c3e755a0635d95742f76f3c75

# nixos/movim: format with nixfmt-rfc-style
43c1654cae47cbf987cb63758c06245fa95c1e3b
2 changes: 1 addition & 1 deletion CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -650,7 +650,7 @@ If you want your PR to get merged quickly and smoothly, it is in your best inter

For the committer to judge your intention, it's best to explain why you've made your change.
This does not apply to trivial changes like version updates because the intention is obvious (though linking the changelog is appreciated).
For any more nuanced changed or even major version upgrades, it helps if you explain the background behind your change a bit.
For any more nuanced changes or even major version upgrades, it helps if you explain the background behind your change a bit.
E.g. if you're adding a package, explain what it is and why it should be in Nixpkgs.
This goes hand in hand with [Writing good commit messages](#writing-good-commit-messages).

Expand Down
164 changes: 159 additions & 5 deletions doc/build-helpers/testers.chapter.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ It has two modes:

## `shellcheck` {#tester-shellcheck}

Runs files through `shellcheck`, a static analysis tool for shell scripts.
Run files through `shellcheck`, a static analysis tool for shell scripts, failing if there are any issues.

:::{.example #ex-shellcheck}
# Run `testers.shellcheck`
Expand All @@ -127,7 +127,7 @@ A single script

```nix
testers.shellcheck {
name = "shellcheck";
name = "script";
src = ./script.sh;
}
```
Expand All @@ -139,7 +139,7 @@ let
inherit (lib) fileset;
in
testers.shellcheck {
name = "shellcheck";
name = "nixbsd-activate";
src = fileset.toSource {
root = ./.;
fileset = fileset.unions [
Expand All @@ -154,17 +154,80 @@ testers.shellcheck {

### Inputs {#tester-shellcheck-inputs}

[`src` (path or string)]{#tester-shellcheck-param-src}
`name` (string, optional)
: The name of the test.
`name` will be required at a future point because it massively improves traceability of test failures, but is kept optional for now to avoid breaking existing usages.
Defaults to `run-shellcheck`.
The name of the derivation produced by the tester is `shellcheck-${name}` when `name` is supplied.

`src` (path-like)
: The path to the shell script(s) to check.
This can be a single file or a directory containing shell files.
All files in `src` will be checked, so you may want to provide `fileset`-based source instead of a whole directory.

### Return value {#tester-shellcheck-return}

A derivation that runs `shellcheck` on the given script(s).
A derivation that runs `shellcheck` on the given script(s), producing an empty output if no issues are found.
The build will fail if `shellcheck` finds any issues.

## `shfmt` {#tester-shfmt}

Run files through `shfmt`, a shell script formatter, failing if any files are reformatted.

:::{.example #ex-shfmt}
# Run `testers.shfmt`

A single script

```nix
testers.shfmt {
name = "script";
src = ./script.sh;
}
```

Multiple files

```nix
let
inherit (lib) fileset;
in
testers.shfmt {
name = "nixbsd";
src = fileset.toSource {
root = ./.;
fileset = fileset.unions [
./lib.sh
./nixbsd-activate
];
};
}
```

:::

### Inputs {#tester-shfmt-inputs}

`name` (string)
: The name of the test.
`name` is required because it massively improves traceability of test failures.
The name of the derivation produced by the tester is `shfmt-${name}`.

`src` (path-like)
: The path to the shell script(s) to check.
This can be a single file or a directory containing shell files.
All files in `src` will be checked, so you may want to provide `fileset`-based source instead of a whole directory.

`indent` (integer, optional)
: The number of spaces to use for indentation.
Defaults to `2`.
A value of `0` indents with tabs.

### Return value {#tester-shfmt-return}

A derivation that runs `shfmt` on the given script(s), producing an empty output upon success.
The build will fail if `shfmt` reformats anything.

## `testVersion` {#tester-testVersion}

Checks that the output from running a command contains the specified version string in it as a whole word.
Expand Down Expand Up @@ -347,6 +410,97 @@ testers.testEqualContents {

:::

## `testEqualArrayOrMap` {#tester-testEqualArrayOrMap}

Check that bash arrays (including associative arrays, referred to as "maps") are populated correctly.

This can be used to ensure setup hooks are registered in a certain order, or to write unit tests for shell functions which transform arrays.

:::{.example #ex-testEqualArrayOrMap-test-function-add-cowbell}

# Test a function which appends a value to an array

```nix
testers.testEqualArrayOrMap {
name = "test-function-add-cowbell";
valuesArray = [
"cowbell"
"cowbell"
];
expectedArray = [
"cowbell"
"cowbell"
"cowbell"
];
script = ''
addCowbell() {
local -rn arrayNameRef="$1"
arrayNameRef+=( "cowbell" )
}
nixLog "appending all values in valuesArray to actualArray"
for value in "''${valuesArray[@]}"; do
actualArray+=( "$value" )
done
nixLog "applying addCowbell"
addCowbell actualArray
'';
}
```

:::

### Inputs {#tester-testEqualArrayOrMap-inputs}

NOTE: Internally, this tester uses `__structuredAttrs` to handle marshalling between Nix expressions and shell variables.
This imposes the restriction that arrays and "maps" have values which are string-like.

NOTE: At least one of `expectedArray` and `expectedMap` must be provided.

`name` (string)

: The name of the test.

`script` (string)

: The singular task of `script` is to populate `actualArray` or `actualMap` (it may populate both).
To do this, `script` may access the following shell variables:

- `valuesArray` (available when `valuesArray` is provided to the tester)
- `valuesMap` (available when `valuesMap` is provided to the tester)
- `actualArray` (available when `expectedArray` is provided to the tester)
- `actualMap` (available when `expectedMap` is provided to the tester)

While both `expectedArray` and `expectedMap` are in scope during the execution of `script`, they *must not* be accessed or modified from within `script`.

`valuesArray` (array of string-like values, optional)

: An array of string-like values.
This array may be used within `script`.

`valuesMap` (attribute set of string-like values, optional)

: An attribute set of string-like values.
This attribute set may be used within `script`.

`expectedArray` (array of string-like values, optional)

: An array of string-like values.
This array *must not* be accessed or modified from within `script`.
When provided, `script` is expected to populate `actualArray`.

`expectedMap` (attribute set of string-like values, optional)

: An attribute set of string-like values.
This attribute set *must not* be accessed or modified from within `script`.
When provided, `script` is expected to populate `actualMap`.

### Return value {#tester-testEqualArrayOrMap-return}

The tester produces an empty output and only succeeds when `expectedArray` and `expectedMap` match `actualArray` and `actualMap`, respectively, when non-null.
The build log will contain differences encountered.

## `testEqualDerivation` {#tester-testEqualDerivation}

Checks that two packages produce the exact same build instructions.
Expand Down
27 changes: 24 additions & 3 deletions doc/redirects.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,15 @@
"ex-build-helpers-extendMkDerivation": [
"index.html#ex-build-helpers-extendMkDerivation"
],
"ex-shfmt": [
"index.html#ex-shfmt"
],
"ex-testBuildFailurePrime-doc-example": [
"index.html#ex-testBuildFailurePrime-doc-example"
],
"ex-testEqualArrayOrMap-test-function-add-cowbell": [
"index.html#ex-testEqualArrayOrMap-test-function-add-cowbell"
],
"neovim": [
"index.html#neovim"
],
Expand Down Expand Up @@ -335,6 +341,15 @@
"footnote-stdenv-find-inputs-location.__back.0": [
"index.html#footnote-stdenv-find-inputs-location.__back.0"
],
"tester-shfmt": [
"index.html#tester-shfmt"
],
"tester-shfmt-inputs": [
"index.html#tester-shfmt-inputs"
],
"tester-shfmt-return": [
"index.html#tester-shfmt-return"
],
"tester-testBuildFailurePrime": [
"index.html#tester-testBuildFailurePrime"
],
Expand All @@ -344,6 +359,15 @@
"tester-testBuildFailurePrime-return": [
"index.html#tester-testBuildFailurePrime-return"
],
"tester-testEqualArrayOrMap": [
"index.html#tester-testEqualArrayOrMap"
],
"tester-testEqualArrayOrMap-inputs": [
"index.html#tester-testEqualArrayOrMap-inputs"
],
"tester-testEqualArrayOrMap-return": [
"index.html#tester-testEqualArrayOrMap-return"
],
"variables-specifying-dependencies": [
"index.html#variables-specifying-dependencies"
],
Expand Down Expand Up @@ -1533,9 +1557,6 @@
"tester-shellcheck-inputs": [
"index.html#tester-shellcheck-inputs"
],
"tester-shellcheck-param-src": [
"index.html#tester-shellcheck-param-src"
],
"tester-shellcheck-return": [
"index.html#tester-shellcheck-return"
],
Expand Down
19 changes: 19 additions & 0 deletions doc/release-notes/rl-2505.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,23 @@

<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->

- `services.rippled` has been removed, as `rippled` was broken and had not been updated since 2022.

- `services.rippleDataApi` has been removed, as `ripple-data-api` was broken and had not been updated since 2022.

- `squid` has been updated to version 7, this release includes multiple breaking changes, like ESI removal.
For more information, [check the release notes](https://github.com/squid-cache/squid/releases/tag/SQUID_7_0_1).

- The [`no-broken-symlinks` hook](https://nixos.org/manual/nixpkgs/unstable/#no-broken-symlinks.sh) was added to catch builds containing dangling or reflexive symlinks, as these are indicative of problems with packaging.
The hook can be disabled by providing `dontCheckForBrokenSymlinks = true;` as an argument to `mkDerivation`.
For more information, [check the docs](https://nixos.org/manual/nixpkgs/unstable/#no-broken-symlinks.sh) or [see this PR](https://github.com/NixOS/nixpkgs/pull/370750).

- The hand written `perlPackages.SearchXapian` bindings have been dropped in favor of the (mostly compatible)
`perlPackages.Xapian`.

- [testers.shellcheck](https://nixos.org/manual/nixpkgs/unstable/#tester-shellcheck) now warns when `name` is not provided.
The `name` argument will become mandatory in a future release.

- The `nixLog*` family of functions made available through the standard environment have been rewritten to prefix messages with both the debug level and the function name of the caller.
The `nixLog` function, which logs unconditionally, was also re-introduced and modified to prefix messages with the function name of the caller.
For more information, [see this PR](https://github.com/NixOS/nixpkgs/pull/370742).
Expand All @@ -19,6 +29,15 @@
It should generally be replaced with `rustPlatform.fetchCargoVendor`, but `rustPlatform.importCargoLock` may also be appropriate in some circumstances.
`rustPlatform.buildRustPackage` users must set `useFetchCargoVendor` to `true` and regenerate the `cargoHash`.

- NetBox was updated to `>= 4.2.0`. Have a look at the breaking changes
of the [4.1 release](https://github.com/netbox-community/netbox/releases/tag/v4.1.0)
and the [4.2 release](https://github.com/netbox-community/netbox/releases/tag/v4.2.0),
make the required changes to your database, if needed, then upgrade by setting `services.netbox.package = pkgs.netbox_4_2;` in your configuration.

- NetBox version 4.0.X available as `netbox_4_0` was removed. Please upgrade to `4.2`.

- `i3status-rust`-package no longer enables `notmuch` by default. It can be enabled via `withNotmuch`.

- Default ICU version updated from 74 to 76

<!-- To avoid merge conflicts, consider adding your item at an arbitrary place in the list instead. -->
Expand Down
Loading

0 comments on commit 8e1e635

Please sign in to comment.