From 3c71af1950b87b803618feeee3d93ff1de6fe974 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jalil=20David=20Salam=C3=A9=20Messina?= Date: Sun, 18 Feb 2024 16:46:31 +0100 Subject: [PATCH] feat(docs): Improve package options defaultText --- home/options.nix | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/home/options.nix b/home/options.nix index 9c18946..1afdcd1 100644 --- a/home/options.nix +++ b/home/options.nix @@ -2,12 +2,18 @@ let inherit (lib) types; - mkExtraPackagesOption = name: default: lib.mkOption { - description = "Extra ${name} Packages."; - type = types.listOf types.package; - inherit default; - example = [ ]; - }; + mkExtraPackagesOption = name: defaultPkgsPath: + let + text = lib.strings.concatMapStringsSep " " (pkgPath: "pkgs." + (lib.strings.concatStringsSep "." pkgPath)) defaultPkgsPath; + defaultText = lib.literalExpression "[ ${text} ]"; + default = builtins.map (pkgPath: lib.attrsets.getAttrFromPath pkgPath pkgs) defaultPkgsPath; + in + lib.mkOption { + description = "Extra ${name} Packages."; + type = types.listOf types.package; + inherit default defaultText; + example = [ ]; + }; identity.options = { email = lib.mkOption { @@ -141,13 +147,13 @@ in description = lib.mdDoc "Setup development environment for programming languages."; default = { }; type = types.submodule { - options.extraPackages = mkExtraPackagesOption "dev" [ pkgs.typos pkgs.just ]; + options.extraPackages = mkExtraPackagesOption "dev" [ [ "typos" ] [ "just" ] ]; options.rust = lib.mkOption { description = "Jalil's default rust configuration."; default = { }; type = types.submodule { options.enable = lib.mkEnableOption "rust dev environment"; - options.extraPackages = mkExtraPackagesOption "Rust" [ pkgs.cargo-nextest pkgs.cargo-sort pkgs.cargo-msrv pkgs.cargo-kcov pkgs.cargo-watch ]; + options.extraPackages = mkExtraPackagesOption "Rust" [ [ "cargo-nextest" ] [ "cargo-sort" ] [ "cargo-msrv" ] [ "cargo-kcov" ] [ "cargo-watch" ] ]; }; }; };