-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add pay-respects module including shell integration support for bash, zsh, fish and nushell
- Loading branch information
1 parent
66c5d8b
commit c33bce6
Showing
7 changed files
with
132 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,7 +5,6 @@ | |
# are expected to be follow the same format as described in [1]. | ||
# | ||
# [1] https://github.com/NixOS/nixpkgs/blob/fca0d6e093c82b31103dc0dacc48da2a9b06e24b/maintainers/maintainer-list.nix#LC1 | ||
|
||
{ | ||
aabccd021 = { | ||
name = "Muhamad Abdurahman"; | ||
|
@@ -628,4 +627,10 @@ | |
keys = | ||
[{ fingerprint = "BC82 4BB5 1656 D144 285E A0EC D382 C4AF EECE AA90"; }]; | ||
}; | ||
ALameLlama = { | ||
name = "Nicholas Ciechanowski"; | ||
email = "[email protected]"; | ||
github = "ALameLlama"; | ||
githubId = 55490546; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
{ config, lib, pkgs, ... }: | ||
with lib; | ||
let | ||
cfg = config.programs.pay-respects; | ||
payRespectsCmd = "${cfg.package}/bin/pay-respects"; | ||
in { | ||
meta.maintainers = [ hm.maintainers.ALameLlama ]; | ||
|
||
options.programs.pay-respects = { | ||
enable = mkEnableOption "pay-respects"; | ||
|
||
package = mkOption { | ||
type = types.package; | ||
default = pkgs.pay-respects; | ||
defaultText = literalExpression "pkgs.pay-respects"; | ||
description = "The package to use for the pay-respects binary."; | ||
}; | ||
|
||
enableBashIntegration = mkEnableOption "Bash integration" // { | ||
default = true; | ||
}; | ||
|
||
enableZshIntegration = mkEnableOption "Zsh integration" // { | ||
default = true; | ||
}; | ||
|
||
enableFishIntegration = mkEnableOption "Fish integration" // { | ||
default = true; | ||
}; | ||
|
||
enableNushellIntegration = mkEnableOption "Nushell integration" // { | ||
default = true; | ||
}; | ||
}; | ||
|
||
config = mkIf cfg.enable { | ||
home.packages = [ cfg.package ]; | ||
|
||
programs = { | ||
bash.initExtra = '' | ||
${optionalString cfg.enableBashIntegration '' | ||
eval "$(${payRespectsCmd} bash --alias)" | ||
''} | ||
''; | ||
|
||
zsh.initExtra = '' | ||
${optionalString cfg.enableZshIntegration '' | ||
eval "$(${payRespectsCmd} zsh --alias)" | ||
''} | ||
''; | ||
|
||
fish.interactiveShellInit = '' | ||
${optionalString cfg.enableFishIntegration '' | ||
${payRespectsCmd} fish --alias | source | ||
''} | ||
''; | ||
|
||
nushell.extraConfig = '' | ||
${optionalString cfg.enableNushellIntegration '' | ||
${payRespectsCmd} nushell --alias [<alias>] | ||
''} | ||
''; | ||
}; | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
pay-respects-integration-enabled = ./integration-enabled.nix; | ||
pay-respects-integration-disabled = ./integration-disabled.nix; | ||
} |
22 changes: 22 additions & 0 deletions
22
tests/modules/programs/pay-respects/integration-disabled.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ ... }: { | ||
programs = { | ||
pay-respects.enable = true; | ||
pay-respects.enableBashIntegration = false; | ||
pay-respects.enableFishIntegration = false; | ||
pay-respects.enableZshIntegration = false; | ||
pay-respects.enableNushellIntegration = false; | ||
bash.enable = true; | ||
zsh.enable = true; | ||
fish.enable = true; | ||
nushell.enable = true; | ||
}; | ||
|
||
test.stubs.pay-respects = { }; | ||
|
||
nmt.script = '' | ||
assertFileNotRegex home-files/.bashrc '@pay-respects@/bin/pay-respects' | ||
assertFileNotRegex home-files/.zshrc '@pay-respects@/bin/pay-respects' | ||
assertFileNotRegex home-files/.config/fish/config.fish '@pay-respects@/bin/pay-respects' | ||
assertFileNotRegex home-files/.config/nushell/config.nu '@pay-respects@/bin/pay-respects' | ||
''; | ||
} |
33 changes: 33 additions & 0 deletions
33
tests/modules/programs/pay-respects/integration-enabled.nix
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
{ ... }: { | ||
programs = { | ||
pay-respects.enable = true; | ||
bash.enable = true; | ||
zsh.enable = true; | ||
fish.enable = true; | ||
nushell.enable = true; | ||
}; | ||
|
||
test.stubs.pay-respects = { }; | ||
|
||
nmt.script = '' | ||
assertFileExists home-files/.bashrc | ||
assertFileContains \ | ||
home-files/.bashrc \ | ||
'eval "$(@pay-respects@/bin/pay-respects bash --alias)"' | ||
assertFileExists home-files/.zshrc | ||
assertFileContains \ | ||
home-files/.zshrc \ | ||
'eval "$(@pay-respects@/bin/pay-respects zsh --alias)"' | ||
assertFileExists home-files/.config/fish/config.fish | ||
assertFileContains \ | ||
home-files/.config/fish/config.fish \ | ||
'@pay-respects@/bin/pay-respects fish --alias | source' | ||
assertFileExists home-files/.config/nushell/config.nu | ||
assertFileContains \ | ||
home-files/.config/nushell/config.nu \ | ||
'@pay-respects@/bin/pay-respects nushell --alias [<alias>]' | ||
''; | ||
} |