nix-v0/src/home/shell/shell.nix
2024-11-03 15:27:57 -06:00

53 lines
1.3 KiB
Nix

{
config,
lib,
pkgs,
...
}:
{
options.custom = with lib; {
shell = {
packages = mkOption {
type =
with types;
attrsOf (oneOf [
str
attrs
package
]);
default = { };
apply = custom.mkShellPackages;
description = ''
Attrset of shell packages to install and add to pkgs.custom overlay (for compatibility across multiple shells).
Both string and attr values will be passed as arguments to writeShellApplicationCompletions
'';
example = ''
shell.packages = {
myPackage1 = "echo 'Hello, World!'";
myPackage2 = {
runtimeInputs = [ pkgs.hello ];
text = "hello --greeting 'Hi'";
};
}
'';
};
additionalSourceFile = mkOption {
type = types.nullOr types.path;
default = ./custom.sh;
};
};
};
config = {
programs.bash = lib.mkIf (config.custom.shell.additionalSourceFile != null) {
bashrcExtra = lib.mkAfter ''
source ${config.custom.shell.additionalSourceFile}
'';
};
programs.zsh = lib.mkIf (config.custom.shell.additionalSourceFile != null) {
initExtra = lib.mkAfter ''
source ${config.custom.shell.additionalSourceFile}
'';
};
};
}