diff --git a/machines/thaylen-city/default.nix b/machines/thaylen-city/default.nix index 6cbf0e18..88c76f72 100644 --- a/machines/thaylen-city/default.nix +++ b/machines/thaylen-city/default.nix @@ -5,6 +5,10 @@ homeStateVersion = "24.11"; systemStateVersion = 4; username = "charlotte.vanpetegem"; + development = { + enable = true; + git.email = "charlotte.vanpetegem@silverfin.com"; + }; }; networking.computerName = "Thaylen City"; @@ -54,34 +58,5 @@ startup.chime = false; }; - home-manager.users."charlotte.vanpetegem" = { - programs.git = { - enable = true; - extraConfig = { - branch.autosetuprebase = "always"; - github.user = "chvp"; - merge.conflictStyle = "diff3"; - pull.rebase = true; - rerere.enabled = true; - rebase.autoStash = true; - }; - ignores = [ - ".DS_Store" - ".data" - ".direnv" - ".envrc" - ".idea" - ".dir-locals.el" - ]; - userEmail = "charlotte.vanpetegem@silverfin.com"; - userName = "Charlotte Van Petegem"; - }; - - home = { - packages = with pkgs; [ - docker-compose - tmux - ]; - }; - }; + home-manager.users."charlotte.vanpetegem".home.packages = with pkgs; [ docker-compose ]; } diff --git a/modules/nixos/development/default.nix b/modules/nixos/development/default.nix index 2d1950e8..2a6a4ae2 100644 --- a/modules/nixos/development/default.nix +++ b/modules/nixos/development/default.nix @@ -7,175 +7,8 @@ ./git ]; - options.chvp.development.enable = lib.mkOption { - default = false; - example = true; - }; - config = lib.mkIf config.chvp.development.enable { - chvp = { - base.emacs.extraConfig = [ - '' - ;; Editorconfig - (use-package editorconfig - :diminish (editorconfig-mode) - :config - (editorconfig-mode 1) - ) - - ;; R syntax support - (use-package ess - :init - (load "ess-autoloads") - :mode ("\\.r\\'" . ess-r-mode) - :mode ("\\.R\\'" . ess-r-mode) - ) - - ;; Language server support - (use-package eglot - :demand t - :general - (lmap - :keymaps '(prog-mode-map vue-mode-map) - "SPC s" '(eglot :which-key "Add buffer to eglot") - "SPC f" '(eglot-format :which-key "Format region") - "SPC F" '(eglot-format :which-key "Format buffer") - "SPC r" '(eglot-rename :which-key "Rename symbol") - "SPC a" '(eglot-code-actions :which-key "Relevant local actions") - "SPC n" '(flymake-goto-next-error :which-key "Next error") - "SPC p" '(flymake-goto-prev-error :which-key "Previous error") - ) - :hook (eglot-managed-mode . chvp--eglot-capf) - :config - (advice-add 'eglot-completion-at-point :around #'cape-wrap-buster) - (defun chvp--eglot-capf () - (setq-local completion-at-point-functions - (list (cape-super-capf - #'eglot-completion-at-point - #'tempel-complete) - #'cape-file - #'dabbrev-capf - #'cape-line))) - ) - - ;; Forth syntax support - (use-package forth-mode - :mode ("\\.fs\\'" . forth-mode) - :mode ("\\.fb\\'" . forth-block-mode) - ) - - ;; Markdown syntax support - (use-package markdown-mode - :commands (markdown-mode gfm-mode) - :mode ("README\\.md\\'" . gfm-mode) - :mode ("\\.md\\'" . markdown-mode) - :mode ("\\.markdown\\'" . markdown-mode) - ) - - ;; Haskell language support - (use-package haskell-mode - :mode "\\.hs\\'" - :config - (require 'haskell-doc) - ) - - ;; Folding - (use-package origami - :hook (prog-mode . origami-mode) - ) - - ;; Python syntax support - (use-package python-mode - :mode "\\.py\\'" - ) - - ;; Ruby language support - (use-package ruby-mode - :ensure nil ;; Included with emacs - :mode "\\.\\(?:cap\\|gemspec\\|irbrc\\|gemrc\\|rake\\|rb\\|ru\\|thor\\)\\'" - :mode "\\(?:Brewfile\\|Capfile\\|Gemfile\\(?:\\.[a-zA-Z0-9._-]+\\)?\\|[rR]akefile\\)\\'" - :custom - (ruby-insert-encoding-magic-comment nil "Don't insert encoding magic comment") - ) - - ;; Rust language support - (use-package rust-mode - :mode "\\.rs\\'" - ) - - ;; TypeScript language support - (use-package typescript-mode - :mode "\\.ts\\'" - ) - - ;; Vue language support - (use-package vue-mode - :mode "\\.vue\\'" - :custom - (mmm-submode-decoration-level 0 "Don't color submodes differently") - :config - (defun vue-eglot-init-options () - (let ((tsdk-path "${pkgs.typescript}/lib/node_modules/typescript/lib")) - `(:typescript (:tsdk ,tsdk-path - :languageFeatures (:completion - (:defaultTagNameCase "kebab" - :defaultAttrNameCase "kebab" - :getDocumentNameCasesRequest nil - :getDocumentSelectionRequest nil) - :diagnostics - (:getDocumentVersionRequest nil)) - :documentFeatures (:documentFormatting - (:defaultPrintWidth 100 - :getDocumentPrintWidthRequest nil) - :documentSymbol t - :documentColor t))))) - (add-to-list 'eglot-server-programs `(vue-mode . ("${pkgs.vue-language-server}/bin/vue-language-server" "--stdio" :initializationOptions ,(vue-eglot-init-options)))) - (setq vue--front-tag-lang-regex - (concat "<%s" ; The tag name - "\\(?:" ; Zero of more of... - "\\(?:\\s-+\\w+=[\"'].*?[\"']\\)" ; Any optional key-value pairs like type="foo/bar" - "\\|\\(?:\\s-+scoped\\)" ; The optional "scoped" attribute - "\\|\\(?:\\s-+module\\)" ; The optional "module" attribute - "\\|\\(?:\\s-+setup\\)" ; The optional "setup" attribute - "\\)*" - "\\(?:\\s-+lang=[\"']%s[\"']\\)" ; The language specifier (required) - "\\(?:" ; Zero of more of... - "\\(?:\\s-+\\w+=[\"'].*?[\"']\\)" ; Any optional key-value pairs like type="foo/bar" - "\\|\\(?:\\s-+scoped\\)" ; The optional "scoped" attribute - "\\|\\(?:\\s-+module\\)" ; The optional "module" attribute - "\\|\\(?:\\s-+setup\\)" ; The optional "setup" attribute - "\\)*" - " *>\n")) ; The end of the tag - (setq vue--front-tag-regex - (concat "<%s" ; The tag name - "\\(?:" ; Zero of more of... - "\\(?:\\s-+" vue--not-lang-key "[\"'][^\"']*?[\"']\\)" ; Any optional key-value pairs like type="foo/bar". - ;; ^ Disallow "lang" in k/v pairs to avoid matching regions with non-default languages - "\\|\\(?:\\s-+scoped\\)" ; The optional "scoped" attribute - "\\|\\(?:\\s-+module\\)" ; The optional "module" attribute - "\\|\\(?:\\s-+setup\\)" ; The optional "setup" attribute - "\\)*" - "\\s-*>\n")) ; The end of the tag - ) - - ;; HTML (and HTML template) support - (use-package web-mode - :mode "\\.html\\'" - :mode "\\.html\\.erb\\'" - ) - - ;; YAML syntax support - (use-package yaml-mode - :mode "\\.yml\\'" - :mode "\\.yaml\\'" - ) - '' - ]; - development = { - docker.enable = lib.mkDefault true; - git.enable = lib.mkDefault true; - }; - }; + chvp.development.docker.enable = lib.mkDefault true; users.users.charlotte.extraGroups = [ "dialout" "uucp" ]; diff --git a/modules/nixos/development/git/default.nix b/modules/nixos/development/git/default.nix index e3134f5f..a25fae9c 100644 --- a/modules/nixos/development/git/default.nix +++ b/modules/nixos/development/git/default.nix @@ -1,94 +1,11 @@ { config, lib, pkgs, ... }: { - options.chvp.development.git = { - enable = lib.mkOption { - default = false; - example = true; - }; - email = lib.mkOption { - type = lib.types.str; - default = "charlotte@vanpetegem.be"; - example = "charlotte@vanpetegem.be"; - description = '' - Default email set in global git config. - ''; + home-manager.users.charlotte.programs.git = lib.mkIf config.chvp.development.git.enable { + extraConfig.tag.gpgSign = config.chvp.graphical.enable; + signing = { + key = "charlotte@vanpetegem.me"; + signByDefault = config.chvp.graphical.enable; }; }; - - config = - let - base = { - programs.git = { - enable = true; - lfs.enable = true; - extraConfig = { - branch.autosetuprebase = "always"; - github.user = "chvp"; - merge.conflictStyle = "diff3"; - pull.rebase = true; - rerere.enabled = true; - tag.gpgSign = true; - }; - ignores = [ - ".data" - ".direnv" - ".envrc" - ".dir-locals.el" - ]; - signing = { - key = "charlotte@vanpetegem.me"; - signByDefault = config.chvp.graphical.enable; - }; - userEmail = config.chvp.development.git.email; - userName = "Charlotte Van Petegem"; - }; - }; - in - lib.mkIf config.chvp.development.git.enable { - chvp.base.emacs.extraConfig = [ - '' - ;; Magit GitHub/GitLab integration - (use-package forge - :after magit) - - ;; Git integration - (use-package magit - :init - (setq forge-add-default-bindings nil) - :general - (lmap - "g" '(:ignore t :which-key "git") - "gs" '(magit-status :which-key "status") - ) - ) - - ;; Project management - (use-package project - :custom - (project-switch-commands - '( - (project-find-file "find file") - (consult-ripgrep "find regexp" ?r) - (project-eshell "eshell") - ) - "Change default actions when switching project" - ) - :general - (lmap - "p" '(:ignore t :which-key "project") - "pf" '(project-find-file :which-key "find") - "pp" '(project-switch-project :which-key "switch") - "pr" '(project-query-replace-regexp :which-key "replace") - "ps" '(consult-ripgrep :search "incsearch") - "pS" '(project-find-regexp :which-key "search") - "p!" '(project-shell-command :which-key "command") - "p&" '(project-async-shell-command :which-key "task") - ) - ) - '' - ]; - home-manager.users.charlotte = { ... }: base; - home-manager.users.root = { ... }: base; - }; } diff --git a/modules/shared/default.nix b/modules/shared/default.nix index 54e8d2d3..ad2481cc 100644 --- a/modules/shared/default.nix +++ b/modules/shared/default.nix @@ -3,5 +3,6 @@ { imports = [ ./base + ./development ]; } diff --git a/modules/shared/development/default.nix b/modules/shared/development/default.nix new file mode 100644 index 00000000..7da43c2a --- /dev/null +++ b/modules/shared/development/default.nix @@ -0,0 +1,175 @@ +{ config, lib, pkgs, ... }: + +{ + imports = [ + ./git + ]; + + options.chvp.development.enable = lib.mkOption { + default = false; + example = true; + }; + + config = lib.mkIf config.chvp.development.enable { + chvp = { + base.emacs.extraConfig = [ + '' + ;; Editorconfig + (use-package editorconfig + :diminish (editorconfig-mode) + :config + (editorconfig-mode 1) + ) + + ;; R syntax support + (use-package ess + :init + (load "ess-autoloads") + :mode ("\\.r\\'" . ess-r-mode) + :mode ("\\.R\\'" . ess-r-mode) + ) + + ;; Language server support + (use-package eglot + :demand t + :general + (lmap + :keymaps '(prog-mode-map vue-mode-map) + "SPC s" '(eglot :which-key "Add buffer to eglot") + "SPC f" '(eglot-format :which-key "Format region") + "SPC F" '(eglot-format :which-key "Format buffer") + "SPC r" '(eglot-rename :which-key "Rename symbol") + "SPC a" '(eglot-code-actions :which-key "Relevant local actions") + "SPC n" '(flymake-goto-next-error :which-key "Next error") + "SPC p" '(flymake-goto-prev-error :which-key "Previous error") + ) + :hook (eglot-managed-mode . chvp--eglot-capf) + :config + (advice-add 'eglot-completion-at-point :around #'cape-wrap-buster) + (defun chvp--eglot-capf () + (setq-local completion-at-point-functions + (list (cape-super-capf + #'eglot-completion-at-point + #'tempel-complete) + #'cape-file + #'dabbrev-capf + #'cape-line))) + ) + + ;; Forth syntax support + (use-package forth-mode + :mode ("\\.fs\\'" . forth-mode) + :mode ("\\.fb\\'" . forth-block-mode) + ) + + ;; Markdown syntax support + (use-package markdown-mode + :commands (markdown-mode gfm-mode) + :mode ("README\\.md\\'" . gfm-mode) + :mode ("\\.md\\'" . markdown-mode) + :mode ("\\.markdown\\'" . markdown-mode) + ) + + ;; Haskell language support + (use-package haskell-mode + :mode "\\.hs\\'" + :config + (require 'haskell-doc) + ) + + ;; Folding + (use-package origami + :hook (prog-mode . origami-mode) + ) + + ;; Python syntax support + (use-package python-mode + :mode "\\.py\\'" + ) + + ;; Ruby language support + (use-package ruby-mode + :ensure nil ;; Included with emacs + :mode "\\.\\(?:cap\\|gemspec\\|irbrc\\|gemrc\\|rake\\|rb\\|ru\\|thor\\)\\'" + :mode "\\(?:Brewfile\\|Capfile\\|Gemfile\\(?:\\.[a-zA-Z0-9._-]+\\)?\\|[rR]akefile\\)\\'" + :custom + (ruby-insert-encoding-magic-comment nil "Don't insert encoding magic comment") + ) + + ;; Rust language support + (use-package rust-mode + :mode "\\.rs\\'" + ) + + ;; TypeScript language support + (use-package typescript-mode + :mode "\\.ts\\'" + ) + + ;; Vue language support + (use-package vue-mode + :mode "\\.vue\\'" + :custom + (mmm-submode-decoration-level 0 "Don't color submodes differently") + :config + (defun vue-eglot-init-options () + (let ((tsdk-path "${pkgs.typescript}/lib/node_modules/typescript/lib")) + `(:typescript (:tsdk ,tsdk-path + :languageFeatures (:completion + (:defaultTagNameCase "kebab" + :defaultAttrNameCase "kebab" + :getDocumentNameCasesRequest nil + :getDocumentSelectionRequest nil) + :diagnostics + (:getDocumentVersionRequest nil)) + :documentFeatures (:documentFormatting + (:defaultPrintWidth 100 + :getDocumentPrintWidthRequest nil) + :documentSymbol t + :documentColor t))))) + (add-to-list 'eglot-server-programs `(vue-mode . ("${pkgs.vue-language-server}/bin/vue-language-server" "--stdio" :initializationOptions ,(vue-eglot-init-options)))) + (setq vue--front-tag-lang-regex + (concat "<%s" ; The tag name + "\\(?:" ; Zero of more of... + "\\(?:\\s-+\\w+=[\"'].*?[\"']\\)" ; Any optional key-value pairs like type="foo/bar" + "\\|\\(?:\\s-+scoped\\)" ; The optional "scoped" attribute + "\\|\\(?:\\s-+module\\)" ; The optional "module" attribute + "\\|\\(?:\\s-+setup\\)" ; The optional "setup" attribute + "\\)*" + "\\(?:\\s-+lang=[\"']%s[\"']\\)" ; The language specifier (required) + "\\(?:" ; Zero of more of... + "\\(?:\\s-+\\w+=[\"'].*?[\"']\\)" ; Any optional key-value pairs like type="foo/bar" + "\\|\\(?:\\s-+scoped\\)" ; The optional "scoped" attribute + "\\|\\(?:\\s-+module\\)" ; The optional "module" attribute + "\\|\\(?:\\s-+setup\\)" ; The optional "setup" attribute + "\\)*" + " *>\n")) ; The end of the tag + (setq vue--front-tag-regex + (concat "<%s" ; The tag name + "\\(?:" ; Zero of more of... + "\\(?:\\s-+" vue--not-lang-key "[\"'][^\"']*?[\"']\\)" ; Any optional key-value pairs like type="foo/bar". + ;; ^ Disallow "lang" in k/v pairs to avoid matching regions with non-default languages + "\\|\\(?:\\s-+scoped\\)" ; The optional "scoped" attribute + "\\|\\(?:\\s-+module\\)" ; The optional "module" attribute + "\\|\\(?:\\s-+setup\\)" ; The optional "setup" attribute + "\\)*" + "\\s-*>\n")) ; The end of the tag + ) + + ;; HTML (and HTML template) support + (use-package web-mode + :mode "\\.html\\'" + :mode "\\.html\\.erb\\'" + ) + + ;; YAML syntax support + (use-package yaml-mode + :mode "\\.yml\\'" + :mode "\\.yaml\\'" + ) + '' + ]; + development.git.enable = lib.mkDefault true; + }; + }; +} diff --git a/modules/shared/development/git/default.nix b/modules/shared/development/git/default.nix new file mode 100644 index 00000000..4b168eb2 --- /dev/null +++ b/modules/shared/development/git/default.nix @@ -0,0 +1,90 @@ +{ config, lib, pkgs, ... }: + +let + username = config.chvp.username; +in +{ + options.chvp.development.git = { + enable = lib.mkOption { + default = false; + example = true; + }; + email = lib.mkOption { + type = lib.types.str; + default = "charlotte@vanpetegem.be"; + example = "charlotte@vanpetegem.be"; + description = '' + Default email set in global git config. + ''; + }; + }; + + config = lib.mkIf config.chvp.development.git.enable { + chvp.base.emacs.extraConfig = [ + '' + ;; Magit GitHub/GitLab integration + (use-package forge + :after magit) + + ;; Git integration + (use-package magit + :init + (setq forge-add-default-bindings nil) + :general + (lmap + "g" '(:ignore t :which-key "git") + "gs" '(magit-status :which-key "status") + ) + ) + + ;; Project management + (use-package project + :custom + (project-switch-commands + '( + (project-find-file "find file") + (consult-ripgrep "find regexp" ?r) + (project-eshell "eshell") + ) + "Change default actions when switching project" + ) + :general + (lmap + "p" '(:ignore t :which-key "project") + "pf" '(project-find-file :which-key "find") + "pp" '(project-switch-project :which-key "switch") + "pr" '(project-query-replace-regexp :which-key "replace") + "ps" '(consult-ripgrep :search "incsearch") + "pS" '(project-find-regexp :which-key "search") + "p!" '(project-shell-command :which-key "command") + "p&" '(project-async-shell-command :which-key "task") + ) + ) + '' + ]; + home-manager.users.${username} = { + programs.git = { + enable = true; + lfs.enable = true; + extraConfig = { + branch.autosetuprebase = "always"; + github.user = "chvp"; + merge.conflictStyle = "diff3"; + pull.rebase = true; + rebase.autoStash = true; + rerere.enabled = true; + }; + ignores = [ + ".DS_Store" + ".data" + ".direnv" + ".envrc" + ".idea" + ".dir-locals.el" + ]; + userEmail = config.chvp.development.git.email; + userName = "Charlotte Van Petegem"; + }; + }; + }; +}