From 297aa6d0a28c3ade20e669c08e7d5f6a3f519782 Mon Sep 17 00:00:00 2001 From: Matt Sturgeon Date: Fri, 31 May 2024 17:28:31 +0100 Subject: [PATCH] lib/options: make `mkPackageOption` use `mkNullOrOption'` --- lib/options.nix | 34 ++++++++++++++++++---------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/lib/options.nix b/lib/options.nix index b1152eacf0..6e8d5cd965 100644 --- a/lib/options.nix +++ b/lib/options.nix @@ -248,23 +248,25 @@ rec { mkPackageOption = { - name ? null, # Can be null if a custom description is given. - default, + name ? null, # Can be omitted if a custom description is given. description ? null, - example ? null, - }: - mkOption { - type = with types; nullOr package; - inherit default example; - description = - if description == null then - '' - Which package to use for `${name}`. - Set to `null` to disable its automatic installation. - '' - else - description; - }; + default, # `default` is not optional + ... + }@args: + mkNullOrOption' ( + (filterAttrs (n: _: n != "name") args) + // { + type = types.package; + description = + if description == null then + '' + Which package to use for `${name}`. + Set to `null` to disable its automatic installation. + '' + else + description; + } + ); mkPluginPackageOption = name: default: