diff --git a/flake.lock b/flake.lock index ce059c1..508ec4c 100644 --- a/flake.lock +++ b/flake.lock @@ -17,13 +17,50 @@ "url": "https://git.nani.wtf/h7x4/dotfiles" } }, - "flake-utils": { + "flake-compat": { + "flake": false, "locked": { - "lastModified": 1659877975, - "narHash": "sha256-zllb8aq3YO3h8B/U0/J1WBgAL8EX5yWf5pMj3G0NAmc=", + "lastModified": 1673956053, + "narHash": "sha256-4gtG9iQuiKITOjNQQeQIpoIB6b16fm+504Ch3sNKLd8=", + "owner": "edolstra", + "repo": "flake-compat", + "rev": "35bb57c0c8d8b62bbfd284272c928ceb64ddbde9", + "type": "github" + }, + "original": { + "owner": "edolstra", + "repo": "flake-compat", + "type": "github" + } + }, + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1681202837, + "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", "owner": "numtide", "repo": "flake-utils", - "rev": "c0e246b9b83f637f4681389ecabcb2681b4f3af0", + "rev": "cfacdce06f30d2b68473a46042957675eebb3401", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "flake-utils_2": { + "inputs": { + "systems": "systems_2" + }, + "locked": { + "lastModified": 1681202837, + "narHash": "sha256-H+Rh19JDwRtpVPAWp64F+rlEtxUWBAQW28eAi3SRSzg=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "cfacdce06f30d2b68473a46042957675eebb3401", "type": "github" }, "original": { @@ -49,20 +86,19 @@ "inputs": { "nixpkgs": [ "nixpkgs" - ], - "utils": "utils" + ] }, "locked": { - "lastModified": 1677284824, - "narHash": "sha256-I3gDxmGjyXdtOR5S8sIeCO8pT+5OR69f/g5EVoQUdsY=", + "lastModified": 1687871164, + "narHash": "sha256-bBFlPthuYX322xOlpJvkjUBz0C+MOBjZdDOOJJ+G2jU=", "owner": "nix-community", "repo": "home-manager", - "rev": "29280978234b73423f4eb708cbb999295f76b42a", + "rev": "07c347bb50994691d7b0095f45ebd8838cf6bc38", "type": "github" }, "original": { "owner": "nix-community", - "ref": "release-22.11", + "ref": "release-23.05", "repo": "home-manager", "type": "github" } @@ -72,11 +108,14 @@ "nixpkgs": [ "nixpkgs-unstable" ], - "utils": "utils_2" + "utils": "utils" }, "locked": { - "lastModified": 1669760368, - "narHash": "sha256-RrFktfI837C7MEiR5PFibQXS2TXzkXcnk9FQgTm9bh4=", + "lastModified": 1677801246, + "narHash": "sha256-/TeSHBkg4gGBsrOjnPxV0YnCIfpYeaMNPcfuj9HeR48=", + "ref": "refs/heads/zellij-kdl-configuration-generator", + "rev": "35ccc428a2b95182a3ca96824d838fd24a738641", + "revCount": 2378, "type": "git", "url": "file:///home/h7x4/git/home-manager" }, @@ -90,11 +129,11 @@ "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1676674799, - "narHash": "sha256-NaZWOgNrco5OT0J5VrWg02SCkKz8RV1sxRjh0/MWMEc=", + "lastModified": 1689214560, + "narHash": "sha256-2vXE3S68YeWhxRm7SdUD9Ac0xwDl9MHEGaGP8MdZa9c=", "owner": "dali99", "repo": "nixos-matrix-modules", - "rev": "362496f4aacb680406db3fad36f98d38e8285b30", + "rev": "c158a35ea298ce3ea7cd446e9992154ea4bc6381", "type": "github" }, "original": { @@ -140,15 +179,18 @@ }, "minecraft": { "inputs": { + "flake-compat": "flake-compat", "flake-utils": "flake-utils", - "nixpkgs": "nixpkgs_2" + "nixpkgs": [ + "nixpkgs-unstable" + ] }, "locked": { - "lastModified": 1677376635, - "narHash": "sha256-ESBC0dvaCpbhUs3DvWxC0JMF6BoKo6xPCaqICvOyPNg=", + "lastModified": 1690076623, + "narHash": "sha256-k1AE76m7N9JVKCz0rjGPNez15rSVsDYS0l6XxfEAH88=", "owner": "infinidoge", "repo": "nix-minecraft", - "rev": "fa5b93f66b355d6b549d0d19733030f2eb09209e", + "rev": "8706036acb4955f9d30f789dea1c42549944ce2e", "type": "github" }, "original": { @@ -210,13 +252,29 @@ "type": "github" } }, - "nixpkgs-unstable": { + "nixpkgs-stable": { "locked": { - "lastModified": 1677342105, - "narHash": "sha256-kv1fpkfCJGb0M+LZaCHFUuIS9kRIwyVgupHu86Y28nc=", + "lastModified": 1689473667, + "narHash": "sha256-41ePf1ylHMTogSPAiufqvBbBos+gtB6zjQlYFSEKFMM=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "b1f87ca164a9684404c8829b851c3586c4d9f089", + "rev": "13231eccfa1da771afa5c0807fdd73e05a1ec4e6", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "release-23.05", + "repo": "nixpkgs", + "type": "github" + } + }, + "nixpkgs-unstable": { + "locked": { + "lastModified": 1690031011, + "narHash": "sha256-kzK0P4Smt7CL53YCdZCBbt9uBFFhE0iNvCki20etAf4=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "12303c652b881435065a98729eb7278313041e49", "type": "github" }, "original": { @@ -227,68 +285,69 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1666198336, - "narHash": "sha256-VTrWD8Bb48h2pi57P1++LuvZIgum3gSLiRzZ/8q3rg0=", - "owner": "nixos", + "lastModified": 1689956312, + "narHash": "sha256-NV9yamMhE5jgz+ZSM2IgXeYqOvmGIbIIJ+AFIhfD7Ek=", + "owner": "NixOS", "repo": "nixpkgs", - "rev": "db25c4da285c5989b39e4ce13dea651a88b7a9d4", + "rev": "6da4bc6cb07cba1b8e53d139cbf1d2fb8061d967", "type": "github" }, "original": { - "owner": "nixos", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" + "id": "nixpkgs", + "ref": "nixos-23.05", + "type": "indirect" } }, "nixpkgs_3": { "locked": { - "lastModified": 1677341534, - "narHash": "sha256-zqaJuOTnKzg5AubC4rzzJ/IS5kU5n4U7vxosv1Fv8Ug=", + "lastModified": 1689413807, + "narHash": "sha256-exuzOvOhGAEKWQKwDuZAL4N8a1I837hH5eocaTcIbLc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "7076110064c09f0b3942f609f2134c1358ef2e50", + "rev": "46ed466081b9cad1125b11f11a2af5cc40b942c7", "type": "github" }, "original": { - "id": "nixpkgs", - "ref": "nixos-22.11", - "type": "indirect" + "owner": "NixOS", + "ref": "nixpkgs-unstable", + "repo": "nixpkgs", + "type": "github" } }, "nixpkgs_4": { "locked": { - "lastModified": 1670193339, - "narHash": "sha256-oHTAhX4p6+uxcabq0rKL4EyKWPbDLGKec88ocPIU/2Y=", + "lastModified": 1682134069, + "narHash": "sha256-TnI/ZXSmRxQDt2sjRYK/8j8iha4B4zP2cnQCZZ3vp7k=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "e169cf5b3b1e6cc4a25ff15087c2621605f83409", + "rev": "fd901ef4bf93499374c5af385b2943f5801c0833", "type": "github" }, "original": { "id": "nixpkgs", - "ref": "nixos-22.11", "type": "indirect" } }, "nixpkgs_5": { "locked": { - "lastModified": 1667254466, - "narHash": "sha256-YrMQzDVOo+uz5gg1REj2q/uVhJE3WcpkqGiMzh3Da3o=", + "lastModified": 1678426640, + "narHash": "sha256-3Q4KN0XAXQT7YE3A8n3LzLtRNUCo0U++W3gl+5NhKHs=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "1b4722674c315de0e191d0d79790b4eac51570a1", + "rev": "824f886682fc893e6dbf27114e5001ebf2770ea1", "type": "github" }, "original": { "id": "nixpkgs", - "ref": "nixos-22.05", + "ref": "nixos-22.11", "type": "indirect" } }, "osuchan": { "inputs": { - "nixpkgs": "nixpkgs_4" + "nixpkgs": [ + "nixpkgs" + ] }, "locked": { "lastModified": 1672838459, @@ -314,10 +373,11 @@ "maunium-stickerpicker": "maunium-stickerpicker", "minecraft": "minecraft", "nix-attr-search": "nix-attr-search", - "nixpkgs": "nixpkgs_3", + "nixpkgs": "nixpkgs_2", "nixpkgs-unstable": "nixpkgs-unstable", "osuchan": "osuchan", "secrets": "secrets", + "sops-nix": "sops-nix", "vscode-server": "vscode-server", "website": "website" } @@ -329,8 +389,8 @@ ] }, "locked": { - "lastModified": 1677374425, - "narHash": "sha256-rcXsPpdbcm/9ULPhldGW9FbroC9y+Vt/HRMGBuJ5lmY=", + "lastModified": 1683506783, + "narHash": "sha256-TEJGASqT3Ro1d3t+gKEc9NFOBqb0feVR2HqeZ8o3DGs=", "type": "git", "url": "file:///home/h7x4/git/nix-secrets" }, @@ -339,6 +399,55 @@ "url": "file:///home/h7x4/git/nix-secrets" } }, + "sops-nix": { + "inputs": { + "nixpkgs": "nixpkgs_3", + "nixpkgs-stable": "nixpkgs-stable" + }, + "locked": { + "lastModified": 1689534977, + "narHash": "sha256-EB4hasmjKgetTR0My2bS5AwELZFIQ4zANLqHKi7aVXg=", + "owner": "Mic92", + "repo": "sops-nix", + "rev": "bd695cc4d0a5e1bead703cc1bec5fa3094820a81", + "type": "github" + }, + "original": { + "owner": "Mic92", + "repo": "sops-nix", + "type": "github" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, + "systems_2": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + }, "utils": { "locked": { "lastModified": 1667395993, @@ -354,33 +463,21 @@ "type": "github" } }, - "utils_2": { - "locked": { - "lastModified": 1667395993, - "narHash": "sha256-nuEHfE/LcWyuSWnS8t12N1wc105Qtau+/OdUAjtQ0rA=", - "owner": "numtide", - "repo": "flake-utils", - "rev": "5aed5285a952e0b949eb3ba02c12fa4fcfef535f", - "type": "github" - }, - "original": { - "owner": "numtide", - "repo": "flake-utils", - "type": "github" - } - }, "vscode-server": { - "flake": false, + "inputs": { + "flake-utils": "flake-utils_2", + "nixpkgs": "nixpkgs_4" + }, "locked": { - "lastModified": 1676501444, - "narHash": "sha256-H+uQetkzd5GIga56HmCDwl5eihdQgeN2jVdNrkXzDyo=", - "owner": "msteen", + "lastModified": 1684517665, + "narHash": "sha256-SaAr66uCQ8CF75jIr23FZjk1+9Kfwm5sQnwV25206Gs=", + "owner": "nix-community", "repo": "nixos-vscode-server", - "rev": "57f1716bc625d2892579294cc207956679e3d94c", + "rev": "1e1358493df6529d4c7bc4cc3066f76fd16d4ae6", "type": "github" }, "original": { - "owner": "msteen", + "owner": "nix-community", "repo": "nixos-vscode-server", "type": "github" } @@ -390,11 +487,11 @@ "nixpkgs": "nixpkgs_5" }, "locked": { - "lastModified": 1667672395, - "narHash": "sha256-YM6GmD6jJejuAV9/t8p8++IbEXs6ooy0SvSDmNpSZ58=", + "lastModified": 1678656410, + "narHash": "sha256-VfFki6R7FGX8n/TX5n5+S6RxiFpxaZkgzPVHMlGzpQ4=", "ref": "main", - "rev": "669ded6d45c2932dcacbe97b385ca01d093229af", - "revCount": 73, + "rev": "44697feb499a85536d69841e6832e18a94ea769b", + "revCount": 75, "type": "git", "url": "https://git.nani.wtf/h7x4/nani.wtf" }, diff --git a/flake.nix b/flake.nix index d84a1df..2ea73ea 100644 --- a/flake.nix +++ b/flake.nix @@ -104,7 +104,18 @@ in [ (self: super: { kanidm = nonrecursive-unstable-pkgs.kanidm; }) (self: super: { pgadmin4 = nonrecursive-unstable-pkgs.pgadmin4; }) + (self: super: { pcloud = unstable-pkgs.callPackage ./package-overrides/pcloud.nix {}; }) osuchan.overlays.default + (self: super: { + mpv-unwrapped = super.mpv-unwrapped.override { + ffmpeg_5 = super.ffmpeg_5-full; + }; + }) + # (self: super: { + # systemd = super.systemd.overrideAttrs (final: prev: { + # mesonFlags = prev.mesonFlags ++ [ "-Dsystemd-socket-proxyd=true" ]; + # }); + # }) ]; }; @@ -115,6 +126,10 @@ inherit pkgs; + packages.${system} = { + inherit (pkgs) kanidm pcloud; + }; + devShells.${system}.default = pkgs.mkShell { packages = with pkgs; [ sops ]; }; diff --git a/home/config/xdg/mimetypes.nix b/home/config/xdg/mimetypes.nix index 5ad1717..9e09ec6 100644 --- a/home/config/xdg/mimetypes.nix +++ b/home/config/xdg/mimetypes.nix @@ -80,7 +80,7 @@ let in { - xdg.dataFile."applications/mimeapps.list".force = true; + xdg.configFile."mimeapps.list".force = true; xdg.mimeApps = { enable = true; # associations.added = {}; diff --git a/home/home.nix b/home/home.nix index a0ba35d..77d0008 100644 --- a/home/home.nix +++ b/home/home.nix @@ -47,6 +47,7 @@ in { ./services/polybar.nix ./services/stalonetray.nix ./services/sxhkd.nix + ./services/copyq.nix ]; home = { @@ -121,7 +122,7 @@ in { services = { gnome-keyring.enable = mkIf graphics true; - dropbox.enable = true; + # dropbox.enable = true; network-manager-applet.enable = mkIf graphics true; # redshift.enable = true; }; diff --git a/home/packages.nix b/home/packages.nix index d8bbb60..68b728b 100644 --- a/home/packages.nix +++ b/home/packages.nix @@ -61,6 +61,7 @@ in { nix-output-monitor nix-tree nix-zsh-completions + nixpkgs-review # nixops nmap ouch @@ -120,11 +121,9 @@ in { birdtray calibre cool-retro-term - copyq darktable discord element-desktop - fcitx geogebra gimp gnome.gnome-font-viewer @@ -156,7 +155,7 @@ in { shellcheck slack sublime3 - swiPrologWithGui + # swiPrologWithGui sxiv tagainijisho teams @@ -178,7 +177,7 @@ in { xmonad-log # xsnow # Wait until christmas - yubioath-desktop + yubioath-flutter yuzu-mainline zeal zoom-us diff --git a/home/programs/emacs/config.el b/home/programs/emacs/config.el new file mode 100644 index 0000000..32d7abf --- /dev/null +++ b/home/programs/emacs/config.el @@ -0,0 +1,1415 @@ +;;; ~/.emacs.d/config.el -*- lexical-binding: t; -*- + +; (setq user-emacs-directory (substitute-in-file-name "$HOME/.emacs.d")) + +(require 'package) +(add-to-list 'package-archives '("melpa" . "https://melpa.org/packages/") t) + +(package-initialize) +(unless (package-installed-p 'use-package) + (package-refresh-contents) + (package-install 'use-package)) + +(require 'use-package) +(setq use-package-always-ensure t) + +(use-package general + :config + (general-evil-setup) + + (general-create-definer leader-key + ; :states 'normal + :states 'motion + :prefix "SPC" + :non-normal-prefix "C-SPC")) + +(leader-key + "" nil + "c" (general-simulate-key "C-c" :which-key "C-c") + "u" (general-simulate-key "C-u" :which-key "C-u") + "x" (general-simulate-key "C-x" :which-key "C-x") + + "m" '(:ignore t :which-key "mode") + "mx" 'nil + + ;; Help + "h" (general-simulate-key "" :which-key "C-h") + + ;; Insert + "i" '(:ignore t :which-key "C-h") + "ix" 'nil + + ;; Package manager + ;; "p" '(:ignore t :which-key "packages") + ;; "pl" 'list-packages + + ;; Quit operations + "q" '(:ignore t :which-key "quit emacs") + "qq" 'kill-emacs + "qz" 'delete-frame + + ;; Buffer operations + "b" '(:ignore t :which-key "buffer") + "bb" 'mode-line-other-buffer + "bk" 'kill-this-buffer + ;; "bn" 'next-buffer + ;; "bp" 'previous-buffer + "bq" 'kill-buffer-and-window + ;; "bR" 'rename-file-and-buffer + "br" 'revert-buffer + + ;; Window operations + "w" '(:ignore t :which-key "window") + "wm" 'maximize-window + "wh" 'split-window-horizontally + "wg" 'split-window-vertically + ;; "wu" 'winner-undo + "ww" 'other-window + "wk" 'delete-window + "wD" 'delete-other-windows + + ;; File operations + "f" '(:ignore t :which-key "find") + ; "fc" 'write-file + ; "fe" '(:ignore t :which-key "emacs") + ;; "fed" 'find-user-init-file + ;; "feR" 'load-user-init-file + ; "fj" 'dired-jump + "fl" 'find-file-literally + ;; "fR" 'rename-file-and-buffer + "fs" 'save-buffer + + ;; Applications + "a" '(:ignore t :which-key "apps") + "ad" 'dired + ":" 'shell-command + ";" 'eval-expression + "ac" 'calendar + "oa" 'org-agenda) + +; (global-set-key (kbd "") 'keyboard-escape-quit) +(general-define-key + "" 'keyboard-escape-quit + "C-o" 'previous-buffer + "C-p" 'next-buffer) + +(setq use-dialog-box nil) + +;; (desktop-save-mode 1) + +(setq-default + tab-width 2 + c-basic-offset 2) + +(setq backup-directory-alist + `(("." . ,(concat user-emacs-directory "/temp")))) + +(use-package evil + :demand t + :init + (setq evil-want-integration t) + (setq evil-want-keybinding nil) + + :general ; (leader-key + ; "wh" '(evil-window-left :which-key "←") + ; "wj" '(evil-window-down :which-key "↓") + ; "wk" '(evil-window-up :which-key "↑") + ; "wl" '(evil-window-right :which-key "→")) + ([remap evil-ex-search-forward] 'swiper) + ([remap evil-ex-search-backward] 'swiper-backward) + + :bind ( + ("C-h" . evil-window-left) + ("C-j" . evil-window-down) + ("C-k" . evil-window-up) + ("C-l" . evil-window-right) + + :map evil-insert-state-map + ("C-g" . evil-normal-state) + ("C-h" . evil-delete-backward-char-and-join)) + + :config + + ;; :q should kill the current buffer rather than quitting emacs entirely + (evil-ex-define-cmd "q" 'kill-this-buffer) + ;; Need to type out :quit to close emacs + (evil-ex-define-cmd "quit" 'evil-quit) + + (evil-set-initial-state 'messages-buffer-mode 'normal) + (evil-set-initial-state 'dashboard-mode 'normal) + + (evil-mode 1)) + +(use-package evil-collection + :after (evil) + :config + (evil-collection-init) + (evil-collection-company-setup)) + +(use-package evil-nerd-commenter + :bind ("M-/" . evilnc-comment-or-uncomment-lines) + :general (leader-key + "c" '(evilnc-comment-or-uncomment-lines :which-key "/* */")) + (general-nmap + "gc" 'evilnc-comment-operator)) + +;; (use-package evil-escape +;; :after (evil company) +;; :diminish evil-escape-mode +;; :init +;; (with-eval-after-load 'company +;; (add-hook 'evil-normal-state-entry-hook #'company-cancel)) +;; (setq evil-escape-key-sequence "jk" +;; evil-escape-unordered-key-sequence t) +;; :config +;; (evil-escape-mode)) + +(use-package ivy + + :bind ( + :map ivy-minibuffer-map + ("M-j" . ivy-next-line) + ("M-k" . ivy-previous-line) + ("M-l" . ivy-alt-done))) + +(use-package ivy-rich + :config (ivy-rich-mode 1)) + +(use-package counsel + :general (leader-key + "ff" '(counsel-find-file :which-key "find file") + "f SPC" '(counsel-ag :which-key "Ag") + "ik" '(counsel-yank-pop :which-key "from kill-ring") + "bb" '(counsel-ibuffer :which-key "choose buffer") + "fe" '(counsel-flycheck :which-key "find error")) + + :bind (("M-x" . counsel-M-x) + ("C-x b" . counsel-ibuffer) + ("C-x C-f" . counsel-find-file) + :map minibuffer-local-map + ("C-r" . 'counsel-minibuffer-history))) + +(use-package org + :general (leader-key + "o" '(:ignore t :which-key "org") + "oa" '(org-agenda :which-key "agenda") + "ox" '(org-toggle-checkbox :which-key "[X]") + "oe" '(org-edit-src-code :which-key "Edit SRC") + ; Insert + "io" '(:ignore t :which-key "org") + "ios" 'org-insert-structure-template) + :config + (setq org-src-tab-acts-natively nil) + (org-babel-do-load-languages + 'org-babel-load-languages + '((dot . t)))) + +(use-package org-superstar + :hook (org-mode-hook . org-superstar-mode) + :config + (setq org-startup-indented t) ;; Indent according to section + (setq org-startup-with-inline-images t)) ;; Display images in-buffer by default + +(use-package evil-org + :after (evil org) + :hook + (org-mode-hook . evil-org-mode) + (evil-org-mode-hook . (lambda () + (evil-org-set-key-theme '(navigation insert textobjects additional calendar)))) + :config + (require 'evil-org-agenda) + (evil-org-agenda-set-keys) + + (setq org-agenda-files '("~/org/agenda.org")) + (setq org-directory "~/org/")) + +(defvar notes-folder "~/.emacs.d/notes") + +(defun format-note-path (project-root) + (concat notes-folder (string-remove-suffix "/" (string-remove-prefix (getenv "HOME") project-root)) ".org")) + +(defun get-notes () + (interactive) + (if (projectile-project-p) + (let + ((note-path (format-note-path (projectile-project-root)))) + (unless (file-exists-p note-path) + (when (y-or-n-p (format "%s does not exist. Create it?" note-path)) + (make-directory (file-name-directory note-path) t) + (make-empty-file note-path))) + (find-file note-path)) + ;; else + (message "Couldn't find project folder"))) + +(leader-key + "fn" '(get-notes :which-key "Get project notes")) + +(setq dotfiles '( + ("Emacs" . (concat (or (getenv "NIX_DOTFILES") "~/nix") "/home/programs/emacs/config.org")) + ("Xmonad" . "$HOME/.xmonad/xmonad.hs") + ("Xmobar" . "$XDG_CONFIG_HOME/xmobar/xmobarrc") + ("Awesome" . "$XDG_CONFIG_HOME/awesome/rc.lua") + ("Stalonetray" . "$HOME/.stalonetrayrc") + ("Termite" . "$XDG_CONFIG_HOME/termite/config") + ("Kitty" . "$XDG_CONFIG_HOME/kitty/kitty.conf") + ("Mpd" . "$XDG_CONFIG_HOME/mpd/mpd.conf") + ("Ncmpcpp" . "$HOME/.ncmpcpp/config") + ("Nnn" . "$XDG_CONFIG_HOME/nnn/") + ("TeX-ntnu" . "$HOME/texmf/tex/latex/local/ntnu.sty") + ("Tmux" . "$XDG_CONFIG_HOME/tmux/tmux.conf") + ("Todo" . "$HOME/.todo") + ("Qutebrowser" . "$XDG_CONFIG_HOME/qutebrowser/config.py") + ("Vim" . "$XDG_CONFIG_HOME/nvim/init.lua") + ("Zsh" . "$XDG_CONFIG_HOME/zsh/.zshrc") + ("Config-selector" . "$HOME/.scripts/rofi/config-selector") + ("Configfiles" . "$HOME/.scripts/rofi/configfiles"))) + +(defun find-config-file () + "Chooses a config-file from dotfiles and opens it in a new buffer" + (interactive) + (ivy-read "Config: " dotfiles + :action (lambda (confpair) (find-file (substitute-in-file-name (eval (cdr confpair))))))) + +(leader-key "fc" '(find-config-file :which-key "find config file")) + +(use-package monokai-theme + :config + (setq monokai-user-variable-pitch t) + (progn + + (defvar after-load-theme-hook nil + "Hook run after a color theme is loaded using `load-theme'.") + + (defadvice load-theme (after run-after-load-theme-hook activate) + "Run `after-load-theme-hook'." + (run-hooks 'after-load-theme-hook)) + + (defun customize-monokai () + "Customize monokai theme" + (if (member 'monokai custom-enabled-themes) + (custom-theme-set-faces + 'monokai + '(py-object-reference-face ((t (:foreground "#FFA500")))) + '(py-decorators-face ((t (:foreground "#FFA500")))) + '(py-variable-name-face ((t (:foreground "#FFA500")))) + '(py-exception-name-face ((:foreground "#FFA500"))) + '(py-class-name-face ((:foreground "#FFA500"))) + '(py-pseudo-keyword-face ((:foreground "#FFA500"))) + '(py-builtins-face ((:foreground "#FFA500")))))) + + (add-hook 'after-load-theme-hook 'customize-monokai))) + +(load-theme 'monokai t) + +(use-package centaur-tabs + :demand + :config + (setq + centaur-tabs-set-icons t + centaur-tabs-gray-out-icons 'buffer + centaur-tabs-height 32 + centaur-tabs-set-modified-marker t + centaur-tabs-modified-marker "•" + centaur-tabs-set-bar 'under + x-underline-at-descent-line t + centaur-tabs-style "wave") + + (centaur-tabs-headline-match) + (centaur-tabs-mode t) + + ; TODO: configure centaur-tabs-active-bar-face and colors + + :general (leader-key + "bg" '(centaur-tabs-counsel-switch-group :which-key "choose tab group") + "b M-p" '(centaur-tabs-backward-group :which-key "previous group") + "b M-n" '(centaur-tabs-forward-group :which-key "next group") + "bp" '(centaur-tabs-backward-tab :which-key "previous tab") + "bn" '(centaur-tabs-forward-tab :which-key "next tab"))) + +(defun centaur-tabs-hide-tab (x) + "Do no to show buffer X in tabs." + (let ((name (format "%s" x))) + (or + ;; Current window is not dedicated window. + (window-dedicated-p (selected-window)) + + ;; Buffer name not match below blacklist. + (string-prefix-p "*epc" name) + (string-prefix-p "*helm" name) + (string-prefix-p "*Helm" name) + (string-prefix-p "*Compile-Log*" name) + (string-prefix-p "*lsp" name) + (string-prefix-p "*company" name) + (string-prefix-p "*Flycheck" name) + (string-prefix-p "*tramp" name) + (string-prefix-p " *Mini" name) + (string-prefix-p "*help" name) + (string-prefix-p "*straight" name) + (string-prefix-p " *temp" name) + (string-prefix-p "*Help" name) + (string-prefix-p "*mybuf" name) + + ;; Is not magit buffer. + (and (string-prefix-p "magit" name) + (not (file-name-extension name))) + ))) + +(use-package doom-modeline + :init (doom-modeline-mode 1) + :config + ;; How tall the mode-line should be. It's only respected in GUI. + ;; If the actual char height is larger, it respects the actual height. + (setq doom-modeline-height 25) + + ;; How wide the mode-line bar should be. It's only respected in GUI. + (setq doom-modeline-bar-width 3) + + ;; The limit of the window width. + ;; If `window-width' is smaller than the limit, some information won't be displayed. + (setq doom-modeline-window-width-limit fill-column) + + ;; How to detect the project root. + ;; The default priority of detection is `ffip' > `projectile' > `project'. + ;; nil means to use `default-directory'. + ;; The project management packages have some issues on detecting project root. + ;; e.g. `projectile' doesn't handle symlink folders well, while `project' is unable + ;; to hanle sub-projects. + ;; You can specify one if you encounter the issue. + (setq doom-modeline-project-detection 'project) + + ;; Determines the style used by `doom-modeline-buffer-file-name'. + ;; + ;; Given ~/Projects/FOSS/emacs/lisp/comint.el + ;; auto => emacs/lisp/comint.el (in a project) or comint.el + ;; truncate-upto-project => ~/P/F/emacs/lisp/comint.el + ;; truncate-from-project => ~/Projects/FOSS/emacs/l/comint.el + ;; truncate-with-project => emacs/l/comint.el + ;; truncate-except-project => ~/P/F/emacs/l/comint.el + ;; truncate-upto-root => ~/P/F/e/lisp/comint.el + ;; truncate-all => ~/P/F/e/l/comint.el + ;; truncate-nil => ~/Projects/FOSS/emacs/lisp/comint.el + ;; relative-from-project => emacs/lisp/comint.el + ;; relative-to-project => lisp/comint.el + ;; file-name => comint.el + ;; buffer-name => comint.el<2> (uniquify buffer name) + ;; + ;; If you are experiencing the laggy issue, especially while editing remote files + ;; with tramp, please try `file-name' style. + ;; Please refer to https://github.com/bbatsov/projectile/issues/657. + (setq doom-modeline-buffer-file-name-style 'relative-to-project) + + ;; Whether display icons in the mode-line. + ;; While using the server mode in GUI, should set the value explicitly. + (setq doom-modeline-icon (display-graphic-p)) + + ;; Whether display the icon for `major-mode'. It respects `doom-modeline-icon'. + (setq doom-modeline-major-mode-icon nil) + + ;; Whether display the colorful icon for `major-mode'. + ;; It respects `all-the-icons-color-icons'. + (setq doom-modeline-major-mode-color-icon nil) + + ;; Whether display the icon for the buffer state. It respects `doom-modeline-icon'. + (setq doom-modeline-buffer-state-icon t) + + ;; Whether display the modification icon for the buffer. + ;; It respects `doom-modeline-icon' and `doom-modeline-buffer-state-icon'. + (setq doom-modeline-buffer-modification-icon t) + + ;; Whether to use unicode as a fallback (instead of ASCII) when not using icons. + (setq doom-modeline-unicode-fallback nil) + + ;; Whether display the minor modes in the mode-line. + (setq doom-modeline-minor-modes nil) + + ;; If non-nil, a word count will be added to the selection-info modeline segment. + (setq doom-modeline-enable-word-count nil) + + ;; Major modes in which to display word count continuously. + ;; Also applies to any derived modes. Respects `doom-modeline-enable-word-count'. + ;; If it brings the sluggish issue, disable `doom-modeline-enable-word-count' or + ;; remove the modes from `doom-modeline-continuous-word-count-modes'. + (setq doom-modeline-continuous-word-count-modes '(markdown-mode gfm-mode org-mode)) + + ;; Whether display the buffer encoding. + (setq doom-modeline-buffer-encoding t) + + ;; Whether display the indentation information. + (setq doom-modeline-indent-info nil) + + ;; If non-nil, only display one number for checker information if applicable. + (setq doom-modeline-checker-simple-format t) + + ;; The maximum number displayed for notifications. + (setq doom-modeline-number-limit 99) + + ;; The maximum displayed length of the branch name of version control. + (setq doom-modeline-vcs-max-length 12) + + ;; Whether display the workspace name. Non-nil to display in the mode-line. + (setq doom-modeline-workspace-name t) + + ;; Whether display the perspective name. Non-nil to display in the mode-line. + (setq doom-modeline-persp-name t) + + ;; If non nil the default perspective name is displayed in the mode-line. + (setq doom-modeline-display-default-persp-name nil) + + ;; If non nil the perspective name is displayed alongside a folder icon. + (setq doom-modeline-persp-icon t) + + ;; Whether display the `lsp' state. Non-nil to display in the mode-line. + (setq doom-modeline-lsp t) + + ;; Whether display the GitHub notifications. It requires `ghub' package. + (setq doom-modeline-github nil) + + ;; The interval of checking GitHub. + (setq doom-modeline-github-interval (* 30 60)) + + ;; Whether display the modal state icon. + ;; Including `evil', `overwrite', `god', `ryo' and `xah-fly-keys', etc. + (setq doom-modeline-modal-icon nil) + + ;; Whether display the mu4e notifications. It requires `mu4e-alert' package. + (setq doom-modeline-mu4e nil) + + ;; Whether display the gnus notifications. + (setq doom-modeline-gnus t) + + ;; Whether gnus should automatically be updated and how often (set to 0 or smaller than 0 to disable) + (setq doom-modeline-gnus-timer 2) + + ;; Whether groups should be excludede when gnus automatically being updated. + (setq doom-modeline-gnus-excluded-groups '("dummy.group")) + + ;; Whether display the IRC notifications. It requires `circe' or `erc' package. + (setq doom-modeline-irc t) + + ;; Function to stylize the irc buffer names. + (setq doom-modeline-irc-stylize 'identity) + + ;; Whether display the environment version. + (setq doom-modeline-env-version t) + ;; Or for individual languages + (setq doom-modeline-env-enable-python t) + (setq doom-modeline-env-enable-ruby t) + (setq doom-modeline-env-enable-perl t) + (setq doom-modeline-env-enable-go t) + (setq doom-modeline-env-enable-elixir t) + (setq doom-modeline-env-enable-rust t) + + ;; Change the executables to use for the language version string + (setq doom-modeline-env-python-executable "python") ; or `python-shell-interpreter' + (setq doom-modeline-env-ruby-executable "ruby") + (setq doom-modeline-env-perl-executable "perl") + (setq doom-modeline-env-go-executable "go") + (setq doom-modeline-env-elixir-executable "iex") + (setq doom-modeline-env-rust-executable "rustc") + + ;; What to dispaly as the version while a new one is being loaded + (setq doom-modeline-env-load-string "...") + + ;; Hooks that run before/after the modeline version string is updated + (setq doom-modeline-before-update-env-hook nil) + (setq doom-modeline-after-update-env-hook nil)) + +(column-number-mode) + +(set-face-attribute 'default nil + :family "Fira Code" + :height 130 + :weight 'normal + :width 'normal) + +; (setq doom-font (font-spec :family "Fira Code" :size 16 :weight 'regular) +; doom-variable-pitch-font (font-spec :family "Droid Sans" :size 13) +; doom-big-font (font-spec :family "Droid Sans" :size 16)) ;; Presentations or streaming + +(set-fontset-font (frame-parameter nil 'font) + 'japanese-jisx0208 + '("Droid Sans Japanese" . "unicode-bmp")) + +(use-package fira-code-mode + :custom (fira-code-mode-disabled-ligatures '("x", "[]")) + :hook prog-mode) + +(use-package dashboard + :init + (setq dashboard-set-heading-icons t) + (setq dashboard-set-file-icons t) + + (setq dashboard-image-banner-max-height (/ (frame-pixel-height) 3)) + (setq dashboard-startup-banner (concat user-emacs-directory "/logo.svg")) + ; (setq dashboard-startup-banner (concat user-emacs-directory "/logo.svg")) + (setq dashboard-center-content t) + (setq dashboard-items '((recents . 10) + (projects . 5) + (agenda . 5) + (bookmarks . 10))) + (setq dashboard-projects-switch-function 'counsel-projectile-switch-project-by-name) + + (dashboard-setup-startup-hook) + + :custom + ; (dashboard-banner-logo-title "Execution >> Idea") + (dashboard-banner-logo-title "Emacs") + + :config + (set-face-attribute 'dashboard-banner-logo-title nil :font "Droid Sans" :height 300)) + +(scroll-bar-mode -1) +(tool-bar-mode -1) +(menu-bar-mode -1) + +(global-display-line-numbers-mode) +(setq + display-line-numbers-type 'relative + scroll-margin 5) + +;; Disable line numbers for some modes +(dolist (mode '(term-mode-hook + shell-mode-hook + treemacs-mode-hook + eshell-mode-hook)) + (add-hook mode (lambda () (display-line-numbers-mode 0)))) + + + +(setq display-line-numbers-type 'relative) +(setq evil-normal-state-cursor '(box "#66d9ef") + evil-insert-state-cursor '(bar "#a6e22e") + evil-visual-state-cursor '(hollow "orange")) + +(use-package rainbow-delimiters + :hook (prog-mode . rainbow-delimiters-mode)) + +(defun lsp-mode-setup () + (setq lsp-headerline-breadcrumb-segments '(path-up-to-project file symbols)) + (lsp-headerline-breadcrumb-mode) + + (general-nmap + "gr" 'lsp-find-references + "gd" 'lsp-find-definition + "gf" 'find-file-at-point)) + +(use-package lsp-mode + :commands (lsp lsp-deferred) + + :hook ( + (lsp-mode . lsp-mode-setup) + (lsp-mode . lsp-enable-which-key-integration)) + + :init (setq + lsp-keymap-prefix "C-c l" + lsp-completion-provider :capf) + + :config (setq + lsp-inhibit-message t + lsp-eldoc-render-all nil + lsp-enable-file-watchers t + lsp-enable-snippet t + lsp-enable-symbol-highlighting t + lsp-headerline-breadcrumb-enable t + lsp-highlight-symbol-at-point t + lsp-modeline-code-actions-enable t + lsp-modeline-diagnostics-enable t + + lsp-ui-doc-position 'right + lsp-ui-doc-max-height 40 + lsp-ui-doc-enable nil + lsp-ui-sideline-delay 0.05 + lsp-ui-sideline-show-code-actions nil) + (lsp-enable-which-key-integration t) + + (add-to-list 'company-backends '(company-capf company-dabbrev)) + + :bind ( + :map lsp-mode-map + ("M-RET" . lsp-execute-code-action)) + + :general (leader-key + "l" (general-simulate-key "C-c l" :which-key "LSP")) + + ([remap xref-find-references] #'lsp-ui-peek-find-references) + ([remap xref-find-definitions] 'lsp-ui-peek-find-definitions) + + (leader-key + "j" '(:ignore t :which-key "LSP OWN") + "ja" 'lsp-format-buffer + "jf" 'lsp-format-buffer + "jh" 'lsp-describe-thing-at-point + "jr" 'lsp-restart-workspace + "jd" 'lsp-goto-implementation + "jt" 'lsp-goto-type-definition + "jx" 'lsp-ui-doc-mode + "j " 'lsp-rename) + + (general-nmap + "K" 'lsp-ui-doc-glance)) + +(use-package lsp-ui) + +(use-package lsp-treemacs + :after (lsp treemacs) + :hook (lsp-mode . lsp-treemacs-sync-mode)) + +(use-package lsp-ivy + :after lsp + :commands lsp-ivy-workspace-symbol) + +(use-package company + :init (setq + company-idle-delay 0.1 ; show autocompletion after n seconds + company-async-timeout 15 ; completion may be slow + company-tooltip-idle-delay 0.1 + company-minimum-prefix-length 1 ; show suggestions after only one character (insted of several) + company-tooltip-align-annotations t) + + (add-to-list 'company-backends 'company-files) + + :hook (prog-mode . company-mode) + + :bind (("C-RET" . counsel-company) + :map prog-mode-map + ("C-i" . company-indent-or-complete-common) + ("C-;" . counsel-company) + ("C-M-i" . counsel-company) + :map company-active-map + ; ("C-o" . company-search-kill-others) + ; ("C-h" . company-quickhelp-manual-begin) + ("C-h" . company-show-doc-buffer) + ("C-s" . company-search-candidates) + ("M-s" . company-filter-candidates) + ([C-tab] . company-complete-common-or-cycle) + ([tab] . company-complete-common-or-cycle) + ([backtab] . company-select-previous) + ;; ("M-RET" . company-complete-selection) + ("RET" . company-complete-selection) + :map company-search-map + ;; ("M-j" . company-select-next) + ;; ("M-k" . company-select-previous) + ("C-p" . company-select-next-or-abort) + ("C-n" . company-select-previous-or-abort)) + ;; ("C-n" . 'company-search-repeat-forward) + ;; ("C-p" . 'company-search-repeat-backward))) + ;; ("" . (cmd! (company-search-abort) (company-filter-candidates))))) + :config + (general-define-key + "C-SPC" 'company-capf)) + +(use-package company-box + :hook (company-mode . company-box-mode)) + +(use-package flycheck + :config + (setq + flycheck-highlighting-mode 'lines) + + (set-face-attribute 'flycheck-error nil + :family "Fira Code" + :background "#773131" + :weight 'normal + :width 'normal) + + (set-face-attribute 'flycheck-warning nil + :family "Fira Code" + :background "#767731" + :weight 'normal + :width 'normal) + + :general (leader-key + "!" (general-simulate-key "C-u C-c !" :which-key "Flycheck"))) +(global-flycheck-mode 1) + + + +(use-package helpful + :custom + (counsel-describe-function-function #'helpful-callable) + (counsel-describe-variable-function #'helpful-variable) + :bind + ([remap describe-function] . counsel-describe-function) + ([remap describe-command] . helpful-command) + ([remap describe-variable] . counsel-describe-variable) + ([remap describe-key] . helpful-key)) + +(use-package projectile + :init + (setq projectile-project-search-path '("~/git/" + "~/git/temp/" + "~/git/appkom/" + "~/git/pvv/")) + (setq projectile-switch-project-action #'projectile-dired) + + :custom ((projectile-completion-system 'ivy)) + :bind-keymap ("C-c p" . projectile-command-map) + :config (projectile-mode) + + :general (leader-key + ;; File path + "fR" 'projectile-recentf + "fa" 'projectile-ag + ;; "fyC" 'spacemacs/projectile-copy-file-path-with-line-column + ;; "fyD" 'spacemacs/projectile-copy-directory-path + ;; "fyL" 'spacemacs/projectile-copy-file-path-with-line + ;; "fyY" 'spacemacs/projectile-copy-file-path + ;; Project + "p" '(:ignore t :which-key "projectile") + "p!" 'projectile-run-shell-command-in-root + "p&" 'projectile-run-async-shell-command-in-root + "p%" 'projectile-replace-regexp + "pa" 'projectile-toggle-between-implementation-and-test + "pb" 'projectile-switch-to-buffer + "pc" 'projectile-compile-project + "pd" 'projectile-find-dir + "pD" 'projectile-dired + "pe" 'projectile-edit-dir-locals + "pf" 'projectile-find-file + "pF" 'projectile-find-file-dwim + "pg" 'projectile-find-tag + "pG" 'projectile-regenerate-tags + "pI" 'projectile-invalidate-cache + "pk" 'projectile-kill-buffers + "pp" 'projectile-switch-project + "pr" 'projectile-recentf + "pR" 'projectile-replace + "pT" 'projectile-test-project + "pv" 'projectile-vc)) + +(use-package swiper + :general (leader-key + "s" '(swiper :which-key "search"))) + +(use-package yasnippet + :init (yas-global-mode t) + :config (yas-reload-all) + :general (leader-key + "y" '(:ignore t :which-key "yasnippet") + "yn" '(yas-new-snippet :which-key "New snippet") + ;; "yi" '(yas-insert-snippet :which-key "Insert snippet") + "y/" '(yas-visit-snippet-file :which-key "Find global snippet") + "yr" '(yas-reload-all :which-key "Reload snippets") + "yv" '(yas-describe-tables :which-key "View loaded snippets"))) + +(use-package ivy-yasnippet + :after yasnippet + :general (leader-key + "yi" '(ivy-yasnippet :which-key "Insert snippet"))) + +(defvar company-mode/enable-yas t + "Enable yasnippet for all backends.") + +(defun company-mode/backend-with-yas (backend) + (if (or (not company-mode/enable-yas) (and (listp backend) (member 'company-yasnippet backend))) + backend + (append (if (consp backend) backend (list backend)) + '(:with company-yasnippet)))) + +(setq company-backends (mapcar #'company-mode/backend-with-yas company-backends)) + +(use-package hl-todo + :ensure t + :custom-face + (hl-todo ((t (:inherit hl-todo :italic t)))) + :hook ((prog-mode . hl-todo-mode) + (yaml-mode . hl-todo-mode))) + +(use-package magit + :general (leader-key + "g" '(:ignore t :which-key "git") + "g/" '(magit-dispatch :which-key "Magit dispatch") + "g." '(magit-file-dispatch :which-key "Magit file dispatch") + ;; "g'" '(forge-dispatch :which-key "Forge dispatch") + "gg" '(magit-status :which-key "Magit status") + "gG" '(magit-status-here :which-key "Magit status here") + "gx" '(magit-file-delete :which-key "Magit file delete") + "gB" '(magit-blame-addition :which-key "Magit blame") + "gC" '(magit-clone :which-key "Magit clone") + "gF" '(magit-fetch :which-key "Magit fetch") + "gL" '(magit-log :which-key "Magit buffer log") + "gS" '(magit-stage-file :which-key "Git stage file") + "gU" '(magit-unstage-file :which-key "Git unstage file") + + "gf" '(:ignore t :which-key "find") + "gff" '(magit-find-file :which-key "Find file") + "gfg" '(magit-find-git-config-file :which-key "Find gitconfig file") + "gfc" '(magit-show-commit :which-key "Find commit") + + + "gl" '(:ignore t :which-key "list") + ;; "glg" '(gist-list :which-key "List gists") + "glr" '(magit-list-repositories :which-key "List repositories") + "gls" '(magit-list-submodules :which-key "List submodules") + ;; "gli" '(forge-list-issues :which-key "List issues") + ;; "glp" '(forge-list-pullreqs :which-key "List pull requests") + ;; "gln" '(forge-list-notifications :which-key "List notifications") + + "gc" '(:ignore t :which-key "create") + "gcr" '(magit-init :which-key "Initialize repo") + "gcR" '(magit-clone :which-key "Clone repo") + "gcc" '(magit-commit-create :which-key "Commit") + "gcf" '(magit-commit-fixup :which-key "Fixup"))) + ;; "gci" '(forge-create-issue :which-key "Issue") + ;; "gcp" '(forge-create-pullreq :which-key "Pull request"))) + +(use-package git-gutter + :init + (global-git-gutter-mode 1)) + +(use-package dart-mode + :mode "\\.dart\\'") + +(use-package lsp-dart + :hook 'dart-mode-hook) + +(use-package elm-mode + :mode ("\\.elm\\'" . elm-mode) + :after (company) + :config (add-to-list 'company-backends 'elm-company) + + :general (leader-key elm-mode-map + + "mc" '(:ignore t :which-key "compile") + "mcb" 'elm-compile-buffer + "mcm" 'elm-compile-main + "mct" 'elm-test-project + "mcr" 'elm-reactor + "mcb" 'elm-preview-buffer + "mcp" 'elm-preview-main + + "mh" '(:ignore t :which-key "docs") + "mhd" 'elm-documentation-lookup + "mhh" 'elm-oracle-doc-at-point + "mht" 'elm-oracle-type-at-point + + "m." 'elm-repl-load + "mp" 'elm-repl-push + "md" 'elm-repl-push-decl + + "mi" 'elm-import + "me" 'elm-expose-at-point + "ms" 'elm-sort-imports + "mf" 'elm-format-buffer + "mv" 'elm-package-catalog)) + +(use-package flycheck-elm + :after (flycheck elm-mode) + :hook (elm-mode-hook . flycheck-elm-setup)) + +(add-hook 'elm-mode-hook 'lsp) + +(use-package highlight-defined + :config + (add-hook 'emacs-lisp-mode-hook 'highlight-defined-mode)) + +(use-package haskell-mode + :general (leader-key haskell-mode-map + + "mh" '(haskell-hide-toggle :which-key "hide") + "mH" '(haskell-hide-toggle-all :which-key "hide all") + + "mc" '(:ignore t :which-key "cabal") + "mcf" '(haskell-cabal-visit-file :which-key "cabal file") + "mcb" '(haskell-process-cabal-build :which-key "build"))) + +(use-package hlint-refactor + :hook (haskell-mode-hook . hlint-refactor-mode) + :general (leader-key haskell-mode-map + "mr" '(hlint-refactor-refactor-buffer :which-key "refactor suggestion"))) + +(use-package hindent + :hook (haskell-mode-hook . hindent-mode)) + +(use-package lsp-haskell + :hook (haskell-mode-hook . lsp) + (haskell-literate-mode-hook . lsp)) + +(use-package lsp-java + :init + ; (setq lsp-java-server-install-dir "/usr/share/java/jdtls/") + (setenv "JAVA_HOME" "/usr/lib/jvm/default") + (setq + lsp-java-java-path (substitute-in-file-name "$JAVA_HOME/bin/java") + lsp-java-jdt-download-url "https://download.eclipse.org/jdtls/snapshots/jdt-language-server-latest.tar.gz") + ; :hook (java-mode-hook . lsp) + :config + (add-hook 'java-mode-hook 'flycheck-mode) + (add-hook 'java-mode-hook 'company-mode) + (add-hook 'java-mode-hook 'lsp) + :general (leader-key java-mode-map + ;; LSP Java commands + "mi" '(lsp-java-organize-imports :which-key "Organize imports") + "mc" '(lsp-java-build-project :which-key "Perform partial or full build for the projects") + ;; lsp-java-update-project-configuration - Update project configuration + ;; lsp-java-actionable-notifications - Resolve actionable notifications + ;; lsp-java-update-user-settings - Update user settings (Check the options in the table bellow.) + ;; lsp-java-update-server - Update server instalation. + "mg" '(:ignore t :which-key "Generate") + "mgs" '(lsp-java-generate-to-string :which-key "Generate toString method") + "mge" '(lsp-java-generate-equals-and-hash-code :which-key "Generate equals and hashCode methods") + "mgo" '(lsp-java-generate-overrides :which-key "Generate method overrides") + "mgg" '(lsp-java-generate-getters-and-setters :which-key "Generate getters and setters") + ;; Refactoring + ;; LSP Java provides rich set of refactorings via Eclipse JDT Language Server code actions and some of them are bound to Emacs commands: + + "mr" '(:ignore t :which-key "Refactor") + "mr" '(lsp-java-extract-to-constant :which-key "Extract constant refactoring") + "mr" '(lsp-java-add-unimplemented-methods :which-key "Extract constant refactoring") + "mr" '(lsp-java-create-parameter :which-key "Create parameter refactoring") + "mr" '(lsp-java-create-field :which-key "Create field refactoring") + "mr" '(lsp-java-create-local :which-key "Create local refactoring") + "mr" '(lsp-java-extract-method :which-key "Extract method refactoring") + "mr" '(lsp-java-add-import :which-key "Add missing import") + + ;; Testing support + "mt" '(:ignore t :which-key "JUnit") + "mtr" '(lsp-jt-report-open :which-key "open test report") + "mtb" '(lsp-jt-browser :which-key "Browse tests and run/debug them.") + ;; ^^^ ** Use x to run the test(s) under point; d to debug the tests under point. R to refresh. ** Support for GUI operations. + "mtl" '(lsp-jt-lens-mode :which-key "test lenses mode") + + ;; Dependency viewer + "md" '(lsp-java-dependency-list :which-key "View java dependencies"))) + +(use-package maven-test-mode + :hook (java-mode-hook . maven-test-mode) + ;; (spacemacs/declare-prefix-for-mode 'java-mode "mm" "maven") + ;; (spacemacs/declare-prefix-for-mode 'java-mode "mmg" "goto") + ;; (spacemacs/declare-prefix-for-mode 'java-mode "mmt" "tests")) + ;; :config + ;; (progn + ;; (spacemacs|hide-lighter maven-test-mode) + ;; (spacemacs/set-leader-keys-for-minor-mode 'maven-test-mode + :general (leader-key maven-test-mode-map + "mm" '(:ignore t :which-key "Maven") + "mmga" 'maven-test-toggle-between-test-and-class + "mmgA" 'maven-test-toggle-between-test-and-class-other-window + "mmta" 'maven-test-all + "mmt C-a" 'maven-test-clean-test-all + "mmtb" 'maven-test-file + "mmti" 'maven-test-install + "mmtt" 'maven-test-method)) + + + +(use-package typescript-mode + :mode "\\.ts\\'" + :hook (typescript-mode . lsp) + :config + (setq typescript-indent-level 2)) + +(use-package json-mode + :mode "\\.js\\(?:on\\|[hl]int\\(?:rc\\)?\\)\\'" + :hook (json-mode . lsp) + ; :config + ; (set-electric! 'json-mode :chars '(?\n ?: ?{ ?})) + :general (leader-key json-mode-map + "mp" '(json-mode-show-path :which-key "Copy path") + "mt" 'json-toggle-boolean + "md" 'json-mode-kill-path + "mx" 'json-nullify-sexp + "m+" 'json-increment-number-at-point + "m-" 'json-decrement-number-at-point + "mf" 'json-mode-beautify)) + +(use-package tex + ;; :after (pdf-tools) + :ensure auctex + :mode ("\\.tex\\'" . LaTeX-mode) + :config + (setq + TeX-source-correlate-method 'synctex + TeX-source-correlate-start-server t + TeX-auto-save t + TeX-parse-self t + ; reftex-plug-into-AUCTeX t + TeX-PDF-mode t) ; Use PDF instead of DVI + + (setq-default + TeX-master "main.tex" + TeX-engine 'default) ; default | xetex | luatex + + (TeX-source-correlate-mode t) ; + + (add-hook 'LaTeX-mode-hook + (lambda () + (reftex-mode t) + (flyspell-mode t))) + + :general (leader-key + "mc" '(TeX-command-run-all :which-key "Compile") + "me" '(TeX-engine-set :which-key "Set engine") + "mv" '(TeX-view :which-key "view"))) + +(use-package company-auctex + :after auctex + :hook LaTeX-mode + :config + (company-auctex-init) + (add-to-list 'company-backends 'company-yasnippet) + (company-mode)) + + ;; :config + ;; (add-to-list '+latex--company-backends #'company-auctex-environments nil #'eq) + ;; (add-to-list '+latex--company-backends #'company-auctex-macros nil #'eq)) + +(use-package auctex-latexmk + :after auctex + (auctex-latexmk-setup) + (setq auctex-latexmk-inherit-TeX-PDF-mode t)) + +(use-package pdf-tools + ;; :hook + + ;; (add-hook 'pdf-view-mode-hook (lambda () + ;; (bms/pdf-midnite-amber))) ; automatically turns on midnight-mode for pdfs + :init + ;; (pdf-tools-install) + (setq + TeX-view-program-selection '((output-pdf "pdf-tools")) + TeX-view-program-list '(("pdf-tools" "TeX-pdf-tools-sync-view"))) + + :config + (setq-default pdf-view-display-size 'fit-page) + (setq pdf-annot-activate-created-annotations t) + + (add-hook 'TeX-after-compilation-finished-functions ;; Update PDF buffers after successful LaTeX runs + #'TeX-revert-document-buffer) + + :general (leader-key pdf-view-mode-map + "mf" 'isearch-forward + "mb" 'isearch-backward)) + +(use-package cdlatex + :general (leader-key + "mis" 'cdlatex-sub-superscript + "mip" 'cdlatex-lr-pair + "mie" 'cdlatex-environment)) + +;; (use-package math-preview) +;; (use-package preview-latex) + +; (use-package latex-preview-pane) + +; (use-package lsp-latex) + +(leader-key LaTeX-mode-map + "mm" '(:ignore t :which-key "Insert math") + "mm^" '(LaTeX-math-wedge :which-key "∧") + "mmv" '(LaTeX-math-vee :which-key "∨") + "mm=>" '(LaTeX-math-Rightarrow :which-key "=>") + "mm->" '(LaTeX-math-rightarrow :which-key "->") + "mm<==" '(LaTeX-math-Leftarrow :which-key "<=") + "mm<-" '(LaTeX-math-leftarrow :which-key "<-") + "mm<=>" '(LaTeX-math-Leftrightarrow :which-key "<=>") + "mm==" '(LaTeX-math-equiv :which-key "≡") + "mm!=" '(LaTeX-math-neq :which-key "≠") + "mmn" '(LaTeX-math-neg :which-key "¬") + "mma" '(LaTeX-math-forall :which-key "∀") + "mme" '(LaTeX-math-exists :which-key "∃") + "mmt" '(LaTeX-math-top :which-key "⊤") + "mmT" '(LaTeX-math-bot :which-key "⊥") + "mm." '(LaTeX-math-therefore :which-key "∴") + "mm," '(LaTeX-math-because :which-key "∵")) + +(defun ntnu/expand-truth-table () + (interactive) + (save-excursion + (let + (start + end + (l/rep (lambda (pat repl) + (setq + start (evil-range-beginning (evil-visual-range)) + end (evil-range-end (evil-visual-range))) + (replace-regexp pat repl nil start end)))) + ;; (evil-ex-substitute start end '("[tT]") "\\\\T" '("g"))))) + (funcall l/rep "[tT]" "\\\\T") + (funcall l/rep "[fF]" "\\\\F") + (funcall l/rep " " " & ") + (funcall l/rep "$" " \\\\\\\\")))) + +(use-package markdown-mode + :commands (markdown-mode gfm-mode) + :mode (("README\\.md\\'" . gfm-mode) + ("\\.md\\'" . markdown-mode) + ("\\.markdown\\'" . markdown-mode)) + :init + (setq markdown-enable-math t ; syntax highlighting for latex fragments + markdown-enable-wiki-links t + markdown-italic-underscore t + markdown-asymmetric-header t + markdown-fontify-code-blocks-natively t + markdown-gfm-additional-languages '("sh") + markdown-make-gfm-checkboxes-buttons t + markdown-content-type "application/xhtml+xml" + markdown-css-paths + ; markdown-command "multimarkdown" + '("https://cdn.jsdelivr.net/npm/github-markdown-css/github-markdown.min.css" + "https://cdn.jsdelivr.net/gh/highlightjs/cdn-release/build/styles/github.min.css") + markdown-xhtml-header-content + (concat "" + "" + "" + "" + "")) + :general (leader-key markdown-mode-map + "m'" 'markdown-edit-code-block + "mo" 'markdown-open + "mp" 'markdown-preview + "me" 'markdown-export + ; "mp" 'grip-mode) + + "mi" '(:ignore t :which-key "insert") + ; "mit" 'markdown-toc-generate-toc + "mii" 'markdown-insert-image + "mil" 'markdown-insert-link)) + +(use-package nix-mode + :mode "\\.nix\\'") + +(use-package python-mode) + +(setq lsp-pyls-plugins-autopep8-enabled nil) +(setq lsp-pyls-plugins-yapf-enabled t) +(add-hook 'python-mode-hook 'lsp) + +(defun prettify-python () + (set-face-attribute font-lock-keyword-face nil :font "CMU Serif" :slant 'italic :height 160) + (setq prettify-symbols-alist '( + ("def" . "f") + ("lambda" . "λ") + ("delta" . "Δ") + ("for" . "∀") + ("not in" . "∉") + ("in" . "∈") + ("return" . "→") + ("->" . "→") + ("\\n" . "⏎") + ("!=" . "≠") + ("not" . "¬") + ("and" . "^") + ("or" . "∨") + ("pi" . "π")))) + +;; (add-hook 'python-mode-hook 'prettify-symbols-mode) +;; (add-hook 'python-mode-hook 'prettify-python) + +(use-package rustic + :bind (:map rustic-mode-map + ("M-j" . lsp-ui-imenu) + ("M-?" . lsp-find-references) + ("C-c C-c l" . flycheck-list-errors) + ("C-c C-c a" . lsp-execute-code-action) + ("C-c C-c r" . lsp-rename) + ("C-c C-c q" . lsp-workspace-restart) + ("C-c C-c Q" . lsp-workspace-shutdown) + ("C-c C-c s" . lsp-rust-analyzer-status)) + :config + ;; uncomment for less flashiness + ;; (setq lsp-eldoc-hook nil) + ;; (setq lsp-enable-symbol-highlighting nil) + ;; (setq lsp-signature-auto-activate nil) + + ;; comment to disable rustfmt on save + (setq rustic-format-on-save t) + (add-hook 'rustic-mode-hook 'rk/rustic-mode-hook)) + +(defun rk/rustic-mode-hook () + ;; so that run C-c C-c C-r works without having to confirm, but don't try to + ;; save rust buffers that are not file visiting. Once + ;; https://github.com/brotzeit/rustic/issues/253 has been resolved this should + ;; no longer be necessary. + (when buffer-file-name + (setq-local buffer-save-without-query t))) + +(use-package emmet-mode + :hook (sgml-mode-hook . emmet-mode) + (html-mode-hook . emmet-mode) + (css-mode-hook . emmet-mode)) + +(use-package drag-stuff + :bind (("M-j" . drag-stuff-down) + ("M-k" . drag-stuff-up) + ;; ("M-h" . drag-left-stuff) + ;; ("M-l" . drag-stuff-right) + )) + +(use-package emojify + :hook (after-init-hook . global-emojify-mode) + :general (leader-key + "ie" 'emojify-insert-emoji)) + +(use-package lorem-ipsum + :general (leader-key + "il" '(:ignore t :which-key "lorem ipsum") + "ill" 'lorem-ipsum-insert-list + "ils" 'lorem-ipsum-insert-sentences + "ilp" 'lorem-ipsum-insert-paragraphs)) + +;; (use-package multiple-cursors +;; :general (leader-key +;; "d" '(:ignore t :which-key "multiple cursors") +;; "dl" '(mc/edit-lines :which-key "edit lines") +;; "dn" '(mc/mark-next-like-this :which-key "mark next") +;; "dN" '(mc/unmark-next-like-this :which-key "unmark next") +;; "dp" '(mc/mark-previous-like-this :which-key "mark previous") +;; "dP" '(mc/unmark-previous-like-this :which-key "unmark previous") +;; "dt" '(mc/mark-all-like-this :which-key "mark all") +;; "dm" '(mc/mark-all-like-this-dwim :which-key "mark all DWIM") +;; "de" '(mc/edit-ends-of-lines :which-key "edit line endings") +;; "da" '(mc/edit-beginnings-of-lines :which-key "edit line starts") +;; "ds" '(mc/mark-sgml-tag-pair :which-key "mark tag") +;; "dd" '(mc/mark-all-like-this-in-defun :which-key "mark in defun"))) + ;; "w" '(mc/add-cursor-on-click :which-key "add cursor w/mouse"))) + +(use-package recentf + :init (recentf-mode t) + :config + (add-to-list 'recentf-exclude (format "%s/\\.emacs\\.d/elpa/.*" (getenv "HOME"))) + (add-to-list 'recentf-exclude "~/\\.emacs\\.d/elpa/.*") + :general (leader-key + "fr" 'counsel-recentf)) + +(use-package treemacs + + :init + (with-eval-after-load 'winum + (define-key winum-keymap (kbd "M-0") 'treemacs-select-window)) + + :config + (progn + (setq treemacs-collapse-dirs (if (executable-find "python") 3 0) + treemacs-deferred-git-apply-delay 0.5 + treemacs-display-in-side-window t + treemacs-file-event-delay 5000 + treemacs-file-follow-delay 0.2 + treemacs-follow-after-init t + treemacs-follow-recenter-distance 0.1 + treemacs-git-command-pipe "" + treemacs-goto-tag-strategy 'refetch-index + treemacs-indentation 2 + treemacs-indentation-string " " + treemacs-is-never-other-window nil + treemacs-max-git-entries 5000 + treemacs-no-png-images nil + treemacs-no-delete-other-windows t + treemacs-project-follow-cleanup nil + treemacs-persist-file (expand-file-name ".cache/treemacs-persist" user-emacs-directory) + treemacs-recenter-after-file-follow nil + treemacs-recenter-after-tag-follow nil + treemacs-show-cursor nil + treemacs-show-hidden-files nil + treemacs-silent-filewatch nil + treemacs-silent-refresh nil + treemacs-sorting 'alphabetic-desc + treemacs-space-between-root-nodes t + treemacs-tag-follow-cleanup t + treemacs-tag-follow-delay 1.5 + treemacs-width 35) + + ;; The default width and height of the icons is 22 pixels. If you are + ;; using a Hi-DPI display, uncomment this to double the icon size. + ;;(treemacs-resize-icons 44) + + (treemacs-follow-mode t) + (treemacs-filewatch-mode t) + (treemacs-fringe-indicator-mode t) + (pcase (cons (not (null (executable-find "git"))) + (not (null (executable-find "python3")))) + (`(t . t) + (treemacs-git-mode 'deferred)) + (`(t . _) + (treemacs-git-mode 'simple)))) + + :bind + (:map global-map + ("M-0" . treemacs-select-window) + ("C-x t 1" . treemacs-delete-other-windows) + ("C-x t t" . treemacs) + ("C-x t B" . treemacs-bookmark) + ("C-x t C-t" . treemacs-find-file) + ("C-x t M-t" . treemacs-find-tag))) + + :general (leader-key + "t" '(:ignore t :which-key "treemacs") + "tt" 'treemacs) + +(use-package treemacs-evil + :after (treemacs evil)) + +(use-package treemacs-projectile + :after (treemacs projectile)) + +(use-package lsp-treemacs + :after (treemacs lsp) + :config (lsp-treemacs-sync-mode 1)) + +(use-package treemacs-magit + :after (treemacs magit)) + +(use-package treemacs-icons-dired + :after treemacs) + +(use-package which-key + :config + (setq which-key-idle-delay 0.3) + (setq which-key-popup-type 'frame) + (which-key-mode) + (which-key-setup-side-window-right-bottom) + ; (which-key-setup-minibuffer) + (set-face-attribute 'which-key-local-map-description-face nil + :weight 'bold)) + +(use-package writeroom-mode + :config (setq fringes-outside-margins 1) + :general (leader-key + "z" '(writeroom-mode :which-key "zen"))) + +(setq default-input-method nil) +;; (map! :leader +;; (:prefix-map ("l" . "language") +;; :desc "English" "e" (lambda () (interactive) (deactivate-input-method)) +;; :desc "Japanese" "j" (lambda () (interactive) (set-input-method 'japanese)) +;; :desc "Norwegian" "n" (lambda () (interactive) (set-input-method 'norwegian-keyboard)) +;; :desc "Latin" "l" (lambda () (interactive) (set-input-method 'latin-1-postfix)) +;; :desc "TeX" "t" (lambda () (interactive) (set-input-method 'TeX)))) + +(defun header_comment () + "Function to make a header comment" + (interactive) + (save-excursion + (let (start end commentString) + (setq start (line-beginning-position) ) + (setq end (line-end-position) ) + (setq commentString (thing-at-point 'line) ) + + (delete-region start end) + (insert + (concat + (cdr (call-process "toilet" nil t nil "-f" "pagga" commentString)) "\n" + commentString)) + (comment-region start (line-end-position)) + ))) + +(leader-key + "ic" '(header_comment :which-key "header comment")) + +;; (use-package! flycheck-popup-tip +;; :config (flycheck-popup-tip-error-prefix "E -> ")) +;; +;; (defun scroll-error-up () +;; (interactive) +;; (message (prin1-to-string flycheck-popup-tip-object)) +;; (popup-scroll-up flycheck-popup-tip-object)) +;; +;; (defun scroll-error-down () +;; (interactive) +;; (popup-scroll-down flycheck-popup-tip-object)) + + +;; (map! +;; (:after flycheck-popup-tip +;; :en "C-j" #'scroll-error-down +;; :en "C-k" #'scroll-error-up)) diff --git a/home/programs/vscode.nix b/home/programs/vscode.nix index 4c7a1eb..fef9d03 100644 --- a/home/programs/vscode.nix +++ b/home/programs/vscode.nix @@ -3,7 +3,7 @@ let mapPrefixToSet = prefix: set: with lib; attrsets.mapAttrs' (k: v: attrsets.nameValuePair ("${prefix}.${k}") v) set; - vs-liveshare = pkgs.callPackage ./vscode-extensions/vsliveshare.nix {}; + # vs-liveshare = pkgs.callPackage ./vscode-extensions/vsliveshare.nix {}; in { @@ -274,7 +274,7 @@ in # ms-vsliveshare.vsliveshare bbenoist.nix christian-kohler.path-intellisense - coenraads.bracket-pair-colorizer-2 + # coenraads.bracket-pair-colorizer-2 haskell.haskell justusadam.language-haskell justusadam.language-haskell @@ -289,7 +289,7 @@ in redhat.vscode-yaml shardulm94.trailing-spaces usernamehw.errorlens - vs-liveshare + # vs-liveshare vscodevim.vim ] ++ pkgs.vscode-utils.extensionsFromVscodeMarketplace [ { @@ -328,12 +328,12 @@ in version = "0.1.4"; sha256 = "02b04756kfk640hri1xw0p6kwjxwp8d2hpmca0iysfivfcmm1bqn"; } - { - name = "indent-rainbow"; - publisher = "oderwat"; - version = "8.2.2"; - sha256 = "1xxljwh66f21fzmhw8icrmxxmfww1s67kf5ja65a8qb1x1rhjjgf"; - } + # { + # name = "indent-rainbow"; + # publisher = "oderwat"; + # version = "8.2.2"; + # sha256 = "1xxljwh66f21fzmhw8icrmxxmfww1s67kf5ja65a8qb1x1rhjjgf"; + # } { name = "vscodeintellicode"; publisher = "VisualStudioExptTeam"; diff --git a/home/services/copyq.nix b/home/services/copyq.nix new file mode 100644 index 0000000..b5444a6 --- /dev/null +++ b/home/services/copyq.nix @@ -0,0 +1,4 @@ +{ ... }: +{ + services.copyq.enable = true; +} diff --git a/home/shellOptions.nix b/home/shellOptions.nix index df29182..ca09a44 100644 --- a/home/shellOptions.nix +++ b/home/shellOptions.nix @@ -133,6 +133,8 @@ in rec { "Nix Stuff" = { nxr = "sudo nixos-rebuild switch"; + nix-check-syntax = "nix-instantiate --parse-only"; + nxr-hm = "sudo nixos-rebuild switch --flake ~/nix#home-manager-tester"; nxr-ks = "sudo nixos-rebuild switch --flake ~/nix#kasei"; @@ -228,7 +230,7 @@ in rec { # the "technically correct definition" of an alias "Actual Aliases" = { - dp = "${dropbox-cli}/bin/dropbox"; + # dp = "${dropbox-cli}/bin/dropbox"; # Having 'watch' with a space after as an alias, enables it to expand other aliases watch = "${procps}/bin/watch "; diff --git a/hosts/common.nix b/hosts/common.nix index ff804ea..b96f43b 100644 --- a/hosts/common.nix +++ b/hosts/common.nix @@ -36,7 +36,7 @@ in { "big-paralell" ]; mandatoryFeatures = []; - sshUser = "nix-builder"; + sshUser = "nix-ssh"; sshKey = secrets.keys.ssh.nixBuilders.tsuki.private; } { @@ -94,14 +94,28 @@ in { i18n = { defaultLocale = "en_US.UTF-8"; inputMethod = lib.mkIf (!machineVars.headless) { + # enabled = "fcitx"; + # engines = with pkgs.fcitx-engines; [ mozc ]; enabled = "fcitx5"; fcitx5.addons = with pkgs; [ fcitx5-mozc - fcitx5-gtk + # fcitx5-gtk + # fcitx5-chinese-addons ]; }; }; + systemd.user.services."fcitx5" = lib.mkIf (config.i18n.inputMethod.enabled == "fcitx5") { + description = "Fcitx5 IME"; + wantedBy = [ "graphical.target" ]; + serviceConfig = { + Type = "simple"; + ExecStart = "${config.i18n.inputMethod.package}/bin/fcitx5"; + ExecReload = "/bin/kill -HUP $MAINPID"; + Restart="on-failure"; + }; + }; + environment = { variables = { EDITOR = "nvim"; @@ -226,10 +240,10 @@ in { resolved.enable = true; - openssh.settings = { - PasswordAuthentication = false; - KbdInteractiveAuthentication = false; - PermitRootLogin = "no"; + openssh= { + passwordAuthentication = false; + kbdInteractiveAuthentication = false; + permitRootLogin = "no"; }; udev.packages = with pkgs; [ @@ -328,8 +342,8 @@ in { clang dart dotnet-sdk - dotnet-sdk_3 - dotnet-sdk_5 + # dotnet-sdk_3 + # dotnet-sdk_5 dotnetPackages.Nuget elm2nix elmPackages.elm @@ -337,7 +351,7 @@ in { gcc ghc ghcid - haskellPackages.Cabal_3_6_3_0 + # haskellPackages.Cabal_3_6_3_0 maven nixfmt nixpkgs-fmt diff --git a/hosts/kasei/configuration.nix b/hosts/kasei/configuration.nix index f9c328c..c4d56f9 100644 --- a/hosts/kasei/configuration.nix +++ b/hosts/kasei/configuration.nix @@ -37,29 +37,43 @@ hostName = "kasei"; networkmanager.enable = true; interfaces.enp6s0.useDHCP = true; - firewall.enable = true; + firewall = { + enable = true; + allowedTCPPorts = [ 7860 ]; + allowedUDPPorts = [ config.services.tailscale.port ]; + checkReversePath = "loose"; + trustedInterfaces = [ "tailscale0" ]; + }; hostId = "f0660cef"; }; services = { - openssh.enable = true; + openssh = { + enable = true; + settings.X11Forwarding = true; + }; xserver.videoDrivers = ["nvidia"]; + tailscale.enable = true; }; # TODO: remove when merged: https://github.com/NixOS/nixpkgs/pull/167388 - systemd.services.logid = { - description = "Logitech Configuration Daemon"; - startLimitIntervalSec = 0; - wants = [ "multi-user.target" ]; - after = [ "multi-user.target" ]; - wantedBy = [ "graphical-session.target" ]; - - serviceConfig = { - Type = "simple"; - ExecStart = "${pkgs.logiops}/bin/logid"; - User = "root"; - ExecReload = "/bin/kill -HUP $MAINPID"; - Restart="on-failure"; + systemd = { + services = { + logid = { + description = "Logitech Configuration Daemon"; + startLimitIntervalSec = 0; + wants = [ "multi-user.target" ]; + after = [ "multi-user.target" ]; + wantedBy = [ "graphical-session.target" ]; + + serviceConfig = { + Type = "simple"; + ExecStart = "${pkgs.logiops}/bin/logid"; + User = "root"; + ExecReload = "/bin/kill -HUP $MAINPID"; + Restart="on-failure"; + }; + }; }; }; @@ -71,9 +85,14 @@ boot = { initrd.availableKernelModules = [ "nvme" "xhci_pci" "ahci" "usb_storage" "usbhid" "sd_mod" "sr_mod" ]; initrd.kernelModules = [ ]; + + # kernelPackages = pkgs.linuxKernel.packages.linux_zen.zfs; + kernelPackages = config.boot.zfs.package.latestCompatibleLinuxPackages; kernelModules = [ "kvm-amd" ]; - blacklistedKernelModules = ["nouveau"]; - kernelParams = ["nomodeset"]; + blacklistedKernelModules = [ "nouveau" ]; + kernelParams = [ "nomodeset" ]; + supportedFilesystems = [ "zfs" ]; + loader = { efi.canTouchEfiVariables = false; grub = { @@ -118,5 +137,3 @@ logitech.wireless.enable = true; }; } - - diff --git a/hosts/special/home-manager-tester/fcitx5-material-color.nix b/hosts/special/home-manager-tester/fcitx5-material-color.nix new file mode 100644 index 0000000..25bb20f --- /dev/null +++ b/hosts/special/home-manager-tester/fcitx5-material-color.nix @@ -0,0 +1,49 @@ +{ + lib, + + stdenvNoCC, + fetchFromGitHub +}: +stdenvNoCC.mkDerivation rec { + pname = "fcitx5-material-color"; + version = "0.2.1"; + + src = fetchFromGitHub { + owner = "hosxy"; + repo = "Fcitx5-Material-Color"; + rev = "${version}"; + sha256 = "i9JHIJ+cHLTBZUNzj9Ujl3LIdkCllTWpO1Ta4OT1LTc="; + }; + + outputs = [ "out" "doc" ]; + + installPhase = '' + runHook preInstall + + install -Dm644 -t $out/usr/share/fcitx5/themes/fcitx5-material-color radio.png arrow.png + + find $src -type f -name 'theme*.conf' \ + -exec install -Dm644 -t $out/usr/share/fcitx5/themes/fcitx5-material-color {} + + + find $src/screenshot -type f \ + -exec install -Dm644 -t $doc/usr/share/doc/fcitx5/themes/fcitx5-material-color {} + + + install -Dm644 -t $doc/usr/share/doc/fcitx5/themes/fcitx5-material-color \ + LICENSE \ + README.md + + runHook postInstall + ''; + + meta = with lib; { + description = ""; + longDescription = '' + A fcitx5 skin with colors from Material Design. + Designed to mimick the interface of the Windows 10 IME. + ''; + homepage = "https://github.com/hosxy/Fcitx5-Material-Color"; + license = licenses.asl20; + maintainers = [ maintainers.h7x4 ]; + platforms = platforms.all; + }; +} diff --git a/modules/socketActivation.nix b/modules/socketActivation.nix new file mode 100644 index 0000000..0790e8a --- /dev/null +++ b/modules/socketActivation.nix @@ -0,0 +1,139 @@ +{ config, pkgs, lib, ... }: +let + inherit (lib) mkOption types mdDoc; + cfg = lib.filterAttrs (_: value: value.enable) config.local.socketActivation; +in +{ + options.local.socketActivation = mkOption { + type = types.attrsOf (types.submodule ({ name, ... }: { + options = { + enable = lib.mkEnableOption "socket activation for "; + + service = mkOption { + type = types.str; + default = name; + defaultText = ""; + example = "myservice"; + description = mdDoc "Systemd service name"; + }; + + privateNamespace = mkOption { + type = types.bool; + default = true; + example = false; + description = mdDoc '' + Whether to isolate the network of the original service. + + This is recommended, but might be impractical if the original + service also uses networking for its own operation. + ''; + }; + + originalSocketAddress = mkOption { + type = types.str; + example = "localhost:8080"; + description = mdDoc '' + Socket that the original service is listening to. + + This could be a TCP or UNIX socket. + ''; + }; + + newSocketAddress = mkOption { + type = with types; either str port; + example = "localhost:8080"; + description = mdDoc '' + Addres of the new systemd socket. + + This could be a TCP or UNIX socket. + ''; + }; + + connectionsMax = mkOption { + type = types.int; + default = 256; + example = 1024; + description = mdDoc '' + Sets the maximum number of simultaneous connections. + If the limit of concurrent connections is reached further connections will be refused. + + See + ''; + }; + + exitIdleTime = mkOption { + type = types.nullOr types.str; + default = "5m"; + example = "1h"; + description = mdDoc '' + Amount of inactivity time, before systemd shuts down the service. + If this is set to `null`, the service will never stop. + + See + ''; + }; + }; + })); + description = mdDoc "Forcefully socket activated systemd services"; + default = { }; + }; + + config = { + assertions = lib.mapAttrsToList (name: value: { + # NOTE: This assertion is missing a lot of invalid cases. + # The original socket address could've been "localhost:1234" and now only 1234, + # while still meaning the same thing. + # Also, if the originalSocketAddress and newSocketAddress is the same UNIX socket path + # it doesn't matter whether they're in different namespaces AFAIK, they'll still clash. + assertion = !value.privateNamespace -> (value.originalSocketAddress != value.newSocketAddress); + message = '' + The new proxied socket address of "${name}" clashes with its original socket address. + Either enable `privateNamespace` to isolate the original service' network, or use a separate + socket address. + ''; + }) cfg; + + systemd = lib.mkMerge ((lib.flip lib.mapAttrsToList) cfg (name: value: let + originalService = config.systemd.services.${value.service}; + in { + sockets."${name}-proxy" = { + wantedBy = [ "sockets.target" ]; + socketConfig = { + ListenStream = value.newSocketAddress; + }; + }; + + services."${name}-proxy" = rec { + requires = [ + "${name}.service" + "${name}-proxy.socket" + ]; + after = requires; + + unitConfig = lib.mkIf value.privateNamespace { + JoinsNamespaceOf = "${value.service}.service"; + }; + + serviceConfig = { + ExecStart = let + args = lib.cli.toGNUCommandLineShell { } { + exit-idle-time = if value.exitIdleTime != null then value.exitIdleTime else "infinity"; + connections-max = value.connectionsMax; + }; + in ''${pkgs.systemd}/lib/systemd/systemd-socket-proxyd ${args} "${cfg.${name}.originalSocketAddress}"''; + PrivateNetwork = value.privateNamespace; + }; + }; + + services.${name} = { + unitConfig = { + StopWhenUnneeded = true; + }; + + serviceConfig = lib.mkIf value.privateNamespace { + PrivateNetwork = true; + }; + }; + })); + }; +} diff --git a/package-overrides/pcloud.nix b/package-overrides/pcloud.nix new file mode 100644 index 0000000..9a5742e --- /dev/null +++ b/package-overrides/pcloud.nix @@ -0,0 +1,132 @@ +# Even though pCloud Drive is redistributed as a plug-n-play AppImage, it +# requires a little bit more love because of the way Nix launches those types +# of applications. +# +# What Nix does, simplifying a bit, is that it extracts an AppImage and starts +# it via buildFHSEnv - this is totally fine for majority of apps, but makes +# it by-design *impossible* to launch SUID wrappers [^1]; in case of pCloud, +# it's fusermount. +# (so pCloud starts, but silently fails to mount the FUSE drive.) +# +# To overcome this issue, we're manually extracting the AppImage and then treat +# it as if it was a regular, good-ol' application requiring some standard path +# fixes. +# +# ^1 https://github.com/NixOS/nixpkgs/issues/69338 + +{ + # Build dependencies + appimageTools +, autoPatchelfHook +, fetchzip +, lib +, stdenv + + # Runtime dependencies; + # A few additional ones (e.g. Node) are already shipped together with the + # AppImage, so we don't have to duplicate them here. +, alsa-lib +, dbus-glib +, fuse +, gsettings-desktop-schemas +, gtk3 +, libdbusmenu-gtk2 +, libXdamage +, libX11 +, libappindicator +, libindicator +, libnotify +, nss +, udev +}: + +let + pname = "pcloud"; + version = "1.12.0"; + code = "XZyc9wVZAbFzyV8ElP71D5v170CvEmVtmrB7"; + # Archive link's codes: https://www.pcloud.com/release-notes/linux.html + src = fetchzip { + url = "https://api.pcloud.com/getpubzip?code=${code}&filename=${pname}-${version}.zip"; + hash = "sha256-QzBlpF+qtNdSZFv3gU0mQhpVyPTWdGH3c+UHKKGfvKc="; + }; + + appimageContents = appimageTools.extractType2 { + name = "${pname}-${version}"; + src = "${src}/pcloud"; + }; + +in +stdenv.mkDerivation { + inherit pname version; + + src = appimageContents; + + dontConfigure = true; + dontBuild = true; + + nativeBuildInputs = [ + autoPatchelfHook + ]; + + buildInputs = [ + alsa-lib + dbus-glib + fuse + gtk3 + libX11 + libXdamage + libappindicator + libdbusmenu-gtk2 + libindicator + libnotify + nss + udev + ]; + + installPhase = '' + mkdir "$out" + cp -ar . "$out/app" + cd "$out" + + # Remove the AppImage runner, since users are not supposed to use it; the + # actual entry point is the `pcloud` binary + rm app/AppRun + + # Adjust directory structure, so that the `.desktop` etc. files are + # properly detected + mkdir bin + mv app/usr/share . + # mv app/usr/lib . + + # Adjust the `.desktop` file + mkdir share/applications + + substitute \ + app/pcloud.desktop \ + share/applications/pcloud.desktop \ + --replace 'Name=pcloud' 'Name=pCloud' \ + --replace 'Exec=AppRun' 'Exec=${pname}' + + # Build the main executable + cat > bin/pcloud <