Commit 002befb915f0

Vincent Demeester <vincent@sbr.pm>
2018-11-01 14:12:15
profiles: add dev, git and emacs profiles…
… right now it's just moving stuff around, some rework is required (on emacs profiles for example) Signed-off-by: Vincent Demeester <vincent@sbr.pm>
1 parent 207823d
git/redhat.gitconfig → modules/profiles/assets/git/redhat.gitconfig
File renamed without changes
modules/profiles/dev.nix
@@ -0,0 +1,38 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+let
+  cfg = config.profiles.dev;
+in
+{
+  options = {
+    profiles.dev = {
+      enable = mkOption {
+        default = false;
+        description = "Enable development profile";
+        type = types.bool;
+      };
+    };
+  };
+  config = mkIf cfg.enable (mkMerge [
+    {
+      profiles.git.enable = true;
+      profiles.emacs.enable = true;
+      home.packages = with pkgs; [
+        binutils-unwrapped
+        cmake
+        fswatch
+        gnumake
+        lnav
+        mercurial
+        ripgrep
+        shfmt
+      ];
+    }
+    (mkIf config.profiles.fish.enable {
+      programs.fish.shellAbbrs = {
+        m = "make";
+      };
+    })
+  ]);
+}
modules/profiles/emacs.nix
@@ -0,0 +1,242 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+let
+  cfg = config.profiles.emacs;
+in
+{
+  options = {
+    profiles.emacs = {
+      enable = mkOption {
+        default = false;
+        description = "Enable emacs profile";
+        type = types.bool;
+      };
+    };
+  };
+  config = mkIf cfg.enable {
+    home.file.".local/share/applications/org-protocol.desktop".source = ./assets/xorg/org-protocol.desktop;
+    systemd.user.services.emacs = {
+      Unit = {
+        Description = "Emacs: the extensible, self-documenting text editor";
+      };
+      Service = {
+        Environment = ''
+          PATH=/home/vincent/bin:/home/vincent/.local/npm/bin:/run/wrappers/bin:/etc/profiles/per-user/vincent/bin:${config.home.profileDirectory}/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin GOPATH=/home/vincent ASPELL_CONF=dict-dir=/home/vincent/.nix-profile/lib/aspell
+        '';
+        Type      = "forking";
+        ExecStart = "${pkgs.bash}/bin/bash -c 'source /etc/profile; exec /home/vincent/.nix-profile/bin/emacs --daemon'";
+        ExecStop  = "/home/vincent/.nix-profile/bin/emacsclient --eval (kill-emacs)";
+        Restart   = "always";
+      };
+      Install = {
+        WantedBy = [ "default.target" ];
+      };
+    };
+    systemd.user.services.emacs-org = {
+      Unit = {
+        Description = "Emacs: the extensible, self-documenting text editor";
+      };
+      Service = {
+        Environment = ''
+          PATH=/home/vincent/bin:/home/vincent/.local/npm/bin:/run/wrappers/bin:/etc/profiles/per-user/vincent/bin:${config.home.profileDirectory}/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin GOPATH=/home/vincent ASPELL_CONF=dict-dir=/home/vincent/.nix-profile/lib/aspell
+        '';
+        Type      = "forking";
+        ExecStart = "${pkgs.bash}/bin/bash -c 'source /etc/profile; exec /home/vincent/.nix-profile/bin/emacs --daemon=org'";
+        ExecStop  = "/home/vincent/.nix-profile/bin/emacsclient --socket-name=org --eval (kill-emacs)";
+        Restart   = "always";
+      };
+      Install = {
+        WantedBy = [ "default.target" ];
+      };
+    };
+    programs.emacs = {
+      enable = true;
+      # package = pkgs.myEmacs;
+      extraPackages = epkgs: with epkgs; [
+        ace-window
+        aggressive-indent
+        # alert
+        async
+        # auto-yasnippet
+        avy
+        bm
+        command-log-mode
+        company
+        company-emoji
+        company-ghc
+        company-go
+        company-lsp
+        (with melpaPackages; [ company-nixos-options ])
+        #company-restclient
+        #company-shell
+        counsel
+        #counsel-gtags
+        counsel-projectile
+        # counsel-spotify
+        #counsel-tramp
+        #crux
+        dash
+        delight
+        diff-hl
+        diffview
+        dired-collapse
+        dired-sidebar
+        direnv
+        docker
+        docker-compose-mode
+        dockerfile-mode
+        doom-themes
+        #dumb-jump
+        #elpy
+        eshell-bookmark
+        (with melpaPackages; [
+        eshell-prompt-extras
+        esh-autosuggest
+        ])
+        exec-path-from-shell
+        expand-region
+        eyebrowse
+        (with melpaPackages; [ ez-query-replace ])
+        fancy-narrow
+        fish-mode
+        (with melpaPackages; [ fish-completion ])
+        flycheck
+        #flycheck-clojure
+        #flycheck-haskell
+        #flycheck-inline
+        #flycheck-gometalinter
+        flycheck-popup-tip
+        focus
+        fullframe
+        #ggtags
+        #ghub
+        #ghub-plus
+        git-commit
+        #git-timemachine
+        gitattributes-mode
+        gitconfig-mode
+        gitignore-mode
+        (with melpaPackages; [
+          go-add-tags
+          # go-dlv
+          go-eldoc
+          go-errcheck
+          go-fill-struct
+          go-guru
+          # go-impl
+          go-mode
+          #gorepl-mode
+          go-tag
+          gotest
+        ])
+        groovy-mode
+        hardhat
+        #haskell-mode
+        helpful
+        highlight
+        #highlight-escape-sequences
+        #highlight-leading-spaces
+        highlight-numbers
+        highlight-symbol
+        hydra
+        #ialign
+        ibuffer-vc
+        iedit
+        (with melpaPackages; [ imenu-list ])
+        ivy
+        ivy-hydra
+        ivy-pass
+        ivy-rich
+        #jedi
+        #jq-mode
+        js-import
+        js2-mode
+        js2-refactor
+        json-mode
+        json-reformat
+        json-snatcher
+        (with melpaPackages; [
+          key-chord
+          lsp-haskell
+          lsp-javascript-typescript
+          lsp-go
+          lsp-mode
+          lsp-python
+          lsp-rust
+          lsp-ui
+        ])
+        magit
+        magit-gitflow
+        magit-popup
+        magit-todos
+        markdown-mode
+        (with melpaPackages; [ minions moody ])
+        multiple-cursors
+        (with melpaPackages; [
+          nix-buffer
+          nix-mode
+          nix-sandbox
+          nixos-options
+        ])
+        no-littering
+        ob-async
+        ob-go
+        #ob-restclient
+        ob-rust
+        ob-typescript
+        org-plus-contrib
+        org-ref
+        #org-super-agenda
+        #org-web-tools
+        (with melpaPackages; [ org-projectile ])
+        ox-epub
+        ox-hugo
+        ox-ioslide
+        ox-pandoc
+        ox-tufte
+        ox-twbs
+        pandoc-mode
+        pass
+        password-store
+        password-store-otp
+        # persistent-scratch
+        pinentry
+        popup
+        projectile
+        projectile-ripgrep
+        (with melpaPackages; [ pulseaudio-control ])
+        python-mode
+        rainbow-delimiters
+        rainbow-mode
+        ripgrep
+        (with melpaPackages; [ rjsx-mode ])
+        shift-number
+        shackle
+        shx
+        smart-jump
+        (with melpaPackages; [ smartparens ])
+        solaire-mode
+        string-edit
+        #tide
+        toml-mode
+        typescript-mode
+        (with melpaPackages; [ undo-tree ])
+        # (with melpaPackages; [ use-package use-package-chords use-package-ensure-system-package ])
+        (with melpaPackages; [ use-package ])
+        # vdiff
+        visual-fill-column
+        visual-regexp
+        #visual-regexp-steroids
+        #vlf
+        web-mode
+        wgrep
+        which-key
+        # window-purpose
+        with-editor
+        yasnippet
+        yaml-mode
+      ];
+  };  
+  };
+}
modules/profiles/git.nix
@@ -0,0 +1,162 @@
+{ config, lib, pkgs, ... }:
+
+with lib;
+let
+  cfg = config.profiles.git;
+  ca-bundle_crt = "${pkgs.cacert}/etc/ssl/certs/ca-bundle.crt";
+in
+{
+  options = {
+    profiles.git = {
+      enable = mkOption {
+        default = false;
+        description = "Enable git profile";
+        type = types.bool;
+      };
+    };
+  };
+  config = mkIf cfg.enable (mkMerge [
+    {
+      home.packages = with pkgs; [
+        gist
+        git-lfs
+        gitAndTools.gitflow
+        gitAndTools.hub
+        gitAndTools.tig
+        prm
+      ];
+      programs.git = {
+        enable = true;
+    
+        userName = "Vincent Demeester";
+        userEmail = "vincent@sbr.pm";
+    
+        signing = {
+          key = "6EB699A3";
+          signByDefault = false;
+        };
+    
+        aliases = {
+          b = "branch --color -v";
+          br = "branch";
+          ci = "commit --signoff";
+          co = "checkout";
+          conflicts = "!git ls-files --unmerged | cut -c51- | sort -u | xargs $EDITOR";
+          ca = "commit --amend";
+          wdiff = "diff --color-words";
+          unstage = "reset HEAD";
+          lg = "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative";
+          lga = "log --graph --pretty=format:'%Cred%h%Creset -%C(yellow)%d%Creset %s %Cgreen(%cr)%Creset' --abbrev-commit --date=relative --branches --remotes";
+          lol = "log --pretty=oneline --abbrev-commit --graph --decorate";
+          ls-ignored = "ls-files --exclude-standard --ignored --others";
+          resolve = "!git ls-files --unmerged | cut -c51- | sort -u | xargs git add";
+          su = "submodule update --init --recursive";
+          st = "status";
+          w = "status -sb";
+        };
+        extraConfig = {
+          core = {
+            editor = "${pkgs.emacs}/bin/emacsclient -t";
+          };
+          color = {
+            status      = "auto";
+            diff        = "auto";
+            branch      = "auto";
+            interactive = "auto";
+            ui          = "auto";
+            sh          = "auto";
+          };
+          "color \"branch\"" = {
+            current = "cyan reverse";
+            local = "cyan";
+            remote = "green";
+          };
+          "color \"diff\"" = {
+            current = "white reverse";
+            frag = "magenta reverse";
+            old = "red";
+            new = "green";
+          };
+          "color \"status\"" = {
+            added = "green";
+            changed = "yellow";
+            untracked = "red";
+          };
+          hub = {
+            protocol = true;
+          };
+          pull = {
+            rebase = true;
+          };
+          push = {
+            default = "upstream";
+            recurseSubmodules = "check";
+          };
+          rebase = {
+            autosquash = true;
+          };
+          advice = {
+            statusHints = false;
+            pushNonFastForward = false;
+          };
+          http = {
+            sslCAinfo = "${ca-bundle_crt}";
+            sslverify = true;
+          };
+          github.user = "vdemeester";
+          "filter \"lfs\"" = {
+            clean = "${pkgs.git-lfs}/bin/git-lfs clean -- %f";
+            smudge = "${pkgs.git-lfs}/bin/git-lfs smudge --skip -- %f";
+            required = true;
+          };
+          "url \"git@github.com:\"".insteadOf = "git://github.com/";
+        };
+        
+        includes = [
+          {
+            path = "~/.config/git/config.d/redhat.gitconfig";
+            condition = "gitdir:~/src/github.com/knative/";
+          }
+          {
+            path = "~/.config/git/config.d/redhat.gitconfig";
+            condition = "gitdir:~/src/k8s.io/";
+          }
+          {
+            path = "~/.config/git/config.d/redhat.gitconfig";
+            condition = "gitdir:~/src/github.com/minishift/";
+          }
+          {
+            path = "~/.config/git/config.d/redhat.gitconfig";
+            condition = "gitdir:~/src/github.com/operator-framework/";
+          }
+          {
+            path = "~/.config/git/config.d/redhat.gitconfig";
+            condition = "gitdir:~/src/github.com/openshift/";
+          }
+          {
+            path = "~/.config/git/config.d/redhat.gitconfig";
+            condition = "gitdir:~/src/github.com/redhat-developer/";
+          }
+          {
+            path = "~/.config/git/config.d/redhat.gitconfig";
+            condition = "gitdir:~/src/github.com/containers/";
+          }
+        ];
+        ignores = [
+          "*.elc" "*.vo" "*.aux" "*.v.d" "*.o" "*.a" "*.la" "*.so" "*.dylib"
+          "*.pyc" "*.pyo" ".idea" "*.iml"
+          "*~" "#*#" ".makefile" ".clean"
+        ];
+      };
+      xdg.configFile."git/config.d/redhat.gitconfig".source = ./assets/git/redhat.gitconfig;    
+    }
+    (mkIf config.profiles.fish.enable{
+      xdg.configFile."fish/conf.d/git.fish".source = ./assets/fish/git.fish;
+      programs.fish.shellAbbrs = {
+        gs = "git status";
+        gb = "git b";
+        gfr = "git fetch -p --all;and git rebase -S --autostash";
+      };
+    })
+  ]);
+}
modules/module-list.nix
@@ -4,10 +4,13 @@
   imports = [
     ./profiles/bash.nix
     ./profiles/desktop.nix
-    ./profiles/ssh.nix
+    ./profiles/dev.nix
+    ./profiles/emacs.nix
     ./profiles/fish.nix
+    ./profiles/git.nix
     ./profiles/i3.nix
     ./profiles/laptop.nix
+    ./profiles/ssh.nix
     ./profiles/tmux.nix
     ./services/shairport-sync.nix
   ];
dev.go.nix
@@ -1,7 +1,7 @@
 { pkgs, prefix, ... }:
 
 {
-  imports = [ ./dev.nix ];
+  profiles.dev.enable = true;
   xdg.configFile."fish/conf.d/go.fish".source = ./modules/profiles/assets/fish/go.fish;
   programs.fish.shellAbbrs = {
     got = "go test -v";
dev.haskell.nix
@@ -1,7 +1,7 @@
 { pkgs, prefix, ... }:
 
 {
-  imports = [ ./dev.nix ];
+  profiles.dev.enable = true;
   home.packages = with pkgs; [
     ghc
     stack
dev.java.nix
@@ -1,7 +1,7 @@
 { pkgs, prefix, ... }:
 
 {
-  imports = [ ./dev.nix ];
+  profiles.dev.enable = true;
   home.packages = with pkgs; [
     jdk
     gradle
dev.js.nix
@@ -1,7 +1,7 @@
 { pkgs, prefix, ... }:
 
 {
-  imports = [ ./dev.nix ];
+  profiles.dev.enable = true;
   home.file.".npmrc".text = ''
     prefix = ~/.local/npm
   '';
dev.nix
@@ -1,18 +0,0 @@
-{ pkgs, prefix, ... }:
-
-{
-  imports = [ ./git.nix ./emacs.nix ];
-  programs.fish.shellAbbrs = {
-    m = "make";
-  };
-  home.packages = with pkgs; [
-    binutils-unwrapped
-    cmake
-    fswatch
-    gnumake
-    lnav
-    mercurial
-    ripgrep
-    shfmt
-  ];
-}
dev.python.nix
@@ -1,7 +1,7 @@
 { pkgs, prefix, ... }:
 
 {
-  imports = [ ./dev.nix ];
+  profiles.dev.enable = true;
   home.packages = with pkgs; [
     python3
     python36Packages.virtualenv
dev.rust.nix
@@ -1,7 +1,7 @@
 { pkgs, prefix, ... }:
 
 {
-  imports = [ ./dev.nix ];
+  profiles.dev.enable = true;
   home.packages = with pkgs; [
     rustup
   ];
emacs.nix
@@ -1,229 +0,0 @@
-{ pkgs, config, lib, ... }:
-
-{
-  # FIXME update this
-  home.file.".local/share/applications/org-protocol.desktop".source = ./modules/profiles/assets/xorg/org-protocol.desktop;
-  systemd.user.services.emacs = {
-    Unit = {
-      Description = "Emacs: the extensible, self-documenting text editor";
-    };
-    Service = {
-      Environment = ''
-        PATH=/home/vincent/bin:/home/vincent/.local/npm/bin:/run/wrappers/bin:/etc/profiles/per-user/vincent/bin:${config.home.profileDirectory}/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin GOPATH=/home/vincent ASPELL_CONF=dict-dir=/home/vincent/.nix-profile/lib/aspell
-      '';
-      Type      = "forking";
-      ExecStart = "${pkgs.bash}/bin/bash -c 'source /etc/profile; exec /home/vincent/.nix-profile/bin/emacs --daemon'";
-      ExecStop  = "/home/vincent/.nix-profile/bin/emacsclient --eval (kill-emacs)";
-      Restart   = "always";
-    };
-    Install = {
-      WantedBy = [ "default.target" ];
-    };
-  };
-  systemd.user.services.emacs-org = {
-    Unit = {
-      Description = "Emacs: the extensible, self-documenting text editor";
-    };
-    Service = {
-      Environment = ''
-        PATH=/home/vincent/bin:/home/vincent/.local/npm/bin:/run/wrappers/bin:/etc/profiles/per-user/vincent/bin:${config.home.profileDirectory}/bin:/nix/var/nix/profiles/default/bin:/run/current-system/sw/bin GOPATH=/home/vincent ASPELL_CONF=dict-dir=/home/vincent/.nix-profile/lib/aspell
-      '';
-      Type      = "forking";
-      ExecStart = "${pkgs.bash}/bin/bash -c 'source /etc/profile; exec /home/vincent/.nix-profile/bin/emacs --daemon=org'";
-      ExecStop  = "/home/vincent/.nix-profile/bin/emacsclient --socket-name=org --eval (kill-emacs)";
-      Restart   = "always";
-    };
-    Install = {
-      WantedBy = [ "default.target" ];
-    };
-  };
-  programs.emacs = {
-    enable = true;
-    # package = pkgs.myEmacs;
-    extraPackages = epkgs: with epkgs; [
-      ace-window
-      aggressive-indent
-      # alert
-      async
-      # auto-yasnippet
-      avy
-      bm
-      command-log-mode
-      company
-      company-emoji
-      company-ghc
-      company-go
-      company-lsp
-      (with melpaPackages; [ company-nixos-options ])
-      #company-restclient
-      #company-shell
-      counsel
-      #counsel-gtags
-      counsel-projectile
-      # counsel-spotify
-      #counsel-tramp
-      #crux
-      dash
-      delight
-      diff-hl
-      diffview
-      dired-collapse
-      dired-sidebar
-      direnv
-      docker
-      docker-compose-mode
-      dockerfile-mode
-      doom-themes
-      #dumb-jump
-      #elpy
-      eshell-bookmark
-      (with melpaPackages; [
-      eshell-prompt-extras
-      esh-autosuggest
-      ])
-      exec-path-from-shell
-      expand-region
-      eyebrowse
-      (with melpaPackages; [ ez-query-replace ])
-      fancy-narrow
-      fish-mode
-      (with melpaPackages; [ fish-completion ])
-      flycheck
-      #flycheck-clojure
-      #flycheck-haskell
-      #flycheck-inline
-      #flycheck-gometalinter
-      flycheck-popup-tip
-      focus
-      fullframe
-      #ggtags
-      #ghub
-      #ghub-plus
-      git-commit
-      #git-timemachine
-      gitattributes-mode
-      gitconfig-mode
-      gitignore-mode
-      (with melpaPackages; [
-        go-add-tags
-        # go-dlv
-        go-eldoc
-        go-errcheck
-        go-fill-struct
-        go-guru
-        # go-impl
-        go-mode
-        #gorepl-mode
-        go-tag
-        gotest
-      ])
-      groovy-mode
-      hardhat
-      #haskell-mode
-      helpful
-      highlight
-      #highlight-escape-sequences
-      #highlight-leading-spaces
-      highlight-numbers
-      highlight-symbol
-      hydra
-      #ialign
-      ibuffer-vc
-      iedit
-      (with melpaPackages; [ imenu-list ])
-      ivy
-      ivy-hydra
-      ivy-pass
-      ivy-rich
-      #jedi
-      #jq-mode
-      js-import
-      js2-mode
-      js2-refactor
-      json-mode
-      json-reformat
-      json-snatcher
-      (with melpaPackages; [
-        key-chord
-        lsp-haskell
-        lsp-javascript-typescript
-        lsp-go
-        lsp-mode
-        lsp-python
-        lsp-rust
-        lsp-ui
-      ])
-      magit
-      magit-gitflow
-      magit-popup
-      magit-todos
-      markdown-mode
-      (with melpaPackages; [ minions moody ])
-      multiple-cursors
-      (with melpaPackages; [
-        nix-buffer
-        nix-mode
-        nix-sandbox
-        nixos-options
-      ])
-      no-littering
-      ob-async
-      ob-go
-      #ob-restclient
-      ob-rust
-      ob-typescript
-      org-plus-contrib
-      org-ref
-      #org-super-agenda
-      #org-web-tools
-      (with melpaPackages; [ org-projectile ])
-      ox-epub
-      ox-hugo
-      ox-ioslide
-      ox-pandoc
-      ox-tufte
-      ox-twbs
-      pandoc-mode
-      pass
-      password-store
-      password-store-otp
-      # persistent-scratch
-      pinentry
-      popup
-      projectile
-      projectile-ripgrep
-      (with melpaPackages; [ pulseaudio-control ])
-      python-mode
-      rainbow-delimiters
-      rainbow-mode
-      ripgrep
-      (with melpaPackages; [ rjsx-mode ])
-      shift-number
-      shackle
-      shx
-      smart-jump
-      (with melpaPackages; [ smartparens ])
-      solaire-mode
-      string-edit
-      #tide
-      toml-mode
-      typescript-mode
-      (with melpaPackages; [ undo-tree ])
-      # (with melpaPackages; [ use-package use-package-chords use-package-ensure-system-package ])
-      (with melpaPackages; [ use-package ])
-      # vdiff
-      visual-fill-column
-      visual-regexp
-      #visual-regexp-steroids
-      #vlf
-      web-mode
-      wgrep
-      which-key
-      # window-purpose
-      with-editor
-      yasnippet
-      yaml-mode
-    ];
-  };
-}
-