Loading lib/modules/env.nix +26 −15 Original line number Diff line number Diff line Loading @@ -4,7 +4,18 @@ config, ... }: let inherit (lib) filter assertMsg head length escapeShellArg types mkOption concatStringsSep; inherit (lib) filter filterAttrs assertMsg head length escapeShellArg types mkOption concatStringsSep ; envToBash = { name, Loading Loading @@ -37,7 +48,11 @@ then ''unset ${name}'' else throw "[devshell] BUG in the env module. This should never be reached."; envType = types.submodule ({name, ...}: { envType = types.submodule ({ config, name, ... }: { options = { name = mkOption { type = types.str; Loading @@ -46,7 +61,7 @@ Name of the environment variable, usually already set to `<name>`. ''; }; desc = mkOption { description = mkOption { type = types.nullOr types.str; default = null; description = '' Loading @@ -55,7 +70,7 @@ }; visible = mkOption { type = types.bool; default = true; default = config.description != null; description = '' Whether to include this env var and it's description in the menu. ''; Loading Loading @@ -120,16 +135,12 @@ in { env = { "XDG_DATA_DIRS".eval = "$DEVSHELL_DIR/share:\${XDG_DATA_DIRS-}"; }; enterShellCommands."env".text = concatStringsSep "\n" (map envToBash (builtins.attrValues config.env)); # TODO: collect all env vars, then add them to the menu if they have a description and "visibile == true" meta = { sections."Environment Variables".color = "red"; entries."XDG_DATA_DIRS" = { description = "Hello world"; enterShellCommands."env".text = concatStringsSep "\n" (map envToBash (builtins.attrValues config.env)); # meta entries for the menu meta.entries = builtins.mapAttrs (_name: env: { inherit (env) description; section = "Environment Variables"; subEntries."Usage" = "hello world"; }; }; }) (filterAttrs (_name: env: env.visible) config.env); }; } Loading
lib/modules/env.nix +26 −15 Original line number Diff line number Diff line Loading @@ -4,7 +4,18 @@ config, ... }: let inherit (lib) filter assertMsg head length escapeShellArg types mkOption concatStringsSep; inherit (lib) filter filterAttrs assertMsg head length escapeShellArg types mkOption concatStringsSep ; envToBash = { name, Loading Loading @@ -37,7 +48,11 @@ then ''unset ${name}'' else throw "[devshell] BUG in the env module. This should never be reached."; envType = types.submodule ({name, ...}: { envType = types.submodule ({ config, name, ... }: { options = { name = mkOption { type = types.str; Loading @@ -46,7 +61,7 @@ Name of the environment variable, usually already set to `<name>`. ''; }; desc = mkOption { description = mkOption { type = types.nullOr types.str; default = null; description = '' Loading @@ -55,7 +70,7 @@ }; visible = mkOption { type = types.bool; default = true; default = config.description != null; description = '' Whether to include this env var and it's description in the menu. ''; Loading Loading @@ -120,16 +135,12 @@ in { env = { "XDG_DATA_DIRS".eval = "$DEVSHELL_DIR/share:\${XDG_DATA_DIRS-}"; }; enterShellCommands."env".text = concatStringsSep "\n" (map envToBash (builtins.attrValues config.env)); # TODO: collect all env vars, then add them to the menu if they have a description and "visibile == true" meta = { sections."Environment Variables".color = "red"; entries."XDG_DATA_DIRS" = { description = "Hello world"; enterShellCommands."env".text = concatStringsSep "\n" (map envToBash (builtins.attrValues config.env)); # meta entries for the menu meta.entries = builtins.mapAttrs (_name: env: { inherit (env) description; section = "Environment Variables"; subEntries."Usage" = "hello world"; }; }; }) (filterAttrs (_name: env: env.visible) config.env); }; }