mirror of
https://github.com/nix-community/home-manager.git
synced 2024-12-14 11:57:55 +00:00
nix-your-shell: add nom (nix-output-monitor) support
`nix-your-shell` has a feature where you can pass `--nom` to it in order to have it use `nix-output-monitor` monitor by default for `nix` invocations. This commit adds support for that in the relevant module.
This commit is contained in:
parent
9ebaa80a22
commit
dd651e30f3
3 changed files with 69 additions and 6 deletions
|
@ -27,20 +27,29 @@ in {
|
|||
enableZshIntegration = mkEnableOption "Zsh integration" // {
|
||||
default = true;
|
||||
};
|
||||
|
||||
enableNom = mkEnableOption "nom (nix-output-monitor) integration";
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = [ cfg.package ];
|
||||
home.packages = [ cfg.package ]
|
||||
++ (optionals cfg.enableNom [ pkgs.nix-output-monitor ]);
|
||||
|
||||
programs = {
|
||||
programs = let
|
||||
argsForShell = shell:
|
||||
concatStringsSep " "
|
||||
([ ] ++ (optional cfg.enableNom "--nom") ++ [ "${shell}" ]);
|
||||
in {
|
||||
fish.interactiveShellInit = mkIf cfg.enableFishIntegration ''
|
||||
${cfg.package}/bin/nix-your-shell fish | source
|
||||
${cfg.package}/bin/nix-your-shell ${argsForShell "fish"} | source
|
||||
'';
|
||||
|
||||
nushell = mkIf cfg.enableNushellIntegration {
|
||||
extraEnv = ''
|
||||
mkdir ${config.xdg.cacheHome}/nix-your-shell
|
||||
${cfg.package}/bin/nix-your-shell nu | save --force ${config.xdg.cacheHome}/nix-your-shell/init.nu
|
||||
${cfg.package}/bin/nix-your-shell ${
|
||||
argsForShell "nu"
|
||||
} | save --force ${config.xdg.cacheHome}/nix-your-shell/init.nu
|
||||
'';
|
||||
|
||||
extraConfig = ''
|
||||
|
@ -49,7 +58,9 @@ in {
|
|||
};
|
||||
|
||||
zsh.initExtra = mkIf cfg.enableZshIntegration ''
|
||||
${cfg.package}/bin/nix-your-shell zsh | source /dev/stdin
|
||||
${cfg.package}/bin/nix-your-shell ${
|
||||
argsForShell "zsh"
|
||||
} | source /dev/stdin
|
||||
'';
|
||||
};
|
||||
};
|
||||
|
|
|
@ -1 +1,4 @@
|
|||
{ nix-your-shell-enable-shells = ./enable-shells.nix; }
|
||||
{
|
||||
nix-your-shell-enable-shells = ./enable-shells.nix;
|
||||
nix-your-shell-enable-nom = ./enable-nom.nix;
|
||||
}
|
||||
|
|
49
tests/modules/programs/nix-your-shell/enable-nom.nix
Normal file
49
tests/modules/programs/nix-your-shell/enable-nom.nix
Normal file
|
@ -0,0 +1,49 @@
|
|||
{ pkgs, config, ... }:
|
||||
|
||||
{
|
||||
programs = {
|
||||
nix-your-shell = {
|
||||
enable = true;
|
||||
enableFishIntegration = true;
|
||||
enableNushellIntegration = true;
|
||||
enableZshIntegration = true;
|
||||
enableNom = true;
|
||||
};
|
||||
fish.enable = true;
|
||||
nushell.enable = true;
|
||||
zsh.enable = true;
|
||||
};
|
||||
|
||||
test.stubs = {
|
||||
nix-your-shell = { };
|
||||
nushell = { };
|
||||
zsh = { };
|
||||
};
|
||||
|
||||
nmt.script = let
|
||||
nushellConfigDir = if pkgs.stdenv.isDarwin && !config.xdg.enable then
|
||||
"home-files/Library/Application Support/nushell"
|
||||
else
|
||||
"home-files/.config/nushell";
|
||||
in ''
|
||||
assertFileExists home-files/.config/fish/config.fish
|
||||
assertFileContains \
|
||||
home-files/.config/fish/config.fish \
|
||||
'@nix-your-shell@/bin/nix-your-shell --nom fish | source'
|
||||
|
||||
assertFileExists ${nushellConfigDir}/config.nu
|
||||
assertFileContains \
|
||||
${nushellConfigDir}/config.nu \
|
||||
'source ${config.xdg.cacheHome}/nix-your-shell/init.nu'
|
||||
|
||||
assertFileExists ${nushellConfigDir}/env.nu
|
||||
assertFileContains \
|
||||
${nushellConfigDir}/env.nu \
|
||||
'@nix-your-shell@/bin/nix-your-shell --nom nu | save --force ${config.xdg.cacheHome}/nix-your-shell/init.nu'
|
||||
|
||||
assertFileExists home-files/.zshrc
|
||||
assertFileContains \
|
||||
home-files/.zshrc \
|
||||
'@nix-your-shell@/bin/nix-your-shell --nom zsh | source /dev/stdin'
|
||||
'';
|
||||
}
|
Loading…
Reference in a new issue