diff --git a/modules/programs/oh-my-posh.nix b/modules/programs/oh-my-posh.nix index dc666afb0..39050e196 100644 --- a/modules/programs/oh-my-posh.nix +++ b/modules/programs/oh-my-posh.nix @@ -68,27 +68,26 @@ in { }; programs.bash.initExtra = mkIf cfg.enableBashIntegration '' - eval "$(${cfg.package}/bin/oh-my-posh init bash ${configArgument})" + eval "$(${lib.getExe cfg.package} init bash ${configArgument})" ''; programs.zsh.initContent = mkIf cfg.enableZshIntegration '' - eval "$(${cfg.package}/bin/oh-my-posh init zsh ${configArgument})" + eval "$(${lib.getExe cfg.package} init zsh ${configArgument})" ''; programs.fish.shellInit = mkIf cfg.enableFishIntegration '' - ${cfg.package}/bin/oh-my-posh init fish ${configArgument} | source + ${lib.getExe cfg.package} init fish ${configArgument} | source ''; programs.nushell = mkIf cfg.enableNushellIntegration { - extraEnv = '' - let oh_my_posh_cache = "${config.xdg.cacheHome}/oh-my-posh" - if not ($oh_my_posh_cache | path exists) { - mkdir $oh_my_posh_cache - } - ${cfg.package}/bin/oh-my-posh init nu ${configArgument} --print | save --force ${config.xdg.cacheHome}/oh-my-posh/init.nu - ''; extraConfig = '' - source ${config.xdg.cacheHome}/oh-my-posh/init.nu + source ${ + pkgs.runCommand "oh-my-posh-nushell-config" { } '' + ${ + lib.getExe cfg.package + } init nu ${configArgument} --print >> "$out" + '' + } ''; }; }; diff --git a/tests/modules/programs/oh-my-posh/nushell.nix b/tests/modules/programs/oh-my-posh/nushell.nix index 2e5079e06..ec88df50f 100644 --- a/tests/modules/programs/oh-my-posh/nushell.nix +++ b/tests/modules/programs/oh-my-posh/nushell.nix @@ -1,4 +1,4 @@ -{ pkgs, config, ... }: +{ lib, pkgs, realPkgs, config, ... }: { programs = { @@ -10,25 +10,17 @@ }; }; + _module.args.pkgs = lib.mkForce realPkgs; + nmt.script = let configFile = if pkgs.stdenv.isDarwin && !config.xdg.enable then "home-files/Library/Application Support/nushell/config.nu" else "home-files/.config/nushell/config.nu"; - - envFile = if pkgs.stdenv.isDarwin && !config.xdg.enable then - "home-files/Library/Application Support/nushell/env.nu" - else - "home-files/.config/nushell/env.nu"; in '' - assertFileExists "${envFile}" - assertFileRegex \ - "${envFile}" \ - '/bin/oh-my-posh init nu --config .*--print \| save --force /.*/home-files/\.cache/oh-my-posh/init\.nu' - assertFileExists "${configFile}" assertFileRegex \ "${configFile}" \ - 'source /.*/\.cache/oh-my-posh/init\.nu' + 'source /nix/store/[^/]*-oh-my-posh-nushell-config' ''; }