Install direnv.
This commit is contained in:
55
nix/configuration/roles/direnv/default.nix
Normal file
55
nix/configuration/roles/direnv/default.nix
Normal file
@@ -0,0 +1,55 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
|
||||
let
|
||||
direnv_zsh_hook = pkgs.writeTextFile {
|
||||
name = "direnv_zsh_hook.zsh";
|
||||
text = ''
|
||||
eval "$(direnv hook zsh)"
|
||||
'';
|
||||
};
|
||||
in
|
||||
{
|
||||
imports = [ ];
|
||||
|
||||
options.me = {
|
||||
direnv.enable = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = false;
|
||||
example = true;
|
||||
description = "Whether we want to install direnv.";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf config.me.direnv.enable (
|
||||
lib.mkMerge [
|
||||
{
|
||||
environment.systemPackages = with pkgs; [
|
||||
direnv
|
||||
nix-direnv
|
||||
];
|
||||
|
||||
me.zsh.includes = [ direnv_zsh_hook ];
|
||||
|
||||
environment.persistence."/persist" = lib.mkIf (!config.me.buildingIso) {
|
||||
hideMounts = true;
|
||||
users.talexander = {
|
||||
directories = [
|
||||
{
|
||||
# List of allowed directories from `direnv allow`.
|
||||
directory = ".local/share/direnv";
|
||||
user = "talexander";
|
||||
group = "talexander";
|
||||
mode = "0755";
|
||||
}
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
]
|
||||
);
|
||||
}
|
||||
@@ -49,6 +49,8 @@ let
|
||||
|
||||
source ${pkgs.zsh-histdb}/share/zsh/plugins/zsh-histdb/histdb-interactive.zsh
|
||||
bindkey '^r' _histdb-isearch
|
||||
|
||||
${lib.concatMapStringsSep "\n" (item: "source ${item}") config.me.zsh.includes}
|
||||
'';
|
||||
};
|
||||
in
|
||||
@@ -62,6 +64,16 @@ in
|
||||
example = true;
|
||||
description = "Whether we want to install zsh.";
|
||||
};
|
||||
zsh.includes = lib.mkOption {
|
||||
type = lib.types.listOf lib.types.package;
|
||||
default = [ ];
|
||||
example = lib.literalExpression ''
|
||||
[ (pkgs.writeTextFile {
|
||||
name = "launch-kanshi.conf";
|
||||
text = "exec kanshi";
|
||||
}) ]'';
|
||||
description = "List of zshrc files to import.";
|
||||
};
|
||||
};
|
||||
|
||||
config = lib.mkIf config.me.zsh.enable (
|
||||
|
||||
Reference in New Issue
Block a user