This adds initial support for the zsh package manager "zplug". PR #1105wip/yesman
parent
bb567e20b3
commit
1b210e7143
@ -0,0 +1,57 @@ |
||||
{ config, lib, pkgs, ... }: |
||||
|
||||
with lib; |
||||
|
||||
let |
||||
|
||||
cfg = config.programs.zsh.zplug; |
||||
|
||||
pluginModule = types.submodule ({ config, ... }: { |
||||
options = { |
||||
name = mkOption { |
||||
type = types.str; |
||||
description = "The name of the plugin."; |
||||
}; |
||||
|
||||
tags = mkOption { |
||||
type = types.listOf types.str; |
||||
default = [ ]; |
||||
description = "The plugin tags."; |
||||
}; |
||||
}; |
||||
|
||||
}); |
||||
|
||||
in { |
||||
options.programs.zsh.zplug = { |
||||
enable = mkEnableOption "zplug - a zsh plugin manager"; |
||||
|
||||
plugins = mkOption { |
||||
default = [ ]; |
||||
type = types.listOf pluginModule; |
||||
description = "List of zplug plugins."; |
||||
}; |
||||
}; |
||||
|
||||
config = mkIf cfg.enable { |
||||
home.packages = [ pkgs.zplug ]; |
||||
|
||||
programs.zsh.initExtraBeforeCompInit = '' |
||||
source ${pkgs.zplug}/init.zsh |
||||
|
||||
${optionalString (cfg.plugins != [ ]) '' |
||||
${concatStrings (map (plugin: '' |
||||
zplug "${plugin.name}"${ |
||||
optionalString (plugin.tags != [ ]) '' |
||||
${concatStrings (map (tag: ", ${tag}") plugin.tags)} |
||||
'' |
||||
} |
||||
'') cfg.plugins)} |
||||
''} |
||||
|
||||
zplug install |
||||
zplug load |
||||
''; |
||||
|
||||
}; |
||||
} |
@ -0,0 +1 @@ |
||||
{ zplug-modules = ./modules.nix; } |
@ -0,0 +1,48 @@ |
||||
{ config, lib, pkgs, ... }: |
||||
|
||||
with lib; |
||||
|
||||
{ |
||||
config = { |
||||
programs.zsh = { |
||||
enable = true; |
||||
zplug = { |
||||
enable = true; |
||||
plugins = [ |
||||
{ |
||||
name = "plugins/git"; |
||||
tags = [ "from:oh-my-zsh" ]; |
||||
} |
||||
{ |
||||
name = "lib/clipboard"; |
||||
tags = [ "from:oh-my-zsh" ''if:"[[ $OSTYPE == *darwin* ]]"'' ]; |
||||
} |
||||
]; |
||||
}; |
||||
}; |
||||
|
||||
nixpkgs.overlays = [ |
||||
(self: super: { |
||||
zsh = pkgs.writeScriptBin "dummy-zsh" ""; |
||||
zplug = pkgs.writeScriptBin "dummy-zplug" ""; |
||||
}) |
||||
]; |
||||
|
||||
nmt.script = '' |
||||
assertFileRegex home-files/.zshrc \ |
||||
'^source ${builtins.storeDir}/.*zplug.*/init\.zsh$' |
||||
|
||||
assertFileContains home-files/.zshrc \ |
||||
'zplug "plugins/git", from:oh-my-zsh' |
||||
|
||||
assertFileContains home-files/.zshrc \ |
||||
'zplug "lib/clipboard", from:oh-my-zsh, if:"[[ $OSTYPE == *darwin* ]]"' |
||||
|
||||
assertFileRegex home-files/.zshrc \ |
||||
'^zplug install$' |
||||
|
||||
assertFileRegex home-files/.zshrc \ |
||||
'^zplug load$' |
||||
''; |
||||
}; |
||||
} |
Loading…
Reference in new issue