Commit 8a3255be40e4

Vincent Demeester <vincent@sbr.pm>
2018-11-01 13:29:41
profiles: add bash, fish and ssh…
… and enable them by default. Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent 5ca8867
fish/a_nix_run.fish → modules/profiles/assets/fish/a_nix_run.fish
File renamed without changes
fish/fish_prompt.fish → modules/profiles/assets/fish/fish_prompt.fish
File renamed without changes
fish/fish_right_prompt.fish → modules/profiles/assets/fish/fish_right_prompt.fish
File renamed without changes
fish/git.fish → modules/profiles/assets/fish/git.fish
File renamed without changes
fish/go.fish → modules/profiles/assets/fish/go.fish
File renamed without changes
fish/nix-aliases.fish → modules/profiles/assets/fish/nix-aliases.fish
File renamed without changes
fish/sudope.fish → modules/profiles/assets/fish/sudope.fish
File renamed without changes
fish/sudope.function.fish → modules/profiles/assets/fish/sudope.function.fish
File renamed without changes
aliases.nix → modules/profiles/aliases.shell.nix
File renamed without changes
modules/profiles/bash.nix
@@ -0,0 +1,23 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+let
+  cfg = config.profiles.bash;
+in
+{
+  options = {
+    profiles.bash = {
+      enable = mkOption {
+        default = true;
+        description = "Enable bash profile and configuration";
+        type = types.bool;
+      };
+    };
+  };
+  config = mkIf cfg.enable {
+    programs.bash = {
+      enable = true;
+      shellAliases = import ./aliases.shell.nix;
+    };
+  };
+}
modules/profiles/fish.nix
@@ -0,0 +1,41 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+let
+  cfg = config.profiles.fish;
+in
+{
+  options = {
+    profiles.fish = {
+      enable = mkOption {
+        default = true;
+        description = "Enable fish program and configurations";
+        type = types.bool;
+      };
+    };
+  };
+  config = mkIf cfg.enable {
+    programs.fish = {
+    enable = true;
+    shellAliases = import ./aliases.shell.nix;
+    shellInit = ''
+      eval (${pkgs.direnv}/bin/direnv hook fish)
+      # emacs ansi-term support
+      if test -n "$EMACS"
+        set -x TERM eterm-color
+  
+        # this function may be required
+        function fish_title
+          true
+        end
+      end
+      '';
+    };
+    xdg.configFile."fish/conf.d/a_nix_run.fish".source = ./assets/fish/a_nix_run.fish;
+    xdg.configFile."fish/conf.d/nix-aliases.fish".source = ./assets/fish/nix-aliases.fish;
+    xdg.configFile."fish/conf.d/sudope.fish".source = ./assets/fish/sudope.fish;
+    xdg.configFile."fish/functions/sudope.fish".source = ./assets/fish/sudope.function.fish;
+    xdg.configFile."fish/functions/fish_prompt.fish".source = ./assets/fish/fish_prompt.fish;
+    xdg.configFile."fish/functions/fish_right_prompt.fish".source = ./assets/fish/fish_right_prompt.fish;
+  };
+}
modules/profiles/ssh.nix
@@ -0,0 +1,53 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+let
+  cfg = config.profiles.ssh;
+in
+{
+  options = {
+    profiles.ssh = {
+      enable = mkOption {
+        default = true;
+        description = "Enable ssh profile and configuration";
+        type = types.bool;
+      };
+    };
+  };
+  config = mkIf cfg.enable {
+    home.file.".ssh/sockets/.placeholder".text = '''';
+    programs.ssh = {
+      enable = true;
+
+      serverAliveInterval = 60;
+      hashKnownHosts = true;
+      userKnownHostsFile = "~/.config/ssh/known_hosts";
+      controlPath = "~/.ssh/sockets/%u-%l-%r@%h:%p";
+    
+      matchBlocks = rec {
+        "github.com" = {
+          hostname = "github.com";
+          user = "git";
+          extraOptions = {
+            controlMaster = "auto";
+            controlPersist = "360";
+          };
+        };
+        "gitlab.com" = {
+          hostname = "gitlab.com";
+          user = "git";
+          extraOptions = {
+            controlMaster = "auto";
+            controlPersist = "360";
+          };
+        };
+        "*.local" = {
+          extraOptions = {
+            controlMaster = "auto";
+            controlPersist = "360";
+          };
+        };
+      };
+    };
+  };
+}
modules/module-list.nix
@@ -2,8 +2,11 @@
 
 {
   imports = [
-    ./profiles/i3.nix
+    ./profiles/bash.nix
     ./profiles/desktop.nix
+    ./profiles/ssh.nix
+    ./profiles/fish.nix
+    ./profiles/i3.nix
     ./services/shairport-sync.nix
   ];
 }
bash.nix
@@ -1,8 +0,0 @@
-{ pkgs, config, lib, ...}:
-
-{
-  programs.bash = {
-    enable = true;
-    shellAliases = import ./aliases.nix
-  };
-}
desktop.nix
@@ -1,7 +1,7 @@
 { pkgs, prefix, ... }:
 
 {
-  imports = [ ./fish.nix ./ssh.nix ./base.nix ];
+  imports = [ ./base.nix ];
   services = {
     gpg-agent = {
       enable = true;
dev.go.nix
@@ -2,7 +2,7 @@
 
 {
   imports = [ ./dev.nix ];
-  xdg.configFile."fish/conf.d/go.fish".source = ./fish/go.fish;
+  xdg.configFile."fish/conf.d/go.fish".source = ./modules/profiles/assets/fish/go.fish;
   programs.fish.shellAbbrs = {
     got = "go test -v";
     gob = "go build -v";
fish.nix
@@ -1,26 +0,0 @@
-{ pkgs, config, lib, ... }:
-
-{
-  programs.fish = {
-    enable = true;
-    shellAliases = import ./aliases.nix;
-    shellInit = ''
-    eval (${pkgs.direnv}/bin/direnv hook fish)
-    # emacs ansi-term support
-    if test -n "$EMACS"
-      set -x TERM eterm-color
-
-      # this function may be required
-      function fish_title
-        true
-      end
-    end
-    '';
-  };
-  xdg.configFile."fish/conf.d/a_nix_run.fish".source = ./fish/a_nix_run.fish;
-  xdg.configFile."fish/conf.d/nix-aliases.fish".source = ./fish/nix-aliases.fish;
-  xdg.configFile."fish/conf.d/sudope.fish".source = ./fish/sudope.fish;
-  xdg.configFile."fish/functions/sudope.fish".source = ./fish/sudope.function.fish;
-  xdg.configFile."fish/functions/fish_prompt.fish".source = ./fish/fish_prompt.fish;
-  xdg.configFile."fish/functions/fish_right_prompt.fish".source = ./fish/fish_right_prompt.fish;
-}
git.nix
@@ -11,7 +11,7 @@ rec {
     gitAndTools.tig
     prm
   ];
-  xdg.configFile."fish/conf.d/git.fish".source = ./fish/git.fish;
+  xdg.configFile."fish/conf.d/git.fish".source = ./modules/profiles/assets/fish/git.fish;
   programs.fish.shellAbbrs = {
     gs = "git status";
     gb = "git b";
server.nix
@@ -1,5 +1,5 @@
 { pkgs, prefix, ... }:
 
 {
-  imports = [ ./fish.nix ./base.nix ];
+  imports = [ ./base.nix ];
 }
ssh.nix
@@ -1,38 +0,0 @@
-{ pkgs, config, lib, ... }:
-
-{
-  home.file.".ssh/sockets/.placeholder".text = '''';
-  programs.ssh = {
-    enable = true;
-
-    serverAliveInterval = 60;
-    hashKnownHosts = true;
-    userKnownHostsFile = "~/.config/ssh/known_hosts";
-    controlPath = "~/.ssh/sockets/%u-%l-%r@%h:%p";
-    
-    matchBlocks = rec {
-      "github.com" = {
-        hostname = "github.com";
-        user = "git";
-        extraOptions = {
-          controlMaster = "auto";
-          controlPersist = "360";
-        };
-      };
-      "gitlab.com" = {
-        hostname = "gitlab.com";
-        user = "git";
-        extraOptions = {
-          controlMaster = "auto";
-          controlPersist = "360";
-        };
-      };
-      "*.local" = {
-        extraOptions = {
-          controlMaster = "auto";
-          controlPersist = "360";
-        };
-      };
-    };
-  };
-}