diff --git a/lib/modules.nix b/lib/modules.nix index 61964d46678116e..dd58de08255ff90 100644 --- a/lib/modules.nix +++ b/lib/modules.nix @@ -744,6 +744,9 @@ let t' = opt.options.type; mergedType = t.typeMerge t'.functor; typesMergeable = mergedType != null; + applySet = if (bothHave "apply") + then { apply = value: opt.options.apply (res.apply value); } + else {}; typeSet = if (bothHave "type") && typesMergeable then { type = mergedType; } else {}; @@ -752,7 +755,6 @@ let if bothHave "default" || bothHave "example" || bothHave "description" || - bothHave "apply" || (bothHave "type" && (! typesMergeable)) then throw "The option `${showOption loc}' in `${opt._file}' is already declared in ${showFiles res.declarations}." @@ -772,7 +774,7 @@ let then [opt.pos] else [{ file = opt._file; line = null; column = null; }]); options = submodules; - } // typeSet + } // applySet // typeSet ) { inherit loc; declarations = []; declarationPositions = []; options = []; } opts; /* Merge all the definitions of an option to produce the final diff --git a/nixos/doc/manual/release-notes/rl-2405.section.md b/nixos/doc/manual/release-notes/rl-2405.section.md index 858f1d2a61382b8..9637c80f652e47e 100644 --- a/nixos/doc/manual/release-notes/rl-2405.section.md +++ b/nixos/doc/manual/release-notes/rl-2405.section.md @@ -407,6 +407,8 @@ The pre-existing [services.ankisyncd](#opt-services.ankisyncd.enable) has been m - A stdenv's default set of hardening flags can now be set via its `bintools-wrapper`'s `defaultHardeningFlags` argument. A convenient stdenv adapter, `withDefaultHardeningFlags`, can be used to override an existing stdenv's `defaultHardeningFlags`. +- The `apply` function passed to `mkOption` is now mergeable. This allows for accessing the previous value of the option, similar to the `prev`/`super` argument in `overlays`, `override` and `overrideAttrs`. + - `libass` now uses the native CoreText backend on Darwin, which may fix subtitle rendering issues with `mpv`, `ffmpeg`, etc. - [Lilypond](https://lilypond.org/index.html) and [Denemo](https://www.denemo.org) are now compiled with Guile 3.0.