Skip to content

Commit

Permalink
modules: make apply mergeable
Browse files Browse the repository at this point in the history
  • Loading branch information
Atry committed Apr 4, 2024
1 parent ae8f15a commit c5702a7
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
6 changes: 4 additions & 2 deletions lib/modules.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 {};
Expand All @@ -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}."
Expand All @@ -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
Expand Down
2 changes: 2 additions & 0 deletions nixos/doc/manual/release-notes/rl-2405.section.md
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down

0 comments on commit c5702a7

Please sign in to comment.