From f8225c39df4421cc40726adbd57ffebf94126c65 Mon Sep 17 00:00:00 2001 From: Gavin John Date: Fri, 18 Jul 2025 10:41:20 -0400 Subject: [PATCH] nixos/comma: init Fixes https://github.com/NixOS/nixpkgs/issues/426379 --- nixos/modules/module-list.nix | 1 + nixos/modules/programs/comma.nix | 52 ++++++++++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 nixos/modules/programs/comma.nix diff --git a/nixos/modules/module-list.nix b/nixos/modules/module-list.nix index 692b4462c928..9ded7df50ebf 100644 --- a/nixos/modules/module-list.nix +++ b/nixos/modules/module-list.nix @@ -193,6 +193,7 @@ ./programs/chrysalis.nix ./programs/clash-verge.nix ./programs/cnping.nix + ./programs/comma.nix ./programs/command-not-found/command-not-found.nix ./programs/coolercontrol.nix ./programs/corefreq.nix diff --git a/nixos/modules/programs/comma.nix b/nixos/modules/programs/comma.nix new file mode 100644 index 000000000000..89fa20fd4812 --- /dev/null +++ b/nixos/modules/programs/comma.nix @@ -0,0 +1,52 @@ +{ + lib, + config, + pkgs, + ... +}: + +let + cfg = config.programs.comma; +in +{ + options.programs.comma = { + enable = lib.mkEnableOption "comma"; + package = lib.mkPackageOption pkgs "comma" { }; + enableBashIntegration = lib.mkEnableOption "comma command-not-found handler for bash" // { + default = true; + }; + enableZshIntegration = lib.mkEnableOption "comma command-not-found handler for zsh" // { + default = true; + }; + enableFishIntegration = lib.mkEnableOption "comma command-not-found handler for fish" // { + default = true; + }; + }; + + config = lib.mkIf cfg.enable { + environment.systemPackages = [ cfg.package ]; + programs = { + bash.interactiveShellInit = lib.mkIf cfg.enableBashIntegration '' + source ${cfg.package}/share/comma/command-not-found.sh + ''; + zsh.interactiveShellInit = lib.mkIf cfg.enableZshIntegration '' + source ${cfg.package}/share/comma/command-not-found.sh + ''; + fish.interactiveShellInit = '' + source ${cfg.package}/share/comma/command-not-found.fish + ''; + + # Disable *other* command-not-found handlers + command-not-found.enable = lib.mkIf ( + cfg.enableBashIntegration || cfg.enableZshIntegration || cfg.enableFishIntegration + ) (lib.mkDefault false); + nix-index = { + enableBashIntegration = lib.mkIf (cfg.enableBashIntegration) (lib.mkDefault false); + enableZshIntegration = lib.mkIf (cfg.enableZshIntegration) (lib.mkDefault false); + enableFishIntegration = lib.mkIf (cfg.enableFishIntegration) (lib.mkDefault false); + }; + }; + }; + + meta.maintainers = with lib.maintainers; [ pandapip1 ]; +}