1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-12-06 00:51:04 +01:00

nix-your-shell: build-time nushell config generation

This commit is contained in:
jaredmontoya 2025-03-21 20:13:56 +01:00 committed by Austin Horstman
parent dde05a0b10
commit 287cbbbf80
2 changed files with 16 additions and 20 deletions

View file

@ -25,22 +25,21 @@ in {
programs = {
fish.interactiveShellInit = lib.mkIf cfg.enableFishIntegration ''
${cfg.package}/bin/nix-your-shell fish | source
${lib.getExe cfg.package} fish | source
'';
nushell = lib.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
'';
extraConfig = ''
source ${config.xdg.cacheHome}/nix-your-shell/init.nu
source ${
pkgs.runCommand "nix-your-shell-nushell-config" { } ''
${lib.getExe cfg.package} nu >> "$out"
''
}
'';
};
zsh.initContent = lib.mkIf cfg.enableZshIntegration ''
${cfg.package}/bin/nix-your-shell zsh | source /dev/stdin
${lib.getExe cfg.package} zsh | source /dev/stdin
'';
};
};

View file

@ -1,4 +1,4 @@
{ pkgs, config, ... }:
{ lib, pkgs, realPkgs, config, ... }:
{
programs = {
@ -13,6 +13,8 @@
zsh.enable = true;
};
_module.args.pkgs = lib.mkForce realPkgs;
nmt.script = let
nushellConfigDir = if pkgs.stdenv.isDarwin && !config.xdg.enable then
"home-files/Library/Application Support/nushell"
@ -20,23 +22,18 @@
"home-files/.config/nushell";
in ''
assertFileExists home-files/.config/fish/config.fish
assertFileContains \
assertFileRegex \
home-files/.config/fish/config.fish \
'@nix-your-shell@/bin/nix-your-shell fish | source'
'/nix/store/[^/]*-nix-your-shell-[^/]*/bin/nix-your-shell fish | source'
assertFileExists ${nushellConfigDir}/config.nu
assertFileContains \
assertFileRegex \
${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 nu | save --force ${config.xdg.cacheHome}/nix-your-shell/init.nu'
'source /nix/store/[^/]*-nix-your-shell-nushell-config'
assertFileExists home-files/.zshrc
assertFileContains \
assertFileRegex \
home-files/.zshrc \
'@nix-your-shell@/bin/nix-your-shell zsh | source /dev/stdin'
'/nix/store/[^/]*-nix-your-shell-[^/]*/bin/nix-your-shell zsh | source /dev/stdin'
'';
}