From 6ea5b5374ef7c170b1ad253909432dc26e549638 Mon Sep 17 00:00:00 2001 From: Felix Stupp Date: Mon, 26 Aug 2024 00:02:12 +0000 Subject: [PATCH] hmModules/assertions: add "/share/zsh" assert from comment --- nix/hmModules/assertions/default.nix | 1 + nix/hmModules/assertions/zsh.nix | 24 ++++++++++++++++++++++++ nix/nixos-modules/frontend/default.nix | 2 +- 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 nix/hmModules/assertions/zsh.nix diff --git a/nix/hmModules/assertions/default.nix b/nix/hmModules/assertions/default.nix index 865a24e..77b85b4 100644 --- a/nix/hmModules/assertions/default.nix +++ b/nix/hmModules/assertions/default.nix @@ -2,5 +2,6 @@ imports = [ # files ./gpg-agent.nix + ./zsh.nix ]; } diff --git a/nix/hmModules/assertions/zsh.nix b/nix/hmModules/assertions/zsh.nix new file mode 100644 index 0000000..d5711f8 --- /dev/null +++ b/nix/hmModules/assertions/zsh.nix @@ -0,0 +1,24 @@ +{ + config, + lib, + osConfig ? null, + ... +}: +let + cfg = config.programs.zsh; +in +{ + config = lib.mkIf cfg.enable { + + assertions = lib.mkIf (!builtins.isNull osConfig) [ + # see https://github.com/nix-community/home-manager/blob/e1391fb22e18a36f57e6999c7a9f966dc80ac073/modules/programs/zsh.nix#L353 + { + assertion = cfg.enableCompletion -> builtins.elem "/share/zsh" osConfig.environment.pathsToLink; + message = '' + for useful ZSH completion, add "/share/zsh" to NixOS environment.pathsToLink + ''; + } + ]; + + }; +} diff --git a/nix/nixos-modules/frontend/default.nix b/nix/nixos-modules/frontend/default.nix index b1c5744..447da98 100644 --- a/nix/nixos-modules/frontend/default.nix +++ b/nix/nixos-modules/frontend/default.nix @@ -38,7 +38,7 @@ in environment = { pathsToLink = [ - "/share/zsh" # required for Home-Manager ZSH autocompletion, see https://github.com/nix-community/home-manager/blob/e1391fb22e18a36f57e6999c7a9f966dc80ac073/modules/programs/zsh.nix#L353 + "/share/zsh" # for ZSH completion ]; plasma6.excludePackages = with pkgs.kdePackages; [