2018-01-04 12:21:06 +01:00
|
|
|
{ lib }:
|
|
|
|
|
2025-01-25 23:16:15 +01:00
|
|
|
let
|
|
|
|
|
|
|
|
mkShellIntegrationOption = name:
|
|
|
|
{ config, baseName ? name, extraDescription ? "" }:
|
|
|
|
let attrName = "enable${baseName}Integration";
|
|
|
|
in lib.mkOption {
|
|
|
|
default = config.home.shell.${attrName};
|
|
|
|
defaultText = lib.literalMD "[](#opt-home.shell.${attrName})";
|
|
|
|
example = false;
|
|
|
|
description = "Whether to enable ${name} integration.${
|
|
|
|
lib.optionalString (extraDescription != "")
|
|
|
|
("\n\n" + extraDescription)
|
|
|
|
}";
|
|
|
|
type = lib.types.bool;
|
|
|
|
};
|
|
|
|
|
|
|
|
in rec {
|
2018-01-04 12:21:06 +01:00
|
|
|
# Produces a Bourne shell like variable export statement.
|
2020-02-02 00:39:17 +01:00
|
|
|
export = n: v: ''export ${n}="${toString v}"'';
|
2018-01-04 12:21:06 +01:00
|
|
|
|
|
|
|
# Given an attribute set containing shell variable names and their
|
|
|
|
# assignment, this function produces a string containing an export
|
|
|
|
# statement for each set entry.
|
|
|
|
exportAll = vars: lib.concatStringsSep "\n" (lib.mapAttrsToList export vars);
|
2025-01-25 23:16:15 +01:00
|
|
|
|
|
|
|
mkBashIntegrationOption = mkShellIntegrationOption "Bash";
|
|
|
|
mkFishIntegrationOption = mkShellIntegrationOption "Fish";
|
|
|
|
mkIonIntegrationOption = mkShellIntegrationOption "Ion";
|
|
|
|
mkNushellIntegrationOption = mkShellIntegrationOption "Nushell";
|
|
|
|
mkZshIntegrationOption = mkShellIntegrationOption "Zsh";
|
2018-01-04 12:21:06 +01:00
|
|
|
}
|