1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-12-06 09:01:04 +01:00
home-manager/modules/programs/nix-your-shell.nix
Austin Horstman 0b491b460f
treewide: remove with lib (#6735)
Continuation of `with lib;` cleanup.
2025-03-31 22:32:16 -05:00

47 lines
1.4 KiB
Nix

{ config, lib, pkgs, ... }:
let cfg = config.programs.nix-your-shell;
in {
meta.maintainers = [ lib.maintainers.terlar ];
options.programs.nix-your-shell = {
enable = lib.mkEnableOption ''
{command}`nix-your-shell`, a wrapper for `nix develop` or `nix-shell`
to retain the same shell inside the new environment'';
package = lib.mkPackageOption pkgs "nix-your-shell" { };
enableFishIntegration =
lib.hm.shell.mkFishIntegrationOption { inherit config; };
enableNushellIntegration =
lib.hm.shell.mkNushellIntegrationOption { inherit config; };
enableZshIntegration =
lib.hm.shell.mkZshIntegrationOption { inherit config; };
};
config = lib.mkIf cfg.enable {
home.packages = [ cfg.package ];
programs = {
fish.interactiveShellInit = lib.mkIf cfg.enableFishIntegration ''
${cfg.package}/bin/nix-your-shell 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
'';
};
zsh.initContent = lib.mkIf cfg.enableZshIntegration ''
${cfg.package}/bin/nix-your-shell zsh | source /dev/stdin
'';
};
};
}