1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00

nix-your-shell: Allow using nom for nix commands

This commit is contained in:
David Chocholatý 2025-08-29 18:14:57 +02:00 committed by Austin Horstman
parent cb68b5cd6a
commit 6ce2e18007
2 changed files with 36 additions and 19 deletions

View file

@ -22,28 +22,44 @@ in
enableNushellIntegration = lib.hm.shell.mkNushellIntegrationOption { inherit config; }; enableNushellIntegration = lib.hm.shell.mkNushellIntegrationOption { inherit config; };
enableZshIntegration = lib.hm.shell.mkZshIntegrationOption { inherit config; }; enableZshIntegration = lib.hm.shell.mkZshIntegrationOption { inherit config; };
nix-output-monitor = {
enable = lib.mkEnableOption ''
[nix-output-monitor](https://github.com/maralorn/nix-output-monitor).
Pipe your nix-build output through the nix-output-monitor a.k.a nom to get additional information while building
'';
package = lib.mkPackageOption pkgs "nix-output-monitor" { };
};
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
home.packages = [ cfg.package ]; home.packages = [
cfg.package
(lib.mkIf cfg.nix-output-monitor.enable cfg.nix-output-monitor.package)
];
programs = { programs =
let
nom = if cfg.nix-output-monitor.enable then "--nom" else "";
in
{
fish.interactiveShellInit = lib.mkIf cfg.enableFishIntegration '' fish.interactiveShellInit = lib.mkIf cfg.enableFishIntegration ''
${lib.getExe cfg.package} fish | source ${lib.getExe cfg.package} ${nom} fish | source
''; '';
nushell = lib.mkIf cfg.enableNushellIntegration { nushell = lib.mkIf cfg.enableNushellIntegration {
extraConfig = '' extraConfig = ''
source ${ source ${
pkgs.runCommand "nix-your-shell-nushell-config.nu" { } '' pkgs.runCommand "nix-your-shell-nushell-config.nu" { } ''
${lib.getExe cfg.package} nu >> "$out" ${lib.getExe cfg.package} ${nom} nu >> "$out"
'' ''
} }
''; '';
}; };
zsh.initContent = lib.mkIf cfg.enableZshIntegration '' zsh.initContent = lib.mkIf cfg.enableZshIntegration ''
${lib.getExe cfg.package} zsh | source /dev/stdin ${lib.getExe cfg.package} ${nom} zsh | source /dev/stdin
''; '';
}; };
}; };

View file

@ -13,6 +13,7 @@
enableFishIntegration = true; enableFishIntegration = true;
enableNushellIntegration = true; enableNushellIntegration = true;
enableZshIntegration = true; enableZshIntegration = true;
nix-output-monitor.enable = true;
}; };
fish.enable = true; fish.enable = true;
nushell.enable = true; nushell.enable = true;
@ -33,7 +34,7 @@
assertFileExists home-files/.config/fish/config.fish assertFileExists home-files/.config/fish/config.fish
assertFileRegex \ assertFileRegex \
home-files/.config/fish/config.fish \ home-files/.config/fish/config.fish \
'/nix/store/[^/]*-nix-your-shell-[^/]*/bin/nix-your-shell fish | source' '/nix/store/[^/]*-nix-your-shell-[^/]*/bin/nix-your-shell --nom fish | source'
assertFileExists ${nushellConfigDir}/config.nu assertFileExists ${nushellConfigDir}/config.nu
assertFileRegex \ assertFileRegex \
@ -43,6 +44,6 @@
assertFileExists home-files/.zshrc assertFileExists home-files/.zshrc
assertFileRegex \ assertFileRegex \
home-files/.zshrc \ home-files/.zshrc \
'/nix/store/[^/]*-nix-your-shell-[^/]*/bin/nix-your-shell zsh | source /dev/stdin' '/nix/store/[^/]*-nix-your-shell-[^/]*/bin/nix-your-shell --nom zsh | source /dev/stdin'
''; '';
} }