From a983d4e779dcd0fa05e5d227233cdd29702e7e89 Mon Sep 17 00:00:00 2001 From: polykernel <81340136+polykernel@users.noreply.github.com> Date: Sun, 31 Oct 2021 22:14:45 -0400 Subject: [PATCH] fuzzel: refactor configure options The current configure options exposed emulates the `choices` type of the SVG and PNG backends from upstream meson_options with a freeform string, however this is error prone and require accompanying validation which unnecessarily complicates the derivation. Two alternatives were considered: 1. Splits the possible choices into separate options nad perform assertions to ensure only one is selected. 2. Expose a set of sane default configure options, and structure the derivation around this subset. Users who wish to customize the choice used can do so using `override` or `overrideAttrs`. Option 1 is not sustainable for large amounts of options which require large amount of assertions just for ensuring uniqueness of selection, and adds complexity to the configure phase. Option 2 minimally impairs the customizablity of the derivation and was chosen in part to address option checking[1]. [1] - https://github.com/NixOS/nixpkgs/pull/141836#discussion_r739910095 --- pkgs/applications/misc/fuzzel/default.nix | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/pkgs/applications/misc/fuzzel/default.nix b/pkgs/applications/misc/fuzzel/default.nix index d697e8412adc..b187dcc0e8c6 100644 --- a/pkgs/applications/misc/fuzzel/default.nix +++ b/pkgs/applications/misc/fuzzel/default.nix @@ -13,14 +13,16 @@ , tllist , fcft , enableCairo ? true -, withPNGBackend ? "libpng" -, withSVGBackend ? "librsvg" - # Optional dependencies +, svgSupport ? true +, pngSupport ? true +# Optional dependencies , cairo , librsvg , libpng }: +assert svgSupport -> enableCairo; + stdenv.mkDerivation rec { pname = "fuzzel"; version = "1.7.0"; @@ -49,15 +51,15 @@ stdenv.mkDerivation rec { tllist fcft ] ++ lib.optional enableCairo cairo - ++ lib.optional (withPNGBackend == "libpng") libpng - ++ lib.optional (withSVGBackend == "librsvg") librsvg; + ++ lib.optional pngSupport libpng + ++ lib.optional svgSupport librsvg; mesonBuildType = "release"; mesonFlags = [ "-Denable-cairo=${if enableCairo then "enabled" else "disabled"}" - "-Dpng-backend=${withPNGBackend}" - "-Dsvg-backend=${withSVGBackend}" + "-Dpng-backend=${if pngSupport then "libpng" else "none"}" + "-Dsvg-backend=${if svgSupport then "librsvg" else "none"}" ]; CFLAGS = "-Wno-error=comment"; # https://gitlab.gnome.org/GNOME/librsvg/-/issues/856