From 5be8612163269f481c7cee03be8202aee7603dcd Mon Sep 17 00:00:00 2001 From: "Alexander \"PapaTutuWawa" Date: Sat, 23 Apr 2022 20:12:59 +0200 Subject: [PATCH] direnv: Init --- hosts/miku.nix | 1 + modules/default.nix | 1 + modules/programs/direnv/default.nix | 19 +++++++++++++++++++ modules/programs/zsh/default.nix | 8 +++++++- 4 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 modules/programs/direnv/default.nix diff --git a/hosts/miku.nix b/hosts/miku.nix index eb506ba..eb33bbc 100644 --- a/hosts/miku.nix +++ b/hosts/miku.nix @@ -68,6 +68,7 @@ }; #xournalpp.enable = true; zsh.enable = true; + direnv.enable = true; office.enable = true; plasma.enable = true; gaming.enable = true; diff --git a/modules/default.nix b/modules/default.nix index e8f9012..8de4e45 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -24,6 +24,7 @@ ./programs/office ./programs/gaming ./programs/bluray + ./programs/direnv # Services ./services/kanshi diff --git a/modules/programs/direnv/default.nix b/modules/programs/direnv/default.nix new file mode 100644 index 0000000..724e35a --- /dev/null +++ b/modules/programs/direnv/default.nix @@ -0,0 +1,19 @@ +{ config, lib, pkgs, ... }: + +let + cfg = config.ptw.programs.direnv; +in { + options.ptw.programs.direnv = { + enable = lib.mkEnableOption "Enable direnv"; + }; + + config = lib.mkIf cfg.enable { + home-manager.users."${config.ptw.system.singleUser}".programs.direnv = { + enable = true; + enableZshIntegration = true; + nix-direnv = { + enable = true; + }; + }; + }; +} diff --git a/modules/programs/zsh/default.nix b/modules/programs/zsh/default.nix index b772449..c53b173 100644 --- a/modules/programs/zsh/default.nix +++ b/modules/programs/zsh/default.nix @@ -47,8 +47,14 @@ in { bindkey "\e[3~" delete-char ''; history.share = true; + initExtraFirst = let + enableDirenv = lib.optionalString + config.ptw.programs.direnv.enable + "eval \"$(${pkgs.direnv}/bin/direnv hook zsh)\""; + in '' + ${enableDirenv} + # TODO: Maybe move this somewhere else - initExtraFirst = '' wcurl() { [[ -z "$1" ]] && echo "Error: No URL specified" && exit 1