mirror of
https://github.com/nix-community/home-manager
synced 2024-11-10 07:04:17 +00:00
programs.nix-your-shell: add module
This commit is contained in:
parent
afd2021bed
commit
77ce0ca694
5 changed files with 106 additions and 0 deletions
|
@ -171,6 +171,7 @@ let
|
|||
./programs/newsboat.nix
|
||||
./programs/nheko.nix
|
||||
./programs/nix-index.nix
|
||||
./programs/nix-your-shell.nix
|
||||
./programs/nnn.nix
|
||||
./programs/noti.nix
|
||||
./programs/notmuch.nix
|
||||
|
|
55
modules/programs/nix-your-shell.nix
Normal file
55
modules/programs/nix-your-shell.nix
Normal file
|
@ -0,0 +1,55 @@
|
|||
{ config, lib, pkgs, ... }:
|
||||
|
||||
with lib;
|
||||
|
||||
let
|
||||
|
||||
cfg = config.programs.nix-your-shell;
|
||||
|
||||
in {
|
||||
meta.maintainers = [ maintainers.terlar ];
|
||||
|
||||
options.programs.nix-your-shell = {
|
||||
enable = mkEnableOption ''
|
||||
{command}`nix-your-shell`, a wrapper for `nix develop` or `nix-shell`
|
||||
to retain the same shell inside the new environment'';
|
||||
|
||||
package = mkPackageOption pkgs "nix-your-shell" { };
|
||||
|
||||
enableFishIntegration = mkEnableOption "Fish integration" // {
|
||||
default = true;
|
||||
};
|
||||
|
||||
enableNushellIntegration = mkEnableOption "Nushell integration" // {
|
||||
default = true;
|
||||
};
|
||||
|
||||
enableZshIntegration = mkEnableOption "Bash integration" // {
|
||||
default = true;
|
||||
};
|
||||
};
|
||||
|
||||
config = mkIf cfg.enable {
|
||||
home.packages = [ cfg.package ];
|
||||
|
||||
programs = {
|
||||
fish.interactiveShellInit = mkIf cfg.enableFishIntegration ''
|
||||
${cfg.package}/bin/nix-your-shell fish | source
|
||||
'';
|
||||
|
||||
nushell = mkIf cfg.enableNushellIntegration {
|
||||
extraEnv = ''
|
||||
${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.initExtra = mkIf cfg.enableZshIntegration ''
|
||||
${cfg.package}/bin/nix-your-shell zsh | source /dev/stdin
|
||||
'';
|
||||
};
|
||||
};
|
||||
}
|
|
@ -114,6 +114,7 @@ in import nmtSrc {
|
|||
./modules/programs/newsboat
|
||||
./modules/programs/nheko
|
||||
./modules/programs/nix-index
|
||||
./modules/programs/nix-your-shell
|
||||
./modules/programs/nnn
|
||||
./modules/programs/nushell
|
||||
./modules/programs/oh-my-posh
|
||||
|
|
1
tests/modules/programs/nix-your-shell/default.nix
Normal file
1
tests/modules/programs/nix-your-shell/default.nix
Normal file
|
@ -0,0 +1 @@
|
|||
{ nix-your-shell-enable-shells = ./enable-shells.nix; }
|
48
tests/modules/programs/nix-your-shell/enable-shells.nix
Normal file
48
tests/modules/programs/nix-your-shell/enable-shells.nix
Normal file
|
@ -0,0 +1,48 @@
|
|||
{ pkgs, config, ... }:
|
||||
|
||||
{
|
||||
programs = {
|
||||
nix-your-shell = {
|
||||
enable = true;
|
||||
enableFishIntegration = true;
|
||||
enableNushellIntegration = true;
|
||||
enableZshIntegration = 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 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 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 zsh | source /dev/stdin'
|
||||
'';
|
||||
}
|
Loading…
Reference in a new issue