about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2022-05-01 13:59:01 -0700
committerFranck Cuny <franck@fcuny.net>2022-05-01 13:59:01 -0700
commitbf3a7126463f45364abcf8d6012dde51e51e4b3f (patch)
treea35d402674c1ba3111ba1efccb0b8a4073466fa9
parentgitea: add a dashboard for grafana (diff)
downloadworld-bf3a7126463f45364abcf8d6012dde51e51e4b3f.tar.gz
home: add a module for direnv
-rw-r--r--home/default.nix1
-rw-r--r--home/direnv/default.nix28
-rw-r--r--profiles/desktop/default.nix1
3 files changed, 30 insertions, 0 deletions
diff --git a/home/default.nix b/home/default.nix
index 694d630..1f0dd9c 100644
--- a/home/default.nix
+++ b/home/default.nix
@@ -3,6 +3,7 @@
 {
   imports = [
     ./beets
+    ./direnv
     ./documentation
     ./element
     ./emacs
diff --git a/home/direnv/default.nix b/home/direnv/default.nix
new file mode 100644
index 0000000..89d0535
--- /dev/null
+++ b/home/direnv/default.nix
@@ -0,0 +1,28 @@
+{ config, lib, pkgs, ... }:
+let
+  cfg = config.my.home.direnv;
+  fishEnabled = config.my.home.fish.enable;
+in {
+  options.my.home.direnv = with lib; {
+    enable = mkEnableOption "direnv configuration";
+  };
+
+  config = lib.mkIf cfg.enable {
+    programs.direnv = {
+      enable = true;
+      nix-direnv = {
+        enable = true;
+        enableFlakes = true;
+      };
+    };
+
+    programs.fish.interactiveShellInit = lib.mkIf fishEnabled (
+      # Using mkAfter to make it more likely to appear after other
+      # manipulations of the prompt.
+      lib.mkAfter ''
+        ${pkgs.direnv}/bin/direnv hook fish | source
+      '');
+
+    home.sessionVariables = { DIRENV_DEFAULT_FLAKE = "nixpkgs"; };
+  };
+}
diff --git a/profiles/desktop/default.nix b/profiles/desktop/default.nix
index 494a7b3..2f3b26e 100644
--- a/profiles/desktop/default.nix
+++ b/profiles/desktop/default.nix
@@ -14,6 +14,7 @@ in {
       };
       home = {
         emacs.enable = true;
+        direnv.enable = true;
         firefox.enable = true;
         pcmanfm.enable = true;
         terminal.program = "alacritty";