summaryrefslogtreecommitdiff
path: root/modules/programs
diff options
context:
space:
mode:
authorMike Vink <59492084+ivi-vink@users.noreply.github.com>2025-01-16 22:22:34 +0100
committerGitHub <noreply@github.com>2025-01-16 22:22:34 +0100
commit8e7bd91f353caacc0bc4105f573eb3e17f09e03a (patch)
treec5059edcbebd9644290cad7c653c49a36d593021 /modules/programs
parent6bd39d420578aacf7c0bab7de3e7027b952115ae (diff)
parentbd921223ba7cdac346477d7ea5204d6f4736fcc6 (diff)
Merge branch 'LnL7:master' into masterHEADmaster
Diffstat (limited to 'modules/programs')
-rw-r--r--modules/programs/bash/default.nix37
-rw-r--r--modules/programs/direnv.nix20
-rw-r--r--modules/programs/fish.nix28
-rw-r--r--modules/programs/gnupg.nix6
-rw-r--r--modules/programs/info/default.nix4
-rw-r--r--modules/programs/man.nix2
-rw-r--r--modules/programs/nix-index/default.nix4
-rw-r--r--modules/programs/ssh/default.nix63
-rw-r--r--modules/programs/tmux.nix26
-rw-r--r--modules/programs/vim.nix10
-rw-r--r--modules/programs/zsh/default.nix73
11 files changed, 145 insertions, 128 deletions
diff --git a/modules/programs/bash/default.nix b/modules/programs/bash/default.nix
index 61f82e0..2518c9c 100644
--- a/modules/programs/bash/default.nix
+++ b/modules/programs/bash/default.nix
@@ -7,28 +7,36 @@ let
in
{
+ imports = [
+ (mkRenamedOptionModule [ "programs" "bash" "enableCompletion" ] [ "programs" "bash" "completion" "enable" ])
+ ];
+
options = {
programs.bash.enable = mkOption {
type = types.bool;
default = true;
- description = lib.mdDoc "Whether to configure bash as an interactive shell.";
+ description = "Whether to configure bash as an interactive shell.";
};
programs.bash.interactiveShellInit = mkOption {
default = "";
- description = lib.mdDoc "Shell script code called during interactive bash shell initialisation.";
+ description = "Shell script code called during interactive bash shell initialisation.";
type = types.lines;
};
- programs.bash.enableCompletion = mkOption {
- type = types.bool;
- default = false;
- description = lib.mdDoc ''
- Enable bash completion for all interactive bash shells.
+ programs.bash.completion = {
+ enable = mkOption {
+ type = types.bool;
+ default = false;
+ description = ''
+ Enable bash completion for all interactive bash shells.
- NOTE. This doesn't work with bash 3.2, which is the default on macOS.
- '';
+ NOTE: This doesn't work with bash 3.2, which is installed by default on macOS by Apple.
+ '';
+ };
+
+ package = mkPackageOption pkgs "bash-completion" { };
};
};
@@ -38,9 +46,9 @@ in
environment.systemPackages =
[ # Include bash package
pkgs.bashInteractive
- ] ++ optional cfg.enableCompletion pkgs.bash-completion;
+ ] ++ optional cfg.completion.enable cfg.completion.package;
- environment.pathsToLink =
+ environment.pathsToLink = optionals cfg.completion.enable
[ "/etc/bash_completion.d"
"/share/bash-completion/completions"
];
@@ -55,9 +63,6 @@ in
if [ -n "$__ETC_BASHRC_SOURCED" -o -n "$NOSYSBASHRC" ]; then return; fi
__ETC_BASHRC_SOURCED=1
- # Don't execute this file when running in a pure nix-shell.
- if [ "$IN_NIX_SHELL" = "pure" ]; then return; fi
-
if [ -z "$__NIX_DARWIN_SET_ENVIRONMENT_DONE" ]; then
. ${config.system.build.setEnvironment}
fi
@@ -73,9 +78,9 @@ in
${config.environment.interactiveShellInit}
${cfg.interactiveShellInit}
- ${optionalString cfg.enableCompletion ''
+ ${optionalString cfg.completion.enable ''
if [ "$TERM" != "dumb" ]; then
- source "${pkgs.bash-completion}/etc/profile.d/bash_completion.sh"
+ source "${cfg.completion.package}/etc/profile.d/bash_completion.sh"
nullglobStatus=$(shopt -p nullglob)
shopt -s nullglob
diff --git a/modules/programs/direnv.nix b/modules/programs/direnv.nix
index 648b3f9..533fc8e 100644
--- a/modules/programs/direnv.nix
+++ b/modules/programs/direnv.nix
@@ -11,13 +11,13 @@ in {
];
options.programs.direnv = {
- enable = lib.mkEnableOption (lib.mdDoc ''
+ enable = lib.mkEnableOption ''
direnv integration. Takes care of both installation and
setting up the sourcing of the shell. Additionally enables nix-direnv
integration.
- '');
+ '';
- package = lib.mkPackageOptionMD pkgs "direnv" {};
+ package = lib.mkPackageOption pkgs "direnv" {};
direnvrcExtra = lib.mkOption {
type = lib.types.lines;
@@ -26,17 +26,17 @@ in {
export FOO="foo"
echo "loaded direnv!"
'';
- description = lib.mdDoc ''
+ description = ''
Extra lines to append to the sourced direnvrc
'';
};
- silent = lib.mkEnableOption (lib.mdDoc ''
+ silent = lib.mkEnableOption ''
the hiding of direnv logging
- '');
+ '';
loadInNixShell =
- lib.mkEnableOption (lib.mdDoc ''
+ (lib.mkEnableOption ''
loading direnv in `nix-shell` `nix shell` or `nix develop`
'')
// {
@@ -45,14 +45,14 @@ in {
nix-direnv = {
enable =
- (lib.mkEnableOption (lib.mdDoc ''
+ (lib.mkEnableOption ''
a faster, persistent implementation of use_nix and use_flake, to replace the built-in one
- ''))
+ '')
// {
default = true;
};
- package = lib.mkPackageOptionMD pkgs "nix-direnv" {};
+ package = lib.mkPackageOption pkgs "nix-direnv" {};
};
};
diff --git a/modules/programs/fish.nix b/modules/programs/fish.nix
index 287cc71..65797cc 100644
--- a/modules/programs/fish.nix
+++ b/modules/programs/fish.nix
@@ -9,7 +9,7 @@ let
cfg = config.programs.fish;
fishAliases = concatStringsSep "\n" (
- mapAttrsFlatten (k: v: "alias ${k} ${escapeShellArg v}")
+ mapAttrsToList (k: v: "alias ${k} ${escapeShellArg v}")
(filterAttrs (k: v: v != null) cfg.shellAliases)
);
@@ -51,16 +51,18 @@ in
enable = mkOption {
default = false;
- description = lib.mdDoc ''
+ description = ''
Whether to configure fish as an interactive shell.
'';
type = types.bool;
};
+ package = lib.mkPackageOption pkgs "fish" { };
+
useBabelfish = mkOption {
type = types.bool;
default = false;
- description = lib.mdDoc ''
+ description = ''
If enabled, the configured environment will be translated to native fish using [babelfish](https://github.com/bouk/babelfish).
Otherwise, [foreign-env](https://github.com/oh-my-fish/plugin-foreign-env) will be used.
'';
@@ -69,7 +71,7 @@ in
babelfishPackage = mkOption {
type = types.package;
default = pkgs.babelfish;
- description = lib.mdDoc ''
+ description = ''
The babelfish package to use when useBabelfish is
set to true.
'';
@@ -78,7 +80,7 @@ in
vendor.config.enable = mkOption {
type = types.bool;
default = true;
- description = lib.mdDoc ''
+ description = ''
Whether fish should source configuration snippets provided by other packages.
'';
};
@@ -86,7 +88,7 @@ in
vendor.completions.enable = mkOption {
type = types.bool;
default = true;
- description = lib.mdDoc ''
+ description = ''
Whether fish should use completion files provided by other packages.
'';
};
@@ -94,14 +96,14 @@ in
vendor.functions.enable = mkOption {
type = types.bool;
default = true;
- description = lib.mdDoc ''
+ description = ''
Whether fish should autoload fish functions provided by other packages.
'';
};
shellAliases = mkOption {
default = config.environment.shellAliases;
- description = lib.mdDoc ''
+ description = ''
Set of aliases for fish shell. See {option}`environment.shellAliases`
for an option format description.
'';
@@ -110,7 +112,7 @@ in
shellInit = mkOption {
default = "";
- description = lib.mdDoc ''
+ description = ''
Shell script code called during fish shell initialisation.
'';
type = types.lines;
@@ -118,7 +120,7 @@ in
loginShellInit = mkOption {
default = "";
- description = lib.mdDoc ''
+ description = ''
Shell script code called during fish login shell initialisation.
'';
type = types.lines;
@@ -126,7 +128,7 @@ in
interactiveShellInit = mkOption {
default = "";
- description = lib.mdDoc ''
+ description = ''
Shell script code called during interactive fish shell initialisation.
'';
type = types.lines;
@@ -134,7 +136,7 @@ in
promptInit = mkOption {
default = "";
- description = lib.mdDoc ''
+ description = ''
Shell script code used to initialise fish prompt.
'';
type = types.lines;
@@ -238,7 +240,7 @@ in
++ optional cfg.vendor.functions.enable "/share/fish/vendor_functions.d";
}
- { systemPackages = [ pkgs.fish ]; }
+ { systemPackages = [ cfg.package ]; }
];
};
diff --git a/modules/programs/gnupg.nix b/modules/programs/gnupg.nix
index bd2f96c..6a34e30 100644
--- a/modules/programs/gnupg.nix
+++ b/modules/programs/gnupg.nix
@@ -13,7 +13,7 @@ in
agent.enable = mkOption {
type = types.bool;
default = false;
- description = lib.mdDoc ''
+ description = ''
Enables GnuPG agent for every user session.
'';
};
@@ -21,7 +21,7 @@ in
agent.enableSSHSupport = mkOption {
type = types.bool;
default = false;
- description = lib.mdDoc ''
+ description = ''
Enable SSH agent support in GnuPG agent. Also sets SSH_AUTH_SOCK
environment variable correctly.
'';
@@ -43,7 +43,7 @@ in
'' + (optionalString cfg.agent.enableSSHSupport ''
# SSH agent protocol doesn't support changing TTYs, so bind the agent
# to every new TTY.
- ${pkgs.gnupg}/bin/gpg-connect-agent --quiet updatestartuptty /bye > /dev/null
+ ${pkgs.gnupg}/bin/gpg-connect-agent --quiet updatestartuptty /bye > /dev/null 2>&1
export SSH_AUTH_SOCK=$(${pkgs.gnupg}/bin/gpgconf --list-dirs agent-ssh-socket)
'');
diff --git a/modules/programs/info/default.nix b/modules/programs/info/default.nix
index 93aaf7c..d70e377 100644
--- a/modules/programs/info/default.nix
+++ b/modules/programs/info/default.nix
@@ -11,7 +11,7 @@ in
programs.info.enable = mkOption {
type = types.bool;
default = true;
- description = lib.mdDoc "Whether to enable info pages and the {command}`info` command.";
+ description = "Whether to enable info pages and the {command}`info` command.";
};
};
@@ -22,7 +22,7 @@ in
environment.pathsToLink = [ "/info" "/share/info" ];
environment.extraOutputsToInstall = [ "info" ];
- environment.postBuild = ''
+ environment.extraSetup = ''
if test -w $out/share/info; then
shopt -s nullglob
for i in $out/share/info/*.info $out/share/info/*.info.gz; do
diff --git a/modules/programs/man.nix b/modules/programs/man.nix
index fd0e018..f15485b 100644
--- a/modules/programs/man.nix
+++ b/modules/programs/man.nix
@@ -8,7 +8,7 @@ with lib;
programs.man.enable = mkOption {
type = types.bool;
default = true;
- description = lib.mdDoc ''
+ description = ''
Whether to enable manual pages and the {command}`man` command.
This also includes "man" outputs of all `systemPackages`.
'';
diff --git a/modules/programs/nix-index/default.nix b/modules/programs/nix-index/default.nix
index 0685346..b6f86f5 100644
--- a/modules/programs/nix-index/default.nix
+++ b/modules/programs/nix-index/default.nix
@@ -11,14 +11,14 @@ in
programs.nix-index.enable = mkOption {
type = types.bool;
default = false;
- description = lib.mdDoc "Whether to enable nix-index and its command-not-found helper.";
+ description = "Whether to enable nix-index and its command-not-found helper.";
};
programs.nix-index.package = mkOption {
type = types.package;
default = pkgs.nix-index;
defaultText = "pkgs.nix-index";
- description = lib.mdDoc "This option specifies the nix-index package to use.";
+ description = "This option specifies the nix-index package to use.";
};
};
diff --git a/modules/programs/ssh/default.nix b/modules/programs/ssh/default.nix
index 5fc7415..1e87732 100644
--- a/modules/programs/ssh/default.nix
+++ b/modules/programs/ssh/default.nix
@@ -3,7 +3,7 @@
with lib;
let
- cfg = config.programs.ssh;
+ cfg = config.programs.ssh;
knownHosts = map (h: getAttr h cfg.knownHosts) (attrNames cfg.knownHosts);
@@ -11,10 +11,18 @@ let
{ name, ... }:
{
options = {
+ certAuthority = lib.mkOption {
+ type = lib.types.bool;
+ default = false;
+ description = ''
+ This public key is an SSH certificate authority, rather than an
+ individual host's key.
+ '';
+ };
hostNames = mkOption {
type = types.listOf types.str;
default = [];
- description = lib.mdDoc ''
+ description = ''
A list of host names and/or IP numbers used for accessing
the host's ssh service.
'';
@@ -23,7 +31,7 @@ let
default = null;
type = types.nullOr types.str;
example = "ecdsa-sha2-nistp521 AAAAE2VjZHN...UEPg==";
- description = lib.mdDoc ''
+ description = ''
The public key data for the host. You can fetch a public key
from a running SSH server with the {command}`ssh-keyscan`
command. The public key should not include any host names, only
@@ -33,7 +41,7 @@ let
publicKeyFile = mkOption {
default = null;
type = types.nullOr types.path;
- description = lib.mdDoc ''
+ description = ''
The path to the public key file for the host. The public
key file is read at build time and saved in the Nix store.
You can fetch a public key file from a running SSH server
@@ -54,7 +62,7 @@ let
keys = mkOption {
type = types.listOf types.str;
default = [];
- description = lib.mdDoc ''
+ description = ''
A list of verbatim OpenSSH public keys that should be added to the
user's authorized keys. The keys are added to a file that the SSH
daemon reads in addition to the the user's authorized_keys file.
@@ -68,7 +76,7 @@ let
keyFiles = mkOption {
type = types.listOf types.path;
default = [];
- description = lib.mdDoc ''
+ description = ''
A list of files each containing one OpenSSH public key that should be
added to the user's authorized keys. The contents of the files are
read at build time and added to a file that the SSH daemon reads in
@@ -81,8 +89,7 @@ let
};
authKeysFiles = let
- mkAuthKeyFile = u: nameValuePair "ssh/authorized_keys.d/${u.name}" {
- copy = true;
+ mkAuthKeyFile = u: nameValuePair "ssh/nix_authorized_keys.d/${u.name}" {
text = ''
${concatStringsSep "\n" u.openssh.authorizedKeys.keys}
${concatMapStrings (f: readFile f + "\n") u.openssh.authorizedKeys.keyFiles}
@@ -97,32 +104,29 @@ let
in
{
+ imports = [
+ (mkRemovedOptionModule [ "services" "openssh" "authorizedKeysFiles" ] "No `nix-darwin` equivalent to this NixOS option.")
+ ];
+
options = {
users.users = mkOption {
type = with types; attrsOf (submodule userOptions);
};
- services.openssh.authorizedKeysFiles = mkOption {
- type = types.listOf types.str;
- default = [];
- description = lib.mdDoc ''
- Specify the rules for which files to read on the host.
-
- This is an advanced option. If you're looking to configure user
- keys, you can generally use [](#opt-users.users._name_.openssh.authorizedKeys.keys)
- or [](#opt-users.users._name_.openssh.authorizedKeys.keyFiles).
-
- These are paths relative to the host root file system or home
- directories and they are subject to certain token expansion rules.
- See AuthorizedKeysFile in man sshd_config for details.
+ programs.ssh.extraConfig = lib.mkOption {
+ type = lib.types.lines;
+ default = "";
+ description = ''
+ Extra configuration text loaded in {file}`ssh_config`.
+ See {manpage}`ssh_config(5)` for help.
'';
};
programs.ssh.knownHosts = mkOption {
default = {};
type = types.attrsOf (types.submodule host);
- description = lib.mdDoc ''
+ description = ''
The set of system-wide known SSH hosts.
'';
example = literalExpression ''
@@ -148,25 +152,30 @@ in
message = "knownHost ${name} must contain either a publicKey or publicKeyFile";
});
- services.openssh.authorizedKeysFiles = [ "%h/.ssh/authorized_keys" "/etc/ssh/authorized_keys.d/%u" ];
-
environment.etc = authKeysFiles //
{ "ssh/ssh_known_hosts" = mkIf (builtins.length knownHosts > 0) {
text = (flip (concatMapStringsSep "\n") knownHosts
(h: assert h.hostNames != [];
- concatStringsSep "," h.hostNames + " "
+ lib.optionalString h.certAuthority "@cert-authority " + concatStringsSep "," h.hostNames + " "
+ (if h.publicKey != null then h.publicKey else readFile h.publicKeyFile)
)) + "\n";
};
+ "ssh/ssh_config.d/100-nix-darwin.conf".text = config.programs.ssh.extraConfig;
"ssh/sshd_config.d/101-authorized-keys.conf" = {
- text = "AuthorizedKeysFile ${toString config.services.openssh.authorizedKeysFiles}\n";
+ text = ''
+ # sshd doesn't like reading from symbolic links, so we cat
+ # the file ourselves.
+ AuthorizedKeysCommand /bin/cat /etc/ssh/nix_authorized_keys.d/%u
+ # Just a simple cat, fine to use _sshd.
+ AuthorizedKeysCommandUser _sshd
+ '';
# Allows us to automatically migrate from using a file to a symlink
knownSha256Hashes = [ oldAuthorizedKeysHash ];
};
};
- # Clean up .before-nix-darwin file left over from using knownSha256Hashes
system.activationScripts.etc.text = ''
+ # Clean up .before-nix-darwin file left over from using knownSha256Hashes
auth_keys_orig=/etc/ssh/sshd_config.d/101-authorized-keys.conf.before-nix-darwin
if [ -e "$auth_keys_orig" ] && [ "$(shasum -a 256 $auth_keys_orig | cut -d ' ' -f 1)" = "${oldAuthorizedKeysHash}" ]; then
diff --git a/modules/programs/tmux.nix b/modules/programs/tmux.nix
index 7278479..d70dab1 100644
--- a/modules/programs/tmux.nix
+++ b/modules/programs/tmux.nix
@@ -41,52 +41,48 @@ in
{
imports = [
(mkRenamedOptionModule [ "programs" "tmux" "tmuxConfig" ] [ "programs" "tmux" "extraConfig" ])
+ (mkRemovedOptionModule [ "programs" "tmux" "defaultCommand" ] "Use `programs.tmux.extraConfig` to configure the default command instead. If unset, tmux will default to using your system configured login shell.")
];
options = {
programs.tmux.enable = mkOption {
type = types.bool;
default = false;
- description = lib.mdDoc "Whether to configure tmux.";
+ description = "Whether to configure tmux.";
};
programs.tmux.enableSensible = mkOption {
type = types.bool;
default = false;
example = true;
- description = lib.mdDoc "Enable sensible configuration options for tmux.";
+ description = "Enable sensible configuration options for tmux.";
};
programs.tmux.enableMouse = mkOption {
type = types.bool;
default = false;
example = true;
- description = lib.mdDoc "Enable mouse support for tmux.";
+ description = "Enable mouse support for tmux.";
};
programs.tmux.enableFzf = mkOption {
type = types.bool;
default = false;
example = true;
- description = lib.mdDoc "Enable fzf keybindings for selecting tmux sessions and panes.";
+ description = "Enable fzf keybindings for selecting tmux sessions and panes.";
};
programs.tmux.enableVim = mkOption {
type = types.bool;
default = false;
example = true;
- description = lib.mdDoc "Enable vim style keybindings for copy mode, and navigation of tmux panes.";
+ description = "Enable vim style keybindings for copy mode, and navigation of tmux panes.";
};
programs.tmux.iTerm2 = mkOption {
type = types.bool;
default = false;
example = true;
- description = lib.mdDoc "Cater to iTerm2 and its tmux integration, as appropriate.";
- };
-
- programs.tmux.defaultCommand = mkOption {
- type = types.either types.str types.package;
- description = lib.mdDoc "The default command to use for tmux panes.";
+ description = "Cater to iTerm2 and its tmux integration, as appropriate.";
};
programs.tmux.tmuxOptions = mkOption {
@@ -98,7 +94,7 @@ in
programs.tmux.extraConfig = mkOption {
type = types.lines;
default = "";
- description = lib.mdDoc "Extra configuration to add to {file}`tmux.conf`.";
+ description = "Extra configuration to add to {file}`tmux.conf`.";
};
};
@@ -120,12 +116,6 @@ in
source-file -q /etc/tmux.conf.local
'';
- programs.tmux.defaultCommand = mkDefault config.environment.loginShell;
-
- programs.tmux.tmuxOptions.login-shell.text = ''
- set -g default-command "${cfg.defaultCommand}"
- '';
-
programs.tmux.tmuxOptions.sensible.text = mkIf cfg.enableSensible ''
set -g default-terminal "screen-256color"
setw -g aggressive-resize on
diff --git a/modules/programs/vim.nix b/modules/programs/vim.nix
index d51d0ac..345532e 100644
--- a/modules/programs/vim.nix
+++ b/modules/programs/vim.nix
@@ -18,14 +18,14 @@ in
programs.vim.enable = mkOption {
type = types.bool;
default = false;
- description = lib.mdDoc "Whether to configure vim.";
+ description = "Whether to configure vim.";
};
programs.vim.enableSensible = mkOption {
type = types.bool;
default = false;
example = true;
- description = lib.mdDoc "Enable sensible configuration options for vim.";
+ description = "Enable sensible configuration options for vim.";
};
programs.vim.extraKnownPlugins = mkOption {
@@ -46,14 +46,14 @@ in
};
}
'';
- description = lib.mdDoc "Custom plugin declarations to add to VAM's knownPlugins.";
+ description = "Custom plugin declarations to add to VAM's knownPlugins.";
};
programs.vim.plugins = mkOption {
type = types.listOf types.attrs;
default = [];
example = [ { names = [ "surround" "vim-nix" ]; } ];
- description = lib.mdDoc "VAM plugin dictionaries to use for vim_configurable.";
+ description = "VAM plugin dictionaries to use for vim_configurable.";
};
programs.vim.package = mkOption {
@@ -70,7 +70,7 @@ in
programs.vim.vimConfig = mkOption {
type = types.lines;
default = "";
- description = lib.mdDoc "Extra vimrcConfig to use for vim_configurable.";
+ description = "Extra vimrcConfig to use for vim_configurable.";
};
};
diff --git a/modules/programs/zsh/default.nix b/modules/programs/zsh/default.nix
index cce645c..65689ba 100644
--- a/modules/programs/zsh/default.nix
+++ b/modules/programs/zsh/default.nix
@@ -18,14 +18,14 @@ in
options = {
programs.zsh.enable = mkOption {
type = types.bool;
- default = false;
- description = lib.mdDoc "Whether to configure zsh as an interactive shell.";
+ default = true;
+ description = "Whether to configure zsh as an interactive shell.";
};
programs.zsh.variables = mkOption {
type = types.attrsOf (types.either types.str (types.listOf types.str));
default = {};
- description = lib.mdDoc ''
+ description = ''
A set of environment variables used in the global environment.
These variables will be set on shell initialisation.
The value of each variable can be either a string or a list of
@@ -38,44 +38,44 @@ in
programs.zsh.shellInit = mkOption {
type = types.lines;
default = "";
- description = lib.mdDoc "Shell script code called during zsh shell initialisation.";
+ description = "Shell script code called during zsh shell initialisation.";
};
programs.zsh.loginShellInit = mkOption {
type = types.lines;
default = "";
- description = lib.mdDoc "Shell script code called during zsh login shell initialisation.";
+ description = "Shell script code called during zsh login shell initialisation.";
};
programs.zsh.interactiveShellInit = mkOption {
type = types.lines;
default = "";
- description = lib.mdDoc "Shell script code called during interactive zsh shell initialisation.";
+ description = "Shell script code called during interactive zsh shell initialisation.";
};
programs.zsh.promptInit = mkOption {
type = types.lines;
- default = "autoload -U promptinit && promptinit && prompt walters && setopt prompt_sp";
- description = lib.mdDoc "Shell script code used to initialise the zsh prompt.";
+ default = "autoload -U promptinit && promptinit && prompt suse && setopt prompt_sp";
+ description = "Shell script code used to initialise the zsh prompt.";
};
programs.zsh.enableCompletion = mkOption {
type = types.bool;
default = true;
- description = lib.mdDoc "Enable zsh completion for all interactive zsh shells.";
+ description = "Enable zsh completion for all interactive zsh shells.";
};
programs.zsh.enableBashCompletion = mkOption {
type = types.bool;
default = true;
- description = lib.mdDoc "Enable bash completion for all interactive zsh shells.";
+ description = "Enable bash completion for all interactive zsh shells.";
};
programs.zsh.enableGlobalCompInit = mkOption {
type = types.bool;
default = cfg.enableCompletion;
defaultText = literalExpression "config.${opt.enableCompletion}";
- description = lib.mdDoc ''
+ description = ''
Enable execution of compinit call for all interactive zsh shells.
This option can be disabled if the user wants to extend its
@@ -87,35 +87,44 @@ in
programs.zsh.enableFzfCompletion = mkOption {
type = types.bool;
default = false;
- description = lib.mdDoc "Enable fzf completion.";
+ description = "Enable fzf completion.";
};
programs.zsh.enableFzfGit = mkOption {
type = types.bool;
default = false;
- description = lib.mdDoc "Enable fzf keybindings for C-g git browsing.";
+ description = "Enable fzf keybindings for C-g git browsing.";
};
programs.zsh.enableFzfHistory = mkOption {
type = types.bool;
default = false;
- description = lib.mdDoc "Enable fzf keybinding for Ctrl-r history search.";
+ description = "Enable fzf keybinding for Ctrl-r history search.";
};
programs.zsh.enableSyntaxHighlighting = mkOption {
type = types.bool;
default = false;
- description = lib.mdDoc "Enable zsh-syntax-highlighting.";
+ description = "Enable zsh-syntax-highlighting.";
};
+
+ programs.zsh.enableFastSyntaxHighlighting = mkEnableOption "zsh-fast-syntax-highlighting";
};
config = mkIf cfg.enable {
+ assertions = [
+ {
+ assertion = !(cfg.enableSyntaxHighlighting && cfg.enableFastSyntaxHighlighting);
+ message = "zsh-syntax-highlighting and zsh-fast-syntax-highlighting are mutually exclusive, please disable one of them.";
+ }
+ ];
environment.systemPackages =
[ # Include zsh package
pkgs.zsh
] ++ optional cfg.enableCompletion pkgs.nix-zsh-completions
- ++ optional cfg.enableSyntaxHighlighting pkgs.zsh-syntax-highlighting;
+ ++ optional cfg.enableSyntaxHighlighting pkgs.zsh-syntax-highlighting
+ ++ optional cfg.enableFastSyntaxHighlighting pkgs.zsh-fast-syntax-highlighting;
environment.pathsToLink = [ "/share/zsh" ];
@@ -124,18 +133,21 @@ in
# This file is read for all shells.
# Only execute this file once per shell.
- # But don't clobber the environment of interactive non-login children!
- if [ -n "$__ETC_ZSHENV_SOURCED" ]; then return; fi
- export __ETC_ZSHENV_SOURCED=1
+ if [ -n "''${__ETC_ZSHENV_SOURCED-}" ]; then return; fi
+ __ETC_ZSHENV_SOURCED=1
- # Don't execute this file when running in a pure nix-shell.
- if test -n "$IN_NIX_SHELL"; then return; fi
+ if [[ -o rcs ]]; then
+ if [ -z "''${__NIX_DARWIN_SET_ENVIRONMENT_DONE-}" ]; then
+ . ${config.system.build.setEnvironment}
+ fi
- if [ -z "$__NIX_DARWIN_SET_ENVIRONMENT_DONE" ]; then
- . ${config.system.build.setEnvironment}
- fi
+ # Tell zsh how to find installed completions
+ for p in ''${(z)NIX_PROFILES}; do
+ fpath=($p/share/zsh/site-functions $p/share/zsh/$ZSH_VERSION/functions $p/share/zsh/vendor-completions $fpath)
+ done
- ${cfg.shellInit}
+ ${cfg.shellInit}
+ fi
# Read system-wide modifications.
if test -f /etc/zshenv.local; then
@@ -148,7 +160,7 @@ in
# This file is read for login shells.
# Only execute this file once per shell.
- if [ -n "$__ETC_ZPROFILE_SOURCED" ]; then return; fi
+ if [ -n "''${__ETC_ZPROFILE_SOURCED-}" ]; then return; fi
__ETC_ZPROFILE_SOURCED=1
${concatStringsSep "\n" zshVariables}
@@ -182,11 +194,6 @@ in
${config.environment.interactiveShellInit}
${cfg.interactiveShellInit}
- # Tell zsh how to find installed completions
- for p in ''${(z)NIX_PROFILES}; do
- fpath+=($p/share/zsh/site-functions $p/share/zsh/$ZSH_VERSION/functions $p/share/zsh/vendor-completions)
- done
-
${cfg.promptInit}
${optionalString cfg.enableGlobalCompInit "autoload -U compinit && compinit"}
@@ -196,6 +203,10 @@ in
"source ${pkgs.zsh-syntax-highlighting}/share/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh"
}
+ ${optionalString cfg.enableFastSyntaxHighlighting
+ "source ${pkgs.zsh-fast-syntax-highlighting}/share/zsh/site-functions/fast-syntax-highlighting.plugin.zsh"
+ }
+
${optionalString cfg.enableFzfCompletion "source ${fzfCompletion}"}
${optionalString cfg.enableFzfGit "source ${fzfGit}"}
${optionalString cfg.enableFzfHistory "source ${fzfHistory}"}