diff --git a/modules/programs/kitty.nix b/modules/programs/kitty.nix index b54fd4b74..53f7c9fc1 100644 --- a/modules/programs/kitty.nix +++ b/modules/programs/kitty.nix @@ -1,29 +1,30 @@ { config, lib, pkgs, ... }: - -with lib; - let + inherit (lib) + literalExpression mkEnableOption mkIf mkOption optionalString types; + cfg = config.programs.kitty; settingsValueType = with types; oneOf [ str bool int float ]; optionalPackage = opt: - optional (opt != null && opt.package != null) opt.package; + lib.optional (opt != null && opt.package != null) opt.package; - toKittyConfig = generators.toKeyValue { + toKittyConfig = lib.generators.toKeyValue { mkKeyValue = key: value: let value' = - (if isBool value then lib.hm.booleans.yesNo else toString) value; + (if lib.isBool value then lib.hm.booleans.yesNo else toString) value; in "${key} ${value'}"; }; - toKittyKeybindings = generators.toKeyValue { + toKittyKeybindings = lib.generators.toKeyValue { mkKeyValue = key: command: "map ${key} ${command}"; }; - toKittyEnv = - generators.toKeyValue { mkKeyValue = name: value: "env ${name}=${value}"; }; + toKittyEnv = lib.generators.toKeyValue { + mkKeyValue = name: value: "env ${name}=${value}"; + }; shellIntegrationInit = { bash = '' @@ -50,28 +51,29 @@ let }; shellIntegrationDefaultOpt = { - default = !(elem "disabled" (splitString " " cfg.shellIntegration.mode)); + default = + !(lib.elem "disabled" (lib.splitString " " cfg.shellIntegration.mode)); defaultText = literalExpression '' !(elem "disabled" (splitString " " config.programs.kitty.shellIntegration.mode)) ''; }; in { imports = [ - (mkChangedOptionModule [ "programs" "kitty" "theme" ] [ + (lib.mkChangedOptionModule [ "programs" "kitty" "theme" ] [ "programs" "kitty" "themeFile" ] (config: - let value = getAttrFromPath [ "programs" "kitty" "theme" ] config; + let value = lib.getAttrFromPath [ "programs" "kitty" "theme" ] config; in if value != null then (let - matching = filter (x: x.name == value) (builtins.fromJSON + matching = lib.filter (x: x.name == value) (builtins.fromJSON (builtins.readFile "${pkgs.kitty-themes}/share/kitty-themes/themes.json")); - in throwIf (length matching == 0) + in lib.throwIf (lib.length matching == 0) "kitty-themes does not contain a theme named ${value}" - strings.removeSuffix ".conf" - (strings.removePrefix "themes/" (head matching).file)) + lib.strings.removeSuffix ".conf" + (lib.strings.removePrefix "themes/" (lib.head matching).file)) else null)) ]; @@ -134,7 +136,7 @@ in { }; font = mkOption { - type = types.nullOr hm.types.fontType; + type = types.nullOr lib.hm.types.fontType; default = null; description = "The font to use."; }; @@ -169,9 +171,10 @@ in { example = "no-cursor"; apply = o: let - modes = splitString " " o; - filtered = filter (m: m != "no-rc") modes; - in concatStringsSep " " (concatLists [ [ "no-rc" ] filtered ]); + modes = lib.splitString " " o; + filtered = lib.filter (m: m != "no-rc") modes; + in lib.concatStringsSep " " + (lib.concatLists [ [ "no-rc" ] filtered ]); description = '' Set the mode of the shell integration. This accepts the same options as the `shell_integration` option of Kitty. Note that @@ -205,7 +208,7 @@ in { text = '' # Generated by Home Manager. # See https://sw.kovidgoyal.net/kitty/conf.html - '' + concatStringsSep "\n" [ + '' + lib.concatStringsSep "\n" [ (optionalString (cfg.font != null) '' font_family ${cfg.font.name} ${optionalString (cfg.font.size != null) @@ -224,7 +227,7 @@ in { (toKittyEnv cfg.environment) cfg.extraConfig ]; - } // optionalAttrs pkgs.stdenv.hostPlatform.isLinux { + } // lib.optionalAttrs pkgs.stdenv.hostPlatform.isLinux { onChange = '' ${pkgs.procps}/bin/pkill -USR1 -u $USER kitty || true ''; @@ -233,7 +236,7 @@ in { home.activation.checkKittyTheme = mkIf (cfg.themeFile != null) (let themePath = "${pkgs.kitty-themes}/share/kitty-themes/themes/${cfg.themeFile}.conf"; - in hm.dag.entryBefore [ "writeBoundary" ] '' + in lib.hm.dag.entryBefore [ "writeBoundary" ] '' if [[ ! -f "${themePath}" ]]; then errorEcho "kitty-themes does not contain the theme file ${themePath}!" exit 1 @@ -242,7 +245,7 @@ in { xdg.configFile."kitty/macos-launch-services-cmdline" = mkIf (cfg.darwinLaunchOptions != null && pkgs.stdenv.hostPlatform.isDarwin) { - text = concatStringsSep " " cfg.darwinLaunchOptions; + text = lib.concatStringsSep " " cfg.darwinLaunchOptions; }; programs.bash.initExtra =