diff --git a/flake.lock b/flake.lock index de89669..bc23e36 100644 --- a/flake.lock +++ b/flake.lock @@ -14,11 +14,11 @@ ] }, "locked": { - "lastModified": 1723293904, - "narHash": "sha256-b+uqzj+Wa6xgMS9aNbX4I+sXeb5biPDi39VgvSFqFvU=", + "lastModified": 1718371084, + "narHash": "sha256-abpBi61mg0g+lFFU0zY4C6oP6fBwPzbHPKBGw676xsA=", "owner": "ryantm", "repo": "agenix", - "rev": "f6291c5935fdc4e0bef208cfc0dcab7e3f7a1c41", + "rev": "3a56735779db467538fb2e577eda28a9daacaca6", "type": "github" }, "original": { @@ -73,11 +73,11 @@ ] }, "locked": { - "lastModified": 1730504689, - "narHash": "sha256-hgmguH29K2fvs9szpq2r3pz2/8cJd2LPS+b4tfNFCwE=", + "lastModified": 1717285511, + "narHash": "sha256-iKzJcpdXih14qYVcZ9QC9XuZYnPc6T8YImb6dX166kw=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "506278e768c2a08bec68eb62932193e341f55c90", + "rev": "2a55567fcf15b1b1c7ed712a2c6fadaec7412ea8", "type": "github" }, "original": { @@ -94,11 +94,11 @@ ] }, "locked": { - "lastModified": 1726560853, - "narHash": "sha256-X6rJYSESBVr3hBoH0WbKE5KvhPU5bloyZ2L4K60/fPQ=", + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "c1dfcf08411b08f6b8615f7d8971a2bfa81d5e8a", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", "type": "github" }, "original": { @@ -136,11 +136,11 @@ ] }, "locked": { - "lastModified": 1730837930, - "narHash": "sha256-0kZL4m+bKBJUBQse0HanewWO0g8hDdCvBhudzxgehqc=", + "lastModified": 1719438532, + "narHash": "sha256-/Vmso2ZMoFE3M7d1MRsQ2K5sR8CVKnrM6t1ys9Xjpz4=", "owner": "nix-community", "repo": "home-manager", - "rev": "2f607e07f3ac7e53541120536708e824acccfaa8", + "rev": "1a4f12ae0bda877ec4099b429cf439aad897d7e9", "type": "github" }, "original": { @@ -168,11 +168,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1730785428, - "narHash": "sha256-Zwl8YgTVJTEum+L+0zVAWvXAGbWAuXHax3KzuejaDyo=", + "lastModified": 1719254875, + "narHash": "sha256-ECni+IkwXjusHsm9Sexdtq8weAq/yUyt1TWIemXt3Ko=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "4aa36568d413aca0ea84a1684d2d46f55dbabad7", + "rev": "2893f56de08021cffd9b6b6dfc70fd9ccd51eb60", "type": "github" }, "original": { @@ -184,11 +184,11 @@ }, "nur": { "locked": { - "lastModified": 1730885145, - "narHash": "sha256-UPrBEY0No1O3ULb67xYjRh2r3u7MnZovfo1oYSPCIxI=", + "lastModified": 1719564461, + "narHash": "sha256-wCFs1sf1tPoV3nCG5N5KaakAKm88FyzN6pRdOsOqNZg=", "owner": "nix-community", "repo": "NUR", - "rev": "c0d8828600ef47d475e6ec33513bf9af6eb6b991", + "rev": "7369862c4a8f293f6fde79044369dad7dfc04798", "type": "github" }, "original": { @@ -210,11 +210,11 @@ ] }, "locked": { - "lastModified": 1730814269, - "narHash": "sha256-fWPHyhYE6xvMI1eGY3pwBTq85wcy1YXqdzTZF+06nOg=", + "lastModified": 1719259945, + "narHash": "sha256-F1h+XIsGKT9TkGO3omxDLEb/9jOOsI6NnzsXFsZhry4=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "d70155fdc00df4628446352fc58adc640cd705c2", + "rev": "0ff4381bbb8f7a52ca4a851660fc7a437a4c6e07", "type": "github" }, "original": { diff --git a/hosts/nixos/porthos/secrets/matrix/sliding-sync-secret.age b/hosts/nixos/porthos/secrets/matrix/sliding-sync-secret.age new file mode 100644 index 0000000..e938cfa --- /dev/null +++ b/hosts/nixos/porthos/secrets/matrix/sliding-sync-secret.age @@ -0,0 +1,8 @@ +age-encryption.org/v1 +-> ssh-ed25519 cKojmg xRtF3XVc7yPicAV/E4U7mn0itvD0h1BWBTjwunuoe2E +OkB9sjGB3ulH4Feuyj3Ed0DBG4+mghW/Qpum9oXL/8c +-> ssh-ed25519 jPowng 1r8drqhz1yZdTq0Kvqya+ArU1C2fkN7Gg9LiWWfeUFg +cjbxntVwHvqLaJpiKs/Y8ojeb6e3/cLFcsoeuoobfFg +--- B1qA2PylJBrdZxZtCzlU2kRPvxLM+IrXTvR+ERxVtTY +"W9bg~/b4ՆI +} -NC7vWb?8=wB UpJClOșnO\ \ No newline at end of file diff --git a/hosts/nixos/porthos/secrets/pdf-edit/login.age b/hosts/nixos/porthos/secrets/pdf-edit/login.age deleted file mode 100644 index 7f13f88..0000000 --- a/hosts/nixos/porthos/secrets/pdf-edit/login.age +++ /dev/null @@ -1,8 +0,0 @@ -age-encryption.org/v1 --> ssh-ed25519 cKojmg VYlHgHSLpfKb5bn1XA3aCpfX7M23DgbraLxxOfo9PDk -Rj+mDvAsWX3WwpuhTrOubmo17j/aud5+P87df5bosBA --> ssh-ed25519 jPowng o9ZFaYrITZ6DjWw07Vk/+TkuU187/ytlEK4sw7G32G4 -zmxlpDvDDEgQFqBVARXeX1ABhvfJ4uAHfa6mIxXzjAY ---- k/d9FWW8/OSo8EllwOBV74pZyX918u54jEljGk3ATUc -4+2{hE7!ҭGA`ׁ_@ߗR_6JL4v,6%#^  BOF|7ܽL]jR -B۾as]xS pbo#J1Q=t}5>O{+. M"7ey \ No newline at end of file diff --git a/hosts/nixos/porthos/secrets/secrets.nix b/hosts/nixos/porthos/secrets/secrets.nix index 68e90f2..c43376b 100644 --- a/hosts/nixos/porthos/secrets/secrets.nix +++ b/hosts/nixos/porthos/secrets/secrets.nix @@ -48,6 +48,9 @@ in owner = "matrix-synapse"; publicKeys = all; }; + "matrix/sliding-sync-secret.age" = { + publicKeys = all; + }; "mealie/mail.age" = { publicKeys = all; @@ -74,24 +77,13 @@ in "paperless/password.age".publicKeys = all; "paperless/secret-key.age".publicKeys = all; - "pdf-edit/login.age".publicKeys = all; - "podgrab/password.age".publicKeys = all; "pyload/credentials.age".publicKeys = all; - "sso/auth-key.age" = { - owner = "nginx-sso"; - publicKeys = all; - }; - "sso/ambroisie/password-hash.age" = { - owner = "nginx-sso"; - publicKeys = all; - }; - "sso/ambroisie/totp-secret.age" = { - owner = "nginx-sso"; - publicKeys = all; - }; + "sso/auth-key.age".publicKeys = all; + "sso/ambroisie/password-hash.age".publicKeys = all; + "sso/ambroisie/totp-secret.age".publicKeys = all; "tandoor-recipes/secret-key.age".publicKeys = all; diff --git a/hosts/nixos/porthos/services.nix b/hosts/nixos/porthos/services.nix index a2339f4..23901f7 100644 --- a/hosts/nixos/porthos/services.nix +++ b/hosts/nixos/porthos/services.nix @@ -69,6 +69,9 @@ in mailConfigFile = secrets."matrix/mail".path; # Only necessary when doing the initial registration secretFile = secrets."matrix/secret".path; + slidingSync = { + secretFile = secrets."matrix/sliding-sync-secret".path; + }; }; mealie = { enable = true; @@ -124,10 +127,20 @@ in passwordFile = secrets."paperless/password".path; secretKeyFile = secrets."paperless/secret-key".path; }; - # Sometimes, editing PDFs is useful - pdf-edit = { + # The whole *arr software suite + pirate = { enable = true; - loginFile = secrets."pdf-edit/login".path; + # ... But not Lidarr because I don't care for music that much + lidarr = { + enable = false; + }; + }; + # Podcast automatic downloader + podgrab = { + enable = true; + passwordFile = secrets."podgrab/password".path; + dataDir = "/data/media/podcasts"; + port = 9598; }; # Regular backups postgresql-backup.enable = true; @@ -139,15 +152,7 @@ in rss-bridge.enable = true; # Usenet client sabnzbd.enable = true; - # The whole *arr software suite - servarr = { - enable = true; - # ... But not Lidarr because I don't care for music that much - lidarr = { - enable = false; - }; - }; - # Because I still need to play sysadmin + # Because I stilll need to play sysadmin ssh-server.enable = true; # Recipe manager tandoor-recipes = { diff --git a/modules/home/atuin/default.nix b/modules/home/atuin/default.nix index 3f06263..b8973cc 100644 --- a/modules/home/atuin/default.nix +++ b/modules/home/atuin/default.nix @@ -1,19 +1,15 @@ -{ config, lib, pkgs, ... }: +{ config, lib, ... }: let cfg = config.my.home.atuin; in { options.my.home.atuin = with lib; { enable = my.mkDisableOption "atuin configuration"; - - # I want the full experience by default - package = mkPackageOption pkgs "atuin" { }; }; config = lib.mkIf cfg.enable { programs.atuin = { enable = true; - inherit (cfg) package; flags = [ # I *despise* this hijacking of the up key, even though I use Ctrl-p diff --git a/modules/home/calibre/default.nix b/modules/home/calibre/default.nix index de7c126..6edf654 100644 --- a/modules/home/calibre/default.nix +++ b/modules/home/calibre/default.nix @@ -5,13 +5,11 @@ in { options.my.home.calibre = with lib; { enable = mkEnableOption "calibre configuration"; - - package = mkPackageOption pkgs "calibre" { }; }; config = lib.mkIf cfg.enable { home.packages = with pkgs; [ - cfg.package + calibre ]; }; } diff --git a/modules/home/direnv/lib/android.sh b/modules/home/direnv/lib/android.sh index 9344aea..fa2f856 100644 --- a/modules/home/direnv/lib/android.sh +++ b/modules/home/direnv/lib/android.sh @@ -1,4 +1,4 @@ -# shellcheck shell=bash +#shellcheck shell=bash # shellcheck disable=2155 use_android() { @@ -32,16 +32,10 @@ use_android() { -b|--build-tools) build_tools_version="$2" shift 2 - if ! [ -e "$ANDROID_HOME/build-tools/$build_tools_version" ]; then - log_error "use_android: build-tools version '$build_tools_version' does not exist" - fi ;; -n|--ndk) ndk_version="$2" shift 2 - if ! [ -e "$ANDROID_HOME/ndk/$ndk_version" ]; then - log_error "use_android: NDK version '$ndk_version' does not exist" - fi ;; --) shift diff --git a/modules/home/direnv/lib/nix.sh b/modules/home/direnv/lib/nix.sh index 4b6c547..a65eb31 100644 --- a/modules/home/direnv/lib/nix.sh +++ b/modules/home/direnv/lib/nix.sh @@ -1,4 +1,4 @@ -# shellcheck shell=bash +#shellcheck shell=bash use_pkgs() { if ! has nix; then diff --git a/modules/home/direnv/lib/postgres.sh b/modules/home/direnv/lib/postgres.sh index 46e171d..c2e6a8f 100644 --- a/modules/home/direnv/lib/postgres.sh +++ b/modules/home/direnv/lib/postgres.sh @@ -1,4 +1,4 @@ -# shellcheck shell=bash +#shellcheck shell=bash layout_postgres() { if ! has postgres || ! has initdb; then diff --git a/modules/home/direnv/lib/python.sh b/modules/home/direnv/lib/python.sh index 780fbe6..15a273f 100644 --- a/modules/home/direnv/lib/python.sh +++ b/modules/home/direnv/lib/python.sh @@ -1,4 +1,4 @@ -# shellcheck shell=bash +#shellcheck shell=bash layout_poetry() { if ! has poetry; then @@ -9,12 +9,12 @@ layout_poetry() { if [[ ! -f pyproject.toml ]]; then # shellcheck disable=2016 - log_error 'layout_poetry: no pyproject.toml found. Use `poetry init` to create one first' + log_error 'layout_poetry: no pyproject.toml found. Use `poetry new` or `poetry init` to create one first' return 1 fi # create venv if it doesn't exist - poetry run -q -- true + poetry run true # shellcheck disable=2155 export VIRTUAL_ENV=$(poetry env info --path) @@ -23,34 +23,3 @@ layout_poetry() { watch_file pyproject.toml watch_file poetry.lock } - -layout_uv() { - if ! has uv; then - # shellcheck disable=2016 - log_error 'layout_uv: `uv` is not in PATH' - return 1 - fi - - if [[ ! -f pyproject.toml ]]; then - # shellcheck disable=2016 - log_error 'layout_uv: no pyproject.toml found. Use `uv init` to create one first' - return 1 - fi - - local default_venv="$PWD/.venv" - : "${VIRTUAL_ENV:=$default_venv}" - - # Use non-default venv path if required - if [ "$VIRTUAL_ENV" != "$default_venv" ]; then - export UV_PROJECT_ENVIRONMENT="$VIRTUAL_ENV" - fi - - # create venv if it doesn't exist - uv venv -q - - export VIRTUAL_ENV - export UV_ACTIVE=1 - PATH_add "$VIRTUAL_ENV/bin" - watch_file pyproject.toml - watch_file uv.lock -} diff --git a/modules/home/discord/default.nix b/modules/home/discord/default.nix index bfa5d40..7348bb4 100644 --- a/modules/home/discord/default.nix +++ b/modules/home/discord/default.nix @@ -7,13 +7,11 @@ in { options.my.home.discord = with lib; { enable = mkEnableOption "discord configuration"; - - package = mkPackageOption pkgs "discord" { }; }; config = lib.mkIf cfg.enable { home.packages = with pkgs; [ - cfg.package + discord ]; xdg.configFile."discord/settings.json".source = diff --git a/modules/home/firefox/tridactyl/tridactylrc b/modules/home/firefox/tridactyl/tridactylrc index 775719c..36bd59d 100644 --- a/modules/home/firefox/tridactyl/tridactylrc +++ b/modules/home/firefox/tridactyl/tridactylrc @@ -4,7 +4,7 @@ " Use dark color scheme colorscheme dark -" Make tridactyl open Vim in my preferred terminal +" Make tridactyl open Vim in my prefered terminal set editorcmd @editorcmd@ " Remove editor file after use diff --git a/modules/home/gdb/default.nix b/modules/home/gdb/default.nix index 1ffc6bd..fe8eb69 100644 --- a/modules/home/gdb/default.nix +++ b/modules/home/gdb/default.nix @@ -6,28 +6,33 @@ in options.my.home.gdb = with lib; { enable = my.mkDisableOption "gdb configuration"; - package = mkPackageOption pkgs "gdb" { }; - rr = { enable = my.mkDisableOption "rr configuration"; - package = mkPackageOption pkgs "rr" { }; + package = mkOption { + type = types.package; + default = pkgs.rr; + defaultText = literalExample "pkgs.rr"; + description = '' + Package providing rr + ''; + }; }; }; config = lib.mkIf cfg.enable (lib.mkMerge [ { home.packages = with pkgs; [ - cfg.package + gdb ]; xdg = { configFile."gdb/gdbinit".source = ./gdbinit; - stateFile."gdb/.keep".text = ""; + dataFile. "gdb/.keep".text = ""; }; home.sessionVariables = { - GDBHISTFILE = "${config.xdg.stateHome}/gdb/gdb_history"; + GDBHISTFILE = "${config.xdg.dataHome}/gdb/gdb_history"; }; } diff --git a/modules/home/gtk/default.nix b/modules/home/gtk/default.nix index f10087d..62d3f81 100644 --- a/modules/home/gtk/default.nix +++ b/modules/home/gtk/default.nix @@ -21,12 +21,12 @@ in }; iconTheme = { - package = pkgs.gnome-themes-extra; + package = pkgs.gnome.gnome-themes-extra; name = "Adwaita"; }; theme = { - package = pkgs.gnome-themes-extra; + package = pkgs.gnome.gnome-themes-extra; name = "Adwaita"; }; }; diff --git a/modules/home/mail/accounts/default.nix b/modules/home/mail/accounts/default.nix index 202b9bc..8886139 100644 --- a/modules/home/mail/accounts/default.nix +++ b/modules/home/mail/accounts/default.nix @@ -58,7 +58,7 @@ in { config.accounts.email.accounts = { personal = lib.mkMerge [ - # Common configuration + # Common configuraton (mkConfig { domain = "belanyi.fr"; address = "bruno"; @@ -70,7 +70,7 @@ in ]; gmail = lib.mkMerge [ - # Common configuration + # Common configuraton (mkConfig { domain = "gmail.com"; address = "brunobelanyi"; diff --git a/modules/home/nix/default.nix b/modules/home/nix/default.nix index c67cc6a..c0bbcc8 100644 --- a/modules/home/nix/default.nix +++ b/modules/home/nix/default.nix @@ -22,10 +22,6 @@ in options.my.home.nix = with lib; { enable = my.mkDisableOption "nix configuration"; - gc = { - enable = my.mkDisableOption "nix GC configuration"; - }; - cache = { selfHosted = my.mkDisableOption "self-hosted cache"; }; @@ -64,22 +60,6 @@ in }; } - (lib.mkIf cfg.gc.enable { - nix.gc = { - automatic = true; - - # Every week, with some wiggle room - frequency = "weekly"; - randomizedDelaySec = "10min"; - - # Use a persistent timer for e.g: laptops - persistent = true; - - # Delete old profiles automatically after 15 days - options = "--delete-older-than 15d"; - }; - }) - (lib.mkIf cfg.cache.selfHosted { nix = { settings = { diff --git a/modules/home/nixpkgs/default.nix b/modules/home/nixpkgs/default.nix index 720fc9b..a4946db 100644 --- a/modules/home/nixpkgs/default.nix +++ b/modules/home/nixpkgs/default.nix @@ -13,8 +13,8 @@ in ]; home.sessionVariables = { - GITHUB_TOKEN = ''$(cat "${config.age.secrets."github/token".path}")''; - GITHUB_API_TOKEN = ''$(cat "${config.age.secrets."github/token".path}")''; + GITHUB_TOKEN = ''$(cat ${lib.escapeShellArg config.age.secrets."github/token".path})''; + GITHUB_API_TOKEN = ''$(cat ${lib.escapeShellArg config.age.secrets."github/token".path})''; }; }; } diff --git a/modules/home/pager/default.nix b/modules/home/pager/default.nix index 1119440..e304097 100644 --- a/modules/home/pager/default.nix +++ b/modules/home/pager/default.nix @@ -15,7 +15,7 @@ in # Clear the screen on start and exit LESS = "-R -+X -c"; # Better XDG compliance - LESSHISTFILE = "${config.xdg.stateHome}/less/history"; + LESSHISTFILE = "${config.xdg.dataHome}/less/history"; LESSKEY = "${config.xdg.configHome}/less/lesskey"; }; }; diff --git a/modules/home/tmux/default.nix b/modules/home/tmux/default.nix index 71ce4ca..501b954 100644 --- a/modules/home/tmux/default.nix +++ b/modules/home/tmux/default.nix @@ -30,7 +30,7 @@ in }); default = { ${config.my.home.terminal.program} = { }; }; - defaultText = literalExpression '' + defaultText = litteralExpression '' { ''${config.my.home.terminal.program} = { }; }; ''; example = { xterm-256color = { }; }; diff --git a/modules/home/vim/after/ftplugin/netrw.vim b/modules/home/vim/after/ftplugin/netrw.vim new file mode 100644 index 0000000..e3689f8 --- /dev/null +++ b/modules/home/vim/after/ftplugin/netrw.vim @@ -0,0 +1,6 @@ +" Create the `b:undo_ftplugin` variable if it doesn't exist +call ftplugined#check_undo_ft() + +" Don't show Netrw in buffer list +setlocal bufhidden=delete +let b:undo_ftplugin='|setlocal bufhidden<' diff --git a/modules/home/vim/after/plugin/mappings/misc.lua b/modules/home/vim/after/plugin/mappings/misc.lua new file mode 100644 index 0000000..6aa25a2 --- /dev/null +++ b/modules/home/vim/after/plugin/mappings/misc.lua @@ -0,0 +1,7 @@ +local wk = require("which-key") + +local keys = { + [""] = { "nohls", "Clear search highlight" }, +} + +wk.register(keys, { prefix = "" }) diff --git a/modules/home/vim/after/plugin/mappings/telescope.lua b/modules/home/vim/after/plugin/mappings/telescope.lua new file mode 100644 index 0000000..0867b36 --- /dev/null +++ b/modules/home/vim/after/plugin/mappings/telescope.lua @@ -0,0 +1,15 @@ +local wk = require("which-key") +local telescope_builtin = require("telescope.builtin") + +local keys = { + f = { + name = "Fuzzy finder", + b = { telescope_builtin.buffers, "Open buffers" }, + f = { telescope_builtin.git_files, "Git tracked files" }, + F = { telescope_builtin.find_files, "Files" }, + g = { telescope_builtin.live_grep, "Grep string" }, + G = { telescope_builtin.grep_string, "Grep string under cursor" }, + }, +} + +wk.register(keys, { prefix = "" }) diff --git a/modules/home/vim/after/plugin/mappings/tree-sitter-textobjects.lua b/modules/home/vim/after/plugin/mappings/tree-sitter-textobjects.lua new file mode 100644 index 0000000..631731c --- /dev/null +++ b/modules/home/vim/after/plugin/mappings/tree-sitter-textobjects.lua @@ -0,0 +1,30 @@ +local wk = require("which-key") + +local motions = { + ["]m"] = "Next method start", + ["]M"] = "Next method end", + ["]S"] = "Next statement start", + ["]]"] = "Next class start", + ["]["] = "Next class end", + ["[m"] = "Previous method start", + ["[M"] = "Previous method end", + ["[S"] = "Previous statement start", + ["[["] = "Previous class start", + ["[]"] = "Previous class end", +} + +local objects = { + ["aa"] = "a parameter", + ["ia"] = "inner parameter", + ["ab"] = "a block", + ["ib"] = "inner block", + ["ac"] = "a class", + ["ic"] = "inner class", + ["af"] = "a function", + ["if"] = "inner function", + ["ak"] = "a comment", + ["aS"] = "a statement", +} + +wk.register(motions, { mode = "n" }) +wk.register(objects, { mode = "o" }) diff --git a/modules/home/vim/after/plugin/mappings/unimpaired.lua b/modules/home/vim/after/plugin/mappings/unimpaired.lua index 82aab05..f502056 100644 --- a/modules/home/vim/after/plugin/mappings/unimpaired.lua +++ b/modules/home/vim/after/plugin/mappings/unimpaired.lua @@ -3,124 +3,126 @@ local wk = require("which-key") local lsp = require("ambroisie.lsp") local keys = { - -- Previous - { "[", group = "Previous" }, - -- Edition and navigation mappings - { "[", desc = "Insert blank line above" }, - { "[", desc = "Previous location list file" }, - { "[", desc = "Previous quickfix list file" }, - { "[", desc = "Previous tag in preview window" }, - { "[a", desc = "Previous argument" }, - { "[A", desc = "First argument" }, - { "[b", desc = "Previous buffer" }, - { "[B", desc = "First buffer" }, - { "[e", desc = "Exchange previous line" }, - { "[f", desc = "Previous file in directory" }, - { "[l", desc = "Previous location list entry" }, - { "[L", desc = "First Location list entry" }, - { "[n", desc = "Previous conflict marker/diff hunk" }, - { "[p", desc = "Paste line above" }, - { "[P", desc = "Paste line above" }, - { "[q", desc = "Previous quickfix list entry" }, - { "[Q", desc = "First quickfix list entry" }, - { "[t", desc = "Previous matching tag" }, - { "[T", desc = "First matching tag" }, - { "[z", desc = "Previous fold" }, - -- Encoding - { "[C", desc = "C string encode" }, - { "[u", desc = "URL encode" }, - { "[x", desc = "XML encode" }, - { "[y", desc = "C string encode" }, - -- Custom - { "[d", lsp.goto_prev_diagnostic, desc = "Previous diagnostic" }, + -- Edition and navigation mappins + ["["] = { + name = "Previous", + [""] = "Insert blank line above", + [""] = "Previous location list file", + [""] = "Previous quickfix list file", + [""] = "Previous tag in preview window", + a = "Previous argument", + A = "First argument", + b = "Previous buffer", + B = "First buffer", + e = "Exchange previous line", + f = "Previous file in directory", + l = "Previous location list entry", + L = "First Location list entry", + n = "Previous conflict marker/diff hunk", + p = "Paste line above", + P = "Paste line above", + q = "Previous quickfix list entry", + Q = "First quickfix list entry", + t = "Previous matching tag", + T = "First matching tag", + z = "Previous fold", + -- Encoding + C = "C string encode", + u = "URL encode", + x = "XML encode", + y = "C string encode", + -- Custom + d = { lsp.goto_prev_diagnostic, "Previous diagnostic" }, + }, + ["]"] = { + name = "Next", + [""] = "Insert blank line below", + [""] = "Next location list file", + [""] = "Next quickfix list file", + [""] = "Next tag in preview window", + a = "Next argument", + A = "Last argument", + b = "Next buffer", + B = "Last buffer", + e = "Exchange next line", + f = "Next file in directory", + l = "Next location list entry", + L = "Last Location list entry", + n = "Next conflict marker/diff hunk", + p = "Paste line below", + P = "Paste line below", + q = "Next quickfix list entry", + Q = "Last quickfix list entry", + t = "Next matching tag", + T = "Last matching tag", + z = "Next fold", + -- Decoding + C = "C string decode", + u = "URL decode", + x = "XML decode", + y = "C string decode", + -- Custom + d = { lsp.goto_next_diagnostic, "Next diagnostic" }, + }, - -- Next - { "]", group = "Next" }, - -- Edition and navigation mappings - { "]", desc = "Insert blank line below" }, - { "]", desc = "Next location list file" }, - { "]", desc = "Next quickfix list file" }, - { "]", desc = "Next tag in preview window" }, - { "]a", desc = "Next argument" }, - { "]A", desc = "Last argument" }, - { "]b", desc = "Next buffer" }, - { "]B", desc = "Last buffer" }, - { "]e", desc = "Exchange next line" }, - { "]f", desc = "Next file in directory" }, - { "]l", desc = "Next location list entry" }, - { "]L", desc = "Last Location list entry" }, - { "]n", desc = "Next conflict marker/diff hunk" }, - { "]p", desc = "Paste line below" }, - { "]P", desc = "Paste line below" }, - { "]q", desc = "Next quickfix list entry" }, - { "]Q", desc = "Last quickfix list entry" }, - { "]t", desc = "Next matching tag" }, - { "]T", desc = "Last matching tag" }, - { "]z", desc = "Next fold" }, - -- Decoding - { "]C", desc = "C string decode" }, - { "]u", desc = "URL decode" }, - { "]x", desc = "XML decode" }, - { "]y", desc = "C string decode" }, - -- Custom - { "]d", lsp.goto_next_diagnostic, desc = "Next diagnostic" }, - - -- Enable option - { "[o", group = "Enable option" }, - { "[ob", desc = "Light background" }, - { "[oc", desc = "Cursor line" }, - { "[od", desc = "Diff" }, - { "[of", "FormatEnable", desc = "LSP Formatting" }, - { "[oh", desc = "Search high-lighting" }, - { "[oi", desc = "Case insensitive search" }, - { "[ol", desc = "List mode" }, - { "[on", desc = "Line numbers" }, - { "[or", desc = "Relative line numbers" }, - { "[op", "lwindow", desc = "Location list" }, - { "[oq", "cwindow", desc = "Quickfix list" }, - { "[ou", desc = "Cursor column" }, - { "[ov", desc = "Virtual editing" }, - { "[ow", desc = "Text wrapping" }, - { "[ox", desc = "Cursor line and column" }, - { "[oz", desc = "Spell checking" }, - - -- Disable option - { "]o", group = "Disable option" }, - { "]ob", desc = "Light background" }, - { "]oc", desc = "Cursor line" }, - { "]od", desc = "Diff" }, - { "]of", "FormatDisable", desc = "LSP Formatting" }, - { "]oh", desc = "Search high-lighting" }, - { "]oi", desc = "Case insensitive search" }, - { "]ol", desc = "List mode" }, - { "]on", desc = "Line numbers" }, - { "]op", "lclose", desc = "Location list" }, - { "]oq", "cclose", desc = "Quickfix list" }, - { "]or", desc = "Relative line numbers" }, - { "]ou", desc = "Cursor column" }, - { "]ov", desc = "Virtual editing" }, - { "]ow", desc = "Text wrapping" }, - { "]ox", desc = "Cursor line and column" }, - { "]oz", desc = "Spell checking" }, - - -- Toggle option - { "yo", group = "Toggle option" }, - { "yob", desc = "Light background" }, - { "yoc", desc = "Cursor line" }, - { "yod", desc = "Diff" }, - { "yof", "FormatToggle", desc = "LSP Formatting" }, - { "yoh", desc = "Search high-lighting" }, - { "yoi", desc = "Case insensitive search" }, - { "yol", desc = "List mode" }, - { "yon", desc = "Line numbers" }, - { "yop", "(qf_loc_toggle)", desc = "Location list" }, - { "yoq", "(qf_qf_toggle)", desc = "Quickfix list" }, - { "yor", desc = "Relative line numbers" }, - { "you", desc = "Cursor column" }, - { "yov", desc = "Virtual editing" }, - { "yow", desc = "Text wrapping" }, - { "yox", desc = "Cursor line and column" }, - { "yoz", desc = "Spell checking" }, + -- Option mappings + ["[o"] = { + name = "Enable option", + b = "Light background", + c = "Cursor line", + d = "Diff", + f = { "FormatEnable", "LSP Formatting" }, + h = "Search high-lighting", + i = "Case insensitive search", + l = "List mode", + n = "Line numbers", + r = "Relative line numbers", + p = { "lwindow", "Location list" }, + q = { "cwindow", "Quickfix list" }, + u = "Cursor column", + v = "Virtual editing", + w = "Text wrapping", + x = "Cursor line and column", + z = "Spell checking", + }, + ["]o"] = { + name = "Option off", + b = "Light background", + c = "Cursor line", + d = "Diff", + f = { "FormatDisable", "LSP Formatting" }, + h = "Search high-lighting", + i = "Case insensitive search", + l = "List mode", + n = "Line numbers", + p = { "lclose", "Location list" }, + q = { "cclose", "Quickfix list" }, + r = "Relative line numbers", + u = "Cursor column", + v = "Virtual editing", + w = "Text wrapping", + x = "Cursor line and column", + z = "Spell checking", + }, + ["yo"] = { + name = "Option toggle", + b = "Light background", + c = "Cursor line", + d = "Diff", + f = { "FormatToggle", "LSP Formatting" }, + h = "Search high-lighting", + i = "Case insensitive search", + l = "List mode", + n = "Line numbers", + p = { "(qf_loc_toggle)", "Location list" }, + q = { "(qf_qf_toggle)", "Quickfix list" }, + r = "Relative line numbers", + u = "Cursor column", + v = "Virtual editing", + w = "Text wrapping", + x = "Cursor line and column", + z = "Spell checking", + }, } -wk.add(keys) +wk.register(keys) diff --git a/modules/home/vim/after/queries/diff/highlights.scm b/modules/home/vim/after/queries/diff/highlights.scm deleted file mode 100644 index c998725..0000000 --- a/modules/home/vim/after/queries/diff/highlights.scm +++ /dev/null @@ -1,5 +0,0 @@ -; extends - -; I want to the line added/removed markers to be the correct color -"+" @diff.plus -"-" @diff.minus diff --git a/modules/home/vim/default.nix b/modules/home/vim/default.nix index 8e6bd5c..d7280fb 100644 --- a/modules/home/vim/default.nix +++ b/modules/home/vim/default.nix @@ -46,9 +46,14 @@ in vim-repeat # Enanche '.' for plugins vim-rsi # Readline mappings vim-unimpaired # Some ex command mappings + vim-vinegar # Better netrw # Languages + rust-vim vim-beancount + vim-jsonnet + vim-nix + vim-toml # General enhancements vim-qf # Better quick-fix list @@ -80,7 +85,6 @@ in dressing-nvim # Integrate native UI hooks with Telescope etc... gitsigns-nvim # Fast git UI integration nvim-surround # Deal with pairs, now in Lua - oil-nvim # Better alternative to NetrW telescope-fzf-native-nvim # Use 'fzf' fuzzy matching algorithm telescope-lsp-handlers-nvim # Use 'telescope' for various LSP actions telescope-nvim # Fuzzy finder interface @@ -100,9 +104,6 @@ in # Shell bash-language-server shfmt - - # Generic - typos-lsp ]; }; diff --git a/modules/home/vim/init.vim b/modules/home/vim/init.vim index 0b54676..3a74c4f 100644 --- a/modules/home/vim/init.vim +++ b/modules/home/vim/init.vim @@ -1,4 +1,4 @@ -" Basic configuration {{{ +" Basic configuraion {{{ """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" " Use UTF-8 set encoding=utf-8 @@ -38,10 +38,10 @@ set tabstop=8 " File parameters {{{ """"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""" -" Disable swap files +" Disable backups, we have source control for that +set nobackup +" Disable swapfiles too set noswapfile -" Enable undo files -set undofile " }}} " UI and UX parameters {{{ @@ -100,13 +100,7 @@ gruvbox.setup({ DiffChange = { fg = colors.aqua, bg = "NONE" }, DiffDelete = { fg = colors.red, bg = "NONE" }, DiffText = { fg = colors.yellow, bg = colors.bg0 }, - -- Directories "pop" better in blue - Directory = { link = "GruvboxBlueBold" }, - }, - italic = { - -- Comments should not be italic, for e.g: box drawing - comments = false, - }, + } }) EOF " Use my preferred colorscheme diff --git a/modules/home/vim/lua/ambroisie/lsp.lua b/modules/home/vim/lua/ambroisie/lsp.lua index eb53da6..dc47366 100644 --- a/modules/home/vim/lua/ambroisie/lsp.lua +++ b/modules/home/vim/lua/ambroisie/lsp.lua @@ -42,7 +42,7 @@ end --- shared LSP configuration callback --- @param client native client configuration ---- @param bufnr int? buffer number of the attached client +--- @param bufnr int? buffer number of the attched client M.on_attach = function(client, bufnr) -- Format on save lsp_format.on_attach(client, bufnr) @@ -87,30 +87,31 @@ M.on_attach = function(client, bufnr) end local keys = { - buffer = bufnr, - -- LSP navigation - { "K", vim.lsp.buf.hover, desc = "Show symbol information" }, - { "", vim.lsp.buf.signature_help, desc = "Show signature information" }, - { "gd", vim.lsp.buf.definition, desc = "Go to definition" }, - { "gD", vim.lsp.buf.declaration, desc = "Go to declaration" }, - { "gi", vim.lsp.buf.implementation, desc = "Go to implementation" }, - { "gr", vim.lsp.buf.references, desc = "List all references" }, - -- Code - { "c", group = "Code" }, - { "ca", vim.lsp.buf.code_action, desc = "Code actions" }, - { "cd", cycle_diagnostics_display, desc = "Cycle diagnostics display" }, - { "cD", show_buffer_diagnostics, desc = "Show buffer diagnostics" }, - { "cr", vim.lsp.buf.rename, desc = "Rename symbol" }, - { "cs", vim.lsp.buf.signature_help, desc = "Show signature" }, - { "ct", vim.lsp.buf.type_definition, desc = "Go to type definition" }, - -- Workspace - { "cw", group = "Workspace" }, - { "cwa", vim.lsp.buf.add_workspace_folder, desc = "Add folder to workspace" }, - { "cwl", list_workspace_folders, desc = "List folders in workspace" }, - { "cwr", vim.lsp.buf.remove_workspace_folder, desc = "Remove folder from workspace" }, + K = { vim.lsp.buf.hover, "Show symbol information" }, + [""] = { vim.lsp.buf.signature_help, "Show signature information" }, + ["gd"] = { vim.lsp.buf.definition, "Go to definition" }, + ["gD"] = { vim.lsp.buf.declaration, "Go to declaration" }, + ["gi"] = { vim.lsp.buf.implementation, "Go to implementation" }, + ["gr"] = { vim.lsp.buf.references, "List all references" }, + + ["c"] = { + name = "Code", + a = { vim.lsp.buf.code_action, "Code actions" }, + d = { cycle_diagnostics_display, "Cycle diagnostics display" }, + D = { show_buffer_diagnostics, "Show buffer diagnostics" }, + r = { vim.lsp.buf.rename, "Rename symbol" }, + s = { vim.lsp.buf.signature_help, "Show signature" }, + t = { vim.lsp.buf.type_definition, "Go to type definition" }, + w = { + name = "Workspace", + a = { vim.lsp.buf.add_workspace_folder, "Add folder to workspace" }, + l = { list_workspace_folders, "List folders in workspace" }, + r = { vim.lsp.buf.remove_workspace_folder, "Remove folder from workspace" }, + }, + }, } - wk.add(keys) + wk.register(keys, { buffer = bufnr }) end return M diff --git a/modules/home/vim/lua/ambroisie/utils.lua b/modules/home/vim/lua/ambroisie/utils.lua index c9e9292..3d2dd3b 100644 --- a/modules/home/vim/lua/ambroisie/utils.lua +++ b/modules/home/vim/lua/ambroisie/utils.lua @@ -48,22 +48,4 @@ M.list_lsp_clients = function(bufnr) return names end ---- partially apply a function with given arguments -M.partial = function(f, ...) - local a = { ... } - local a_len = select("#", ...) - - return function(...) - local tmp = { ... } - local tmp_len = select("#", ...) - - -- Merge arg lists - for i = 1, tmp_len do - a[a_len + i] = tmp[i] - end - - return f(unpack(a, 1, a_len + tmp_len)) - end -end - return M diff --git a/modules/home/vim/plugin/numbertoggle.lua b/modules/home/vim/plugin/numbertoggle.lua index 8042710..1f97fc8 100644 --- a/modules/home/vim/plugin/numbertoggle.lua +++ b/modules/home/vim/plugin/numbertoggle.lua @@ -7,28 +7,17 @@ local numbertoggle = vim.api.nvim_create_augroup("numbertoggle", { clear = true vim.api.nvim_create_autocmd({ "BufEnter", "FocusGained", "InsertLeave", "WinEnter" }, { pattern = "*", group = numbertoggle, - callback = function() - if vim.opt.number:get() then - vim.opt.relativenumber = true - end - end, + command = "if &nu | setlocal rnu | endif", }) vim.api.nvim_create_autocmd({ "BufLeave", "FocusLost", "InsertEnter", "WinLeave" }, { pattern = "*", group = numbertoggle, - callback = function() - if vim.opt.number:get() then - vim.opt.relativenumber = false - end - end, + command = "if &nu | setlocal nornu | endif", }) -- Never show the sign column in a terminal buffer vim.api.nvim_create_autocmd({ "TermOpen" }, { pattern = "*", group = numbertoggle, - callback = function() - vim.opt.number = false - vim.opt.relativenumber = false - end, + command = "setlocal nonu nornu", }) diff --git a/modules/home/vim/plugin/settings/git.lua b/modules/home/vim/plugin/settings/git.lua index b9b92a6..4dbebca 100644 --- a/modules/home/vim/plugin/settings/git.lua +++ b/modules/home/vim/plugin/settings/git.lua @@ -1,75 +1,58 @@ local gitsigns = require("gitsigns") -local utils = require("ambroisie.utils") local wk = require("which-key") ---- Transform `f` into a function which acts on the current visual selection -local function make_visual(f) - return function() - local first = vim.fn.line("v") - local last = vim.fn.line(".") - f({ first, last }) - end -end - -local function nav_hunk(dir) - if vim.wo.diff then - local map = { - prev = "[c", - next = "]c", - } - vim.cmd.normal({ map[dir], bang = true }) - else - gitsigns.nav_hunk(dir) - end -end - gitsigns.setup({ current_line_blame_opts = { -- Show the blame quickly delay = 100, }, - -- Work-around for https://github.com/lewis6991/gitsigns.nvim/issues/929 - signs_staged_enable = false, }) local keys = { -- Navigation - { "[c", utils.partial(nav_hunk, "prev"), desc = "Previous hunk/diff" }, - { "]c", utils.partial(nav_hunk, "next"), desc = "Next hunk/diff" }, + ["[c"] = { "&diff ? '[c' : 'Gitsigns prev_hunk'", "Previous hunk/diff", expr = true }, + ["]c"] = { "&diff ? ']c' : 'Gitsigns next_hunk'", "Next hunk/diff", expr = true }, + -- Commands - { "g", group = "Git" }, - { "gb", gitsigns.toggle_current_line_blame, desc = "Toggle blame virtual text" }, - { "gd", gitsigns.diffthis, desc = "Diff buffer" }, - { "gD", utils.partial(gitsigns.diffthis, "~"), desc = "Diff buffer against last commit" }, - { "gg", "Git", desc = "Git status" }, - { "gh", gitsigns.toggle_deleted, desc = "Show deleted hunks" }, - { "gL", ":spT:Gllog --follow -- %:p", desc = "Current buffer log" }, - { "gm", "(git-messenger)", desc = "Current line blame" }, - { "gp", gitsigns.preview_hunk, desc = "Preview hunk" }, - { "gr", gitsigns.reset_hunk, desc = "Restore hunk" }, - { "gR", gitsigns.reset_buffer, desc = "Restore buffer" }, - { "gs", gitsigns.stage_hunk, desc = "Stage hunk" }, - { "gS", gitsigns.stage_buffer, desc = "Stage buffer" }, - { "gu", gitsigns.undo_stage_hunk, desc = "Undo stage hunk" }, - { "g[", utils.partial(gitsigns.nav_hunk, "prev"), desc = "Previous hunk" }, - { "g]", utils.partial(gitsigns.nav_hunk, "next"), desc = "Next hunk" }, + ["g"] = { + name = "Git", + -- Actions + b = { gitsigns.toggle_current_line_blame, "Toggle blame virtual text" }, + d = { gitsigns.diffthis, "Diff buffer" }, + -- stylua: ignore + D = { function() gitsigns.diffthis("~") end, "Diff buffer against last commit" }, + g = { "Git", "Git status" }, + h = { gitsigns.toggle_deleted, "Show deleted hunks" }, + L = { ":spT:Gllog --follow -- %:p", "Current buffer log" }, + m = { "(git-messenger)", "Current line blame" }, + p = { gitsigns.preview_hunk, "Preview hunk" }, + r = { gitsigns.reset_hunk, "Restore hunk" }, + R = { gitsigns.reset_buffer, "Restore buffer" }, + s = { gitsigns.stage_hunk, "Stage hunk" }, + S = { gitsigns.stage_buffer, "Stage buffer" }, + u = { gitsigns.undo_stage_hunk, "Undo stage hunk" }, + ["["] = { gitsigns.prev_hunk, "Previous hunk" }, + ["]"] = { gitsigns.next_hunk, "Next hunk" }, + }, } local objects = { - mode = "o", - { "ih", gitsigns.select_hunk, desc = "Git hunk" }, -} --- Visual -local visual = { - mode = { "x" }, - { "ih", gitsigns.select_hunk, desc = "Git hunk" }, - { "g", group = "Git" }, - { "gp", gitsigns.preview_hunk, desc = "Preview selection" }, - { "gr", make_visual(gitsigns.reset_hunk), desc = "Restore selection" }, - { "gs", make_visual(gitsigns.stage_hunk), desc = "Stage selection" }, - { "gu", gitsigns.undo_stage_hunk, desc = "Undo stage selection" }, + ["ih"] = { gitsigns.select_hunk, "Git hunk" }, } -wk.add(keys) -wk.add(objects) -wk.add(visual) +local visual = { + ["ih"] = { gitsigns.select_hunk, "Git hunk" }, + + -- Only the actual command can make use of the visual selection... + ["g"] = { + name = "Git", + p = { ":Gitsigns preview_hunk", "Preview selection" }, + r = { ":Gitsigns reset_hunk", "Restore selection" }, + s = { ":Gitsigns stage_hunk", "Stage selection" }, + u = { ":Gitsigns undo_stage_hunk", "Undo stage selection" }, + }, +} + +wk.register(keys, { buffer = bufnr }) +wk.register(objects, { buffer = bufnr, mode = "o" }) +wk.register(visual, { buffer = bufnr, mode = "x" }) diff --git a/modules/home/vim/plugin/settings/lspconfig.lua b/modules/home/vim/plugin/settings/lspconfig.lua index 9e9425c..2f355f4 100644 --- a/modules/home/vim/plugin/settings/lspconfig.lua +++ b/modules/home/vim/plugin/settings/lspconfig.lua @@ -84,11 +84,3 @@ if utils.is_executable("starpls") then on_attach = lsp.on_attach, }) end - --- Generic -if utils.is_executable("typos-lsp") then - lspconfig.typos_lsp.setup({ - capabilities = capabilities, - on_attach = lsp.on_attach, - }) -end diff --git a/modules/home/vim/plugin/settings/oil.lua b/modules/home/vim/plugin/settings/oil.lua deleted file mode 100644 index a160725..0000000 --- a/modules/home/vim/plugin/settings/oil.lua +++ /dev/null @@ -1,34 +0,0 @@ -local oil = require("oil") -local wk = require("which-key") - -local detail = false - -oil.setup({ - view_options = { - -- Show files and directories that start with "." by default - show_hidden = true, - -- But never '..' - is_always_hidden = function(name, bufnr) - return name == ".." - end, - }, - keymaps = { - ["gd"] = { - desc = "Toggle file detail view", - callback = function() - detail = not detail - if detail then - oil.set_columns({ "icon", "permissions", "size", "mtime" }) - else - oil.set_columns({ "icon" }) - end - end, - }, - }, -}) - -local keys = { - { "-", oil.open, desc = "Open parent directory" }, -} - -wk.add(keys) diff --git a/modules/home/vim/plugin/settings/telescope.lua b/modules/home/vim/plugin/settings/telescope.lua index 1a23928..4548ec5 100644 --- a/modules/home/vim/plugin/settings/telescope.lua +++ b/modules/home/vim/plugin/settings/telescope.lua @@ -1,6 +1,4 @@ local telescope = require("telescope") -local telescope_builtin = require("telescope.builtin") -local wk = require("which-key") telescope.setup({ defaults = { @@ -24,14 +22,3 @@ telescope.setup({ telescope.load_extension("fzf") telescope.load_extension("lsp_handlers") - -local keys = { - { "f", group = "Fuzzy finder" }, - { "fb", telescope_builtin.buffers, desc = "Open buffers" }, - { "ff", telescope_builtin.git_files, desc = "Git tracked files" }, - { "fF", telescope_builtin.find_files, desc = "Files" }, - { "fg", telescope_builtin.live_grep, desc = "Grep string" }, - { "fG", telescope_builtin.grep_string, desc = "Grep string under cursor" }, -} - -wk.add(keys) diff --git a/modules/home/vim/plugin/settings/tree-sitter.lua b/modules/home/vim/plugin/settings/tree-sitter.lua index d5fff46..5503857 100644 --- a/modules/home/vim/plugin/settings/tree-sitter.lua +++ b/modules/home/vim/plugin/settings/tree-sitter.lua @@ -1,5 +1,4 @@ local ts_config = require("nvim-treesitter.configs") - ts_config.setup({ highlight = { enable = true, @@ -15,16 +14,16 @@ ts_config.setup({ -- Jump to matching text objects lookahead = true, keymaps = { - ["aa"] = { query = "@parameter.outer", desc = "a parameter" }, - ["ia"] = { query = "@parameter.inner", desc = "inner parameter" }, - ["ab"] = { query = "@block.outer", desc = "a block" }, - ["ib"] = { query = "@block.inner", desc = "inner block" }, - ["ac"] = { query = "@class.outer", desc = "a class" }, - ["ic"] = { query = "@class.inner", desc = "inner class" }, - ["af"] = { query = "@function.outer", desc = "a function" }, - ["if"] = { query = "@function.inner", desc = "inner function" }, - ["ak"] = { query = "@comment.outer", desc = "a comment" }, - ["aS"] = { query = "@statement.outer", desc = "a statement" }, + ["aa"] = "@parameter.outer", + ["ia"] = "@parameter.inner", + ["ab"] = "@block.outer", + ["ib"] = "@block.inner", + ["ac"] = "@class.outer", + ["ic"] = "@class.inner", + ["af"] = "@function.outer", + ["if"] = "@function.inner", + ["ak"] = "@comment.outer", + ["aS"] = "@statement.outer", }, }, move = { @@ -32,22 +31,22 @@ ts_config.setup({ -- Add to jump list set_jumps = true, goto_next_start = { - ["]m"] = { query = "@function.outer", desc = "Next method start" }, - ["]S"] = { query = "@statement.outer", desc = "Next statement start" }, - ["]]"] = { query = "@class.outer", desc = "Next class start" }, + ["]m"] = "@function.outer", + ["]S"] = "@statement.outer", + ["]]"] = "@class.outer", }, goto_next_end = { - ["]M"] = { query = "@function.outer", desc = "Next method end" }, - ["]["] = { query = "@class.outer", desc = "Next class end" }, + ["]M"] = "@function.outer", + ["]["] = "@class.outer", }, goto_previous_start = { - ["[m"] = { query = "@function.outer", desc = "Previous method start" }, - ["[S"] = { query = "@statement.outer", desc = "Previous statement start" }, - ["[["] = { query = "@class.outer", desc = "Previous class start" }, + ["[m"] = "@function.outer", + ["[S"] = "@statement.outer", + ["[["] = "@class.outer", }, goto_previous_end = { - ["[M"] = { query = "@function.outer", desc = "Previous method end" }, - ["[]"] = { query = "@class.outer", desc = "Previous class end" }, + ["[M"] = "@function.outer", + ["[]"] = "@class.outer", }, }, }, diff --git a/modules/home/vim/plugin/settings/which-key.lua b/modules/home/vim/plugin/settings/which-key.lua index 3dc260a..2edfd70 100644 --- a/modules/home/vim/plugin/settings/which-key.lua +++ b/modules/home/vim/plugin/settings/which-key.lua @@ -1,33 +1,2 @@ local wk = require("which-key") -wk.setup({ - icons = { - -- I don't like icons - mappings = false, - breadcrumb = "»", - separator = "➜", - group = "+", - ellipsis = "…", - keys = { - Up = " ", - Down = " ", - Left = " ", - Right = " ", - C = "", - M = "", - D = "", - S = "", - CR = "", - Esc = " ", - NL = "", - BS = "", - Space = "", - Tab = " ", - }, - }, -}) - -local keys = { - { "", vim.cmd.nohlsearch, desc = "Clear search highlight" }, -} - -wk.add(keys) +wk.setup() diff --git a/modules/home/vim/plugin/signtoggle.lua b/modules/home/vim/plugin/signtoggle.lua index 9765a81..d6a26e2 100644 --- a/modules/home/vim/plugin/signtoggle.lua +++ b/modules/home/vim/plugin/signtoggle.lua @@ -4,23 +4,17 @@ local signtoggle = vim.api.nvim_create_augroup("signtoggle", { clear = true }) vim.api.nvim_create_autocmd({ "BufEnter", "FocusGained", "WinEnter" }, { pattern = "*", group = signtoggle, - callback = function() - vim.opt.signcolumn = "yes" - end, + command = "setlocal signcolumn=yes", }) vim.api.nvim_create_autocmd({ "BufLeave", "FocusLost", "WinLeave" }, { pattern = "*", group = signtoggle, - callback = function() - vim.opt.signcolumn = "no" - end, + command = "setlocal signcolumn=yes", }) -- Never show the sign column in a terminal buffer vim.api.nvim_create_autocmd({ "TermOpen" }, { pattern = "*", group = signtoggle, - callback = function() - vim.opt.signcolumn = "no" - end, + command = "setlocal signcolumn=no", }) diff --git a/modules/home/wget/default.nix b/modules/home/wget/default.nix index 1be5397..32c13c0 100644 --- a/modules/home/wget/default.nix +++ b/modules/home/wget/default.nix @@ -20,7 +20,7 @@ in }; xdg.configFile."wgetrc".text = '' - hsts-file = ${config.xdg.stateHome}/wget-hsts + hsts-file = ${config.xdg.dataHome}/wget-hsts ''; }; } diff --git a/modules/home/wm/default.nix b/modules/home/wm/default.nix index ae1e136..449918a 100644 --- a/modules/home/wm/default.nix +++ b/modules/home/wm/default.nix @@ -58,7 +58,7 @@ in service = "some-service-name"; } ]; - description = "list of block configurations, merged with the defaults"; + description = "list of block configurations, merged with the defauls"; }; }; }; diff --git a/modules/home/wm/i3/default.nix b/modules/home/wm/i3/default.nix index c432864..69246f0 100644 --- a/modules/home/wm/i3/default.nix +++ b/modules/home/wm/i3/default.nix @@ -371,7 +371,8 @@ in }; startup = [ - # NOTE: rely on systemd user services instead... + # FIXME + # { commdand; always; notification; } ]; window = { diff --git a/modules/home/wm/screen-lock/default.nix b/modules/home/wm/screen-lock/default.nix index 5e6874e..3b2ead6 100644 --- a/modules/home/wm/screen-lock/default.nix +++ b/modules/home/wm/screen-lock/default.nix @@ -2,7 +2,7 @@ let cfg = config.my.home.wm.screen-lock; - notificationCmd = + notficationCmd = let duration = toString (cfg.notify.delay * 1000); notifyCmd = "${lib.getExe pkgs.libnotify} -u critical -t ${duration}"; @@ -48,7 +48,7 @@ in "-notify" "${toString cfg.notify.delay}" "-notifier" - notificationCmd + notficationCmd ]; }; }; diff --git a/modules/home/xdg/default.nix b/modules/home/xdg/default.nix index 270200e..fb2668c 100644 --- a/modules/home/xdg/default.nix +++ b/modules/home/xdg/default.nix @@ -11,7 +11,7 @@ in enable = true; # File types mime.enable = true; - # File associations + # File associatons mimeApps = { enable = true; }; @@ -34,9 +34,6 @@ in "gdb/.keep".text = ""; "tig/.keep".text = ""; }; - stateFile = { - "python/.keep".text = ""; - }; }; # I want a tidier home @@ -46,13 +43,13 @@ in CARGO_HOME = "${dataHome}/cargo"; DOCKER_CONFIG = "${configHome}/docker"; GRADLE_USER_HOME = "${dataHome}/gradle"; - HISTFILE = "${stateHome}/bash/history"; + HISTFILE = "${dataHome}/bash/history"; INPUTRC = "${configHome}/readline/inputrc"; - PSQL_HISTORY = "${stateHome}/psql_history"; + PSQL_HISTORY = "${dataHome}/psql_history"; PYTHONPYCACHEPREFIX = "${cacheHome}/python/"; PYTHONUSERBASE = "${dataHome}/python/"; PYTHON_HISTORY = "${stateHome}/python/history"; - REDISCLI_HISTFILE = "${stateHome}/redis/rediscli_history"; + REDISCLI_HISTFILE = "${dataHome}/redis/rediscli_history"; REPO_CONFIG_DIR = "${configHome}/repo"; XCOMPOSECACHE = "${dataHome}/X11/xcompose"; _JAVA_OPTIONS = "-Djava.util.prefs.userRoot=${configHome}/java"; diff --git a/modules/home/zsh/default.nix b/modules/home/zsh/default.nix index 11b6cb2..a277366 100644 --- a/modules/home/zsh/default.nix +++ b/modules/home/zsh/default.nix @@ -68,7 +68,7 @@ in ignoreSpace = true; ignoreDups = true; share = false; - path = "${config.xdg.stateHome}/zsh/zsh_history"; + path = "${config.xdg.dataHome}/zsh/zsh_history"; }; plugins = [ diff --git a/modules/home/zsh/options.zsh b/modules/home/zsh/options.zsh index 7bcad03..32da8d8 100644 --- a/modules/home/zsh/options.zsh +++ b/modules/home/zsh/options.zsh @@ -12,7 +12,7 @@ setopt rc_quotes setopt auto_resume # Show history expansion before running a command setopt hist_verify -# Append commands to history as they are executed +# Append commands to history as they are exectuted setopt inc_append_history_time # Remove useless whitespace from commands setopt hist_reduce_blanks diff --git a/modules/nixos/hardware/trackball/default.nix b/modules/nixos/hardware/trackball/default.nix index a9b24e3..7a99247 100644 --- a/modules/nixos/hardware/trackball/default.nix +++ b/modules/nixos/hardware/trackball/default.nix @@ -11,7 +11,7 @@ in config = lib.mkIf cfg.enable { services.xserver = { # This section must be *after* the one configured by `libinput` - # for the `ScrollMethod` configuration to not be overridden + # for the `ScrollMethod` configuration to not be overriden inputClassSections = lib.mkAfter [ # MX Ergo '' diff --git a/modules/nixos/profiles/default.nix b/modules/nixos/profiles/default.nix index dbd4be3..43d5a84 100644 --- a/modules/nixos/profiles/default.nix +++ b/modules/nixos/profiles/default.nix @@ -1,4 +1,4 @@ -# Configuration that spans across system and home, or are almagations of modules +# Configuration that spans accross system and home, or are almagations of modules { ... }: { imports = [ diff --git a/modules/nixos/services/aria/default.nix b/modules/nixos/services/aria/default.nix index 15bb5e8..46fd8ee 100644 --- a/modules/nixos/services/aria/default.nix +++ b/modules/nixos/services/aria/default.nix @@ -71,8 +71,7 @@ in }; }; - # FIXME: persistence? - # NOTE: unfortunately aria2 does not log connection failures for fail2ban + # FIXME: persistence? }; } diff --git a/modules/nixos/services/audiobookshelf/default.nix b/modules/nixos/services/audiobookshelf/default.nix index cb7bc08..e4d03c2 100644 --- a/modules/nixos/services/audiobookshelf/default.nix +++ b/modules/nixos/services/audiobookshelf/default.nix @@ -37,21 +37,5 @@ in }; # FIXME: persistence? - - services.fail2ban.jails = { - audiobookshelf = '' - enabled = true - filter = audiobookshelf - port = http,https - ''; - }; - - environment.etc = { - "fail2ban/filter.d/audiobookshelf.conf".text = '' - [Definition] - failregex = ^.*ERROR: \[Auth\] Failed login attempt for username ".*" from ip - journalmatch = _SYSTEMD_UNIT=audiobookshelf.service - ''; - }; }; } diff --git a/modules/nixos/services/default.nix b/modules/nixos/services/default.nix index 651f3f8..60b2478 100644 --- a/modules/nixos/services/default.nix +++ b/modules/nixos/services/default.nix @@ -16,7 +16,6 @@ ./grocy ./indexers ./jellyfin - ./komga ./lohr ./matrix ./mealie @@ -27,7 +26,7 @@ ./nginx ./nix-cache ./paperless - ./pdf-edit + ./pirate ./podgrab ./postgresql ./postgresql-backup @@ -35,7 +34,6 @@ ./quassel ./rss-bridge ./sabnzbd - ./servarr ./ssh-server ./tandoor-recipes ./tlp diff --git a/modules/nixos/services/flood/default.nix b/modules/nixos/services/flood/default.nix index 23154ed..e1a2b74 100644 --- a/modules/nixos/services/flood/default.nix +++ b/modules/nixos/services/flood/default.nix @@ -29,7 +29,5 @@ in }; # FIXME: persistence? - - # NOTE: unfortunately flood does not log connection failures for fail2ban }; } diff --git a/modules/nixos/services/forgejo/default.nix b/modules/nixos/services/forgejo/default.nix index 3ba4ead..8c36615 100644 --- a/modules/nixos/services/forgejo/default.nix +++ b/modules/nixos/services/forgejo/default.nix @@ -1,4 +1,4 @@ -# A low-resource, full-featured git forge. +# A low-ressource, full-featured git forge. { config, lib, ... }: let cfg = config.my.services.forgejo; diff --git a/modules/nixos/services/gitea/default.nix b/modules/nixos/services/gitea/default.nix index 76de5dd..20b3871 100644 --- a/modules/nixos/services/gitea/default.nix +++ b/modules/nixos/services/gitea/default.nix @@ -1,4 +1,4 @@ -# A low-resource, full-featured git forge. +# A low-ressource, full-featured git forge. { config, lib, ... }: let cfg = config.my.services.gitea; diff --git a/modules/nixos/services/grocy/default.nix b/modules/nixos/services/grocy/default.nix index 67de377..4a3183e 100644 --- a/modules/nixos/services/grocy/default.nix +++ b/modules/nixos/services/grocy/default.nix @@ -39,7 +39,5 @@ in # FIXME: backup # FIXME: persistence - - # NOTE: unfortunately grocy does not log connection failures for fail2ban }; } diff --git a/modules/nixos/services/jellyfin/default.nix b/modules/nixos/services/jellyfin/default.nix index b54f9ef..e277b71 100644 --- a/modules/nixos/services/jellyfin/default.nix +++ b/modules/nixos/services/jellyfin/default.nix @@ -45,21 +45,5 @@ in my.system.persist.directories = [ "/var/lib/${config.systemd.services.jellyfin.serviceConfig.StateDirectory}" ]; - - services.fail2ban.jails = { - jellyfin = '' - enabled = true - filter = jellyfin - port = http,https - ''; - }; - - environment.etc = { - "fail2ban/filter.d/jellyfin.conf".text = '' - [Definition] - failregex = ^.*Authentication request for .* has been denied \(IP: "?"?\)\. - journalmatch = _SYSTEMD_UNIT=jellyfin.service - ''; - }; }; } diff --git a/modules/nixos/services/komga/default.nix b/modules/nixos/services/komga/default.nix deleted file mode 100644 index e1dc780..0000000 --- a/modules/nixos/services/komga/default.nix +++ /dev/null @@ -1,55 +0,0 @@ -# A Comics/Manga media server -{ config, lib, ... }: -let - cfg = config.my.services.komga; -in -{ - options.my.services.komga = with lib; { - enable = mkEnableOption "Komga comics server"; - - port = mkOption { - type = types.port; - default = 4584; - example = 8080; - description = "Internal port for webui"; - }; - }; - - config = lib.mkIf cfg.enable { - services.komga = { - enable = true; - inherit (cfg) port; - - group = "media"; - }; - - systemd.services.komga.environment = { - LOGGING_LEVEL_ORG_GOTSON_KOMGA = "DEBUG"; # Needed for fail2ban - }; - - # Set-up media group - users.groups.media = { }; - - my.services.nginx.virtualHosts = { - komga = { - inherit (cfg) port; - }; - }; - - services.fail2ban.jails = { - komga = '' - enabled = true - filter = komga - port = http,https - ''; - }; - - environment.etc = { - "fail2ban/filter.d/komga.conf".text = '' - [Definition] - failregex = ^.* ip=,.*Bad credentials.*$ - journalmatch = _SYSTEMD_UNIT=komga.service - ''; - }; - }; -} diff --git a/modules/nixos/services/matrix/default.nix b/modules/nixos/services/matrix/default.nix index cb41a0f..145139f 100644 --- a/modules/nixos/services/matrix/default.nix +++ b/modules/nixos/services/matrix/default.nix @@ -26,6 +26,21 @@ in description = "Shared secret to register users"; }; + slidingSync = { + port = mkOption { + type = types.port; + default = 8009; + example = 8084; + description = "Port used by sliding sync server"; + }; + + secretFile = mkOption { + type = types.str; + example = "/var/lib/matrix/sliding-sync-secret-file.env"; + description = "Secret file which contains SYNCV3_SECRET definition"; + }; + }; + mailConfigFile = mkOption { type = types.str; example = "/var/lib/matrix/email-config.yaml"; @@ -91,6 +106,17 @@ in ] ++ lib.optional (cfg.secretFile != null) cfg.secretFile; }; + services.matrix-sliding-sync = { + enable = true; + + settings = { + SYNCV3_SERVER = "https://${matrixDomain}"; + SYNCV3_BINDADDR = "127.0.0.1:${toString cfg.slidingSync.port}"; + }; + + environmentFile = cfg.slidingSync.secretFile; + }; + my.services.nginx.virtualHosts = { # Element Web app deployment chat = { @@ -104,6 +130,9 @@ in "m.identity_server" = { "base_url" = "https://vector.im"; }; + "org.matrix.msc3575.proxy" = { + "url" = "https://matrix-sync.${domain}"; + }; }; showLabsSettings = true; defaultCountryCode = "FR"; # cocorico @@ -123,6 +152,10 @@ in matrix-client = { port = clientPort.private; }; + # Sliding sync + matrix-sync = { + inherit (cfg.slidingSync) port; + }; }; # Those are too complicated to use my wrapper... @@ -145,6 +178,11 @@ in "/_matrix" = proxyToClientPort; "/_synapse/client" = proxyToClientPort; + + # Sliding sync + "~ ^/(client/|_matrix/client/unstable/org.matrix.msc3575/sync)" = { + proxyPass = "http://${config.services.matrix-sliding-sync.settings.SYNCV3_BINDADDR}"; + }; }; listen = [ @@ -190,6 +228,7 @@ in client = { "m.homeserver" = { "base_url" = "https://${matrixDomain}"; }; "m.identity_server" = { "base_url" = "https://vector.im"; }; + "org.matrix.msc3575.proxy" = { "url" = "https://matrix-sync.${domain}"; }; }; # ACAO required to allow element-web on any URL to request this json file in diff --git a/modules/nixos/services/mealie/default.nix b/modules/nixos/services/mealie/default.nix index 4eb6977..4fa4a6a 100644 --- a/modules/nixos/services/mealie/default.nix +++ b/modules/nixos/services/mealie/default.nix @@ -74,21 +74,5 @@ in # FIXME: backup # FIXME: persistence - - services.fail2ban.jails = { - mealie = '' - enabled = true - filter = mealie - port = http,https - ''; - }; - - environment.etc = { - "fail2ban/filter.d/mealie.conf".text = '' - [Definition] - failregex = ^.*ERROR.*Incorrect username or password from - journalmatch = _SYSTEMD_UNIT=mealie.service - ''; - }; }; } diff --git a/modules/nixos/services/miniflux/default.nix b/modules/nixos/services/miniflux/default.nix index 7bcfe30..448e0af 100644 --- a/modules/nixos/services/miniflux/default.nix +++ b/modules/nixos/services/miniflux/default.nix @@ -51,21 +51,5 @@ in # FIXME: backup # FIXME: persistence - - services.fail2ban.jails = { - miniflux = '' - enabled = true - filter = miniflux - port = http,https - ''; - }; - - environment.etc = { - "fail2ban/filter.d/miniflux.conf".text = '' - [Definition] - failregex = ^.*msg="[^"]*(Incorrect|Invalid) username or password[^"]*".*client_ip= - journalmatch = _SYSTEMD_UNIT=miniflux.service - ''; - }; }; } diff --git a/modules/nixos/services/navidrome/default.nix b/modules/nixos/services/navidrome/default.nix index 106e01d..8dd9748 100644 --- a/modules/nixos/services/navidrome/default.nix +++ b/modules/nixos/services/navidrome/default.nix @@ -56,21 +56,5 @@ in my.system.persist.directories = [ "/var/lib/${config.systemd.services.navidrome.serviceConfig.StateDirectory}" ]; - - services.fail2ban.jails = { - navidrome = '' - enabled = true - filter = navidrome - port = http,https - ''; - }; - - environment.etc = { - "fail2ban/filter.d/navidrome.conf".text = '' - [Definition] - failregex = ^.*msg="Unsuccessful login".*X-Real-Ip:\[\] - journalmatch = _SYSTEMD_UNIT=navidrome.service - ''; - }; }; } diff --git a/modules/nixos/services/nextcloud/default.nix b/modules/nixos/services/nextcloud/default.nix index b13a608..ea30a90 100644 --- a/modules/nixos/services/nextcloud/default.nix +++ b/modules/nixos/services/nextcloud/default.nix @@ -31,7 +31,7 @@ in config = lib.mkIf cfg.enable { services.nextcloud = { enable = true; - package = pkgs.nextcloud30; + package = pkgs.nextcloud29; hostName = "nextcloud.${config.networking.domain}"; home = "/var/lib/nextcloud"; maxUploadSize = cfg.maxSize; @@ -92,25 +92,5 @@ in config.services.nextcloud.home config.services.nextcloud.datadir ]; - - services.fail2ban.jails = { - nextcloud = '' - enabled = true - filter = nextcloud - port = http,https - ''; - }; - - environment.etc = { - "fail2ban/filter.d/nextcloud.conf".text = '' - [Definition] - _groupsre = (?:(?:,?\s*"\w+":(?:"[^"]+"|\w+))*) - datepattern = ,?\s*"time"\s*:\s*"%%Y-%%m-%%d[T ]%%H:%%M:%%S(%%z)?" - failregex = ^[^{]*\{%(_groupsre)s,?\s*"remoteAddr":""%(_groupsre)s,?\s*"message":"Login failed: - ^[^{]*\{%(_groupsre)s,?\s*"remoteAddr":""%(_groupsre)s,?\s*"message":"Trusted domain error. - ^[^{]*\{%(_groupsre)s,?\s*"remoteAddr":""%(_groupsre)s,?\s*"message":"Two-factor challenge failed: - journalmatch = _SYSTEMD_UNIT=phpfpm-nextcloud.service - ''; - }; }; } diff --git a/modules/nixos/services/nginx/default.nix b/modules/nixos/services/nginx/default.nix index 721ae76..4af2680 100644 --- a/modules/nixos/services/nginx/default.nix +++ b/modules/nixos/services/nginx/default.nix @@ -59,12 +59,14 @@ let extraConfig = mkOption { type = types.attrs; # FIXME: forward type of virtualHosts - example = { - locations."/socket" = { - proxyPass = "http://127.0.0.1:8096/"; - proxyWebsockets = true; - }; - }; + example = litteralExample '' + { + locations."/socket" = { + proxyPass = "http://127.0.0.1:8096/"; + proxyWebsockets = true; + }; + } + ''; default = { }; description = '' Any extra configuration that should be applied to this virtual host. @@ -98,24 +100,26 @@ in virtualHosts = mkOption { type = types.attrsOf virtualHostOption; default = { }; - example = { - gitea = { - subdomain = "git"; - port = 8080; - }; - dev = { - root = "/var/www/dev"; - }; - jellyfin = { - port = 8096; - extraConfig = { - locations."/socket" = { - proxyPass = "http://127.0.0.1:8096/"; - proxyWebsockets = true; + example = litteralExample '' + { + gitea = { + subdomain = "git"; + port = 8080; + }; + dev = { + root = "/var/www/dev"; + }; + jellyfin = { + port = 8096; + extraConfig = { + locations."/socket" = { + proxyPass = "http://127.0.0.1:8096/"; + proxyWebsockets = true; + }; }; }; - }; - }; + } + ''; description = '' List of virtual hosts to set-up using default settings. ''; @@ -159,21 +163,25 @@ in }; }; }); - example = { - alice = { - passwordHashFile = "/var/lib/nginx-sso/alice/password-hash.txt"; - totpSecretFile = "/var/lib/nginx-sso/alice/totp-secret.txt"; - }; - }; + example = litteralExample '' + { + alice = { + passwordHashFile = "/var/lib/nginx-sso/alice/password-hash.txt"; + totpSecretFile = "/var/lib/nginx-sso/alice/totp-secret.txt"; + }; + } + ''; description = "Definition of users"; }; groups = mkOption { type = with types; attrsOf (listOf str); - example = { - root = [ "alice" ]; - users = [ "alice" "bob" ]; - }; + example = litteralExample '' + { + root = [ "alice" ]; + users = [ "alice" "bob" ]; + } + ''; description = "Groups of users"; }; }; diff --git a/modules/nixos/services/nginx/sso/default.nix b/modules/nixos/services/nginx/sso/default.nix index d60e31b..4a78282 100644 --- a/modules/nixos/services/nginx/sso/default.nix +++ b/modules/nixos/services/nginx/sso/default.nix @@ -59,10 +59,15 @@ in StateDirectory = "nginx-sso"; WorkingDirectory = "/var/lib/nginx-sso"; # The files to be merged might not have the correct permissions - ExecStartPre = pkgs.writeShellScript "merge-nginx-sso-config" '' + ExecStartPre = ''+${pkgs.writeShellScript "merge-nginx-sso-config" '' rm -f '${confPath}' ${utils.genJqSecretsReplacementSnippet cfg.configuration confPath} - ''; + + # Fix permissions + chown nginx-sso:nginx-sso ${confPath} + chmod 0600 ${confPath} + '' + }''; ExecStart = lib.mkForce '' ${lib.getExe pkg} \ --config ${confPath} \ diff --git a/modules/nixos/services/nix-cache/default.nix b/modules/nixos/services/nix-cache/default.nix index f3a29aa..1ce3161 100644 --- a/modules/nixos/services/nix-cache/default.nix +++ b/modules/nixos/services/nix-cache/default.nix @@ -40,7 +40,7 @@ in inherit (cfg) priority; }; - signKeyPaths = [ cfg.secretKeyFile ]; + signKeyPath = cfg.secretKeyFile; }; my.services.nginx.virtualHosts = { diff --git a/modules/nixos/services/pdf-edit/default.nix b/modules/nixos/services/pdf-edit/default.nix deleted file mode 100644 index d59507b..0000000 --- a/modules/nixos/services/pdf-edit/default.nix +++ /dev/null @@ -1,73 +0,0 @@ -{ config, lib, ... }: -let - cfg = config.my.services.pdf-edit; -in -{ - options.my.services.pdf-edit = with lib; { - enable = mkEnableOption "PDF edition service"; - - port = mkOption { - type = types.port; - default = 8089; - example = 8080; - description = "Internal port for webui"; - }; - - loginFile = mkOption { - type = types.str; - example = "/run/secrets/pdf-edit/login.env"; - description = '' - `SECURITY_INITIALLOGIN_USERNAME` and `SECURITY_INITIALLOGIN_PASSWORD` - defined in the format of 'EnvironmentFile' (see `systemd.exec(5)`). - ''; - }; - }; - - config = lib.mkIf cfg.enable { - services.stirling-pdf = lib.mkIf cfg.enable { - enable = true; - - environment = { - SERVER_PORT = cfg.port; - SECURITY_CSRFDISABLED = "false"; - - SYSTEM_SHOWUPDATE = "false"; # We don't care about update notifications - INSTALL_BOOK_AND_ADVANCED_HTML_OPS = "true"; # Installed by the module - - SECURITY_ENABLELOGIN = "true"; - SECURITY_LOGINATTEMPTCOUNT = "-1"; # Rely on fail2ban instead - }; - - environmentFiles = [ cfg.loginFile ]; - }; - - my.services.nginx.virtualHosts = { - pdf-edit = { - inherit (cfg) port; - - extraConfig = { - # Allow upload of PDF files up to 1G - locations."/".extraConfig = '' - client_max_body_size 1G; - ''; - }; - }; - }; - - services.fail2ban.jails = { - stirling-pdf = '' - enabled = true - filter = stirling-pdf - port = http,https - ''; - }; - - environment.etc = { - "fail2ban/filter.d/stirling-pdf.conf".text = '' - [Definition] - failregex = ^.*Failed login attempt from IP: $ - journalmatch = _SYSTEMD_UNIT=stirling-pdf.service - ''; - }; - }; -} diff --git a/modules/nixos/services/servarr/default.nix b/modules/nixos/services/pirate/default.nix similarity index 89% rename from modules/nixos/services/servarr/default.nix rename to modules/nixos/services/pirate/default.nix index 9cb2a59..e0eae1e 100644 --- a/modules/nixos/services/servarr/default.nix +++ b/modules/nixos/services/pirate/default.nix @@ -4,13 +4,12 @@ # [1]: https://youtu.be/I26Ql-uX6AM { config, lib, ... }: let - cfg = config.my.services.servarr; + cfg = config.my.services.pirate; ports = { bazarr = 6767; lidarr = 8686; radarr = 7878; - readarr = 8787; sonarr = 8989; }; @@ -58,7 +57,7 @@ let ]); in { - options.my.services.servarr = { + options.my.services.pirate = { enable = lib.mkEnableOption "Media automation"; bazarr = { @@ -73,10 +72,6 @@ in enable = lib.my.mkDisableOption "Radarr"; }; - readarr = { - enable = lib.my.mkDisableOption "Readarr"; - }; - sonarr = { enable = lib.my.mkDisableOption "Sonarr"; }; @@ -95,9 +90,6 @@ in # Radarr for movies (mkFullConfig "radarr") (mkFail2Ban "radarr") - # Readarr for books - (mkFullConfig "readarr") - (mkFail2Ban "readarr") # Sonarr for shows (mkFullConfig "sonarr") (mkFail2Ban "sonarr") diff --git a/modules/nixos/services/podgrab/default.nix b/modules/nixos/services/podgrab/default.nix index ec6ecb2..fad9553 100644 --- a/modules/nixos/services/podgrab/default.nix +++ b/modules/nixos/services/podgrab/default.nix @@ -13,7 +13,7 @@ in example = "/run/secrets/password.env"; description = '' The path to a file containing the PASSWORD environment variable - definition for Podgrab's authentication. + definition for Podgrab's authentification. ''; }; diff --git a/modules/nixos/services/pyload/default.nix b/modules/nixos/services/pyload/default.nix index 4e8e083..1e5ce61 100644 --- a/modules/nixos/services/pyload/default.nix +++ b/modules/nixos/services/pyload/default.nix @@ -53,9 +53,8 @@ in }; }; + # FIXME: fail2ban # FIXME: backup # FIXME: persistence - - # FIXME: fail2ban }; } diff --git a/modules/nixos/services/tandoor-recipes/default.nix b/modules/nixos/services/tandoor-recipes/default.nix index 6282769..a404033 100644 --- a/modules/nixos/services/tandoor-recipes/default.nix +++ b/modules/nixos/services/tandoor-recipes/default.nix @@ -85,7 +85,5 @@ in # FIXME: backup # FIXME: persistence - - # NOTE: unfortunately tandoor-recipes does not log connection failures for fail2ban }; } diff --git a/modules/nixos/services/transmission/default.nix b/modules/nixos/services/transmission/default.nix index 674fa81..e921bfa 100644 --- a/modules/nixos/services/transmission/default.nix +++ b/modules/nixos/services/transmission/default.nix @@ -94,7 +94,5 @@ in my.system.persist.directories = [ config.services.transmission.home ]; - - # NOTE: unfortunately transmission does not log connection failures for fail2ban }; } diff --git a/modules/nixos/services/vikunja/default.nix b/modules/nixos/services/vikunja/default.nix index 575ddab..262c199 100644 --- a/modules/nixos/services/vikunja/default.nix +++ b/modules/nixos/services/vikunja/default.nix @@ -41,7 +41,7 @@ in service = { # Only allow registration of users through the CLI enableregistration = false; - # Use the host's timezone + # Ues the host's timezone timezone = config.time.timeZone; # Use UNIX socket for serving the API unixsocket = socketPath; @@ -101,7 +101,5 @@ in }; # FIXME: persistence - - # NOTE: unfortunately vikunja does not log connection failures for fail2ban }; } diff --git a/modules/nixos/services/wireguard/default.nix b/modules/nixos/services/wireguard/default.nix index 840ac33..a76e424 100644 --- a/modules/nixos/services/wireguard/default.nix +++ b/modules/nixos/services/wireguard/default.nix @@ -206,7 +206,7 @@ in ]; } - # Additional interface is only used to get access to "LAN" from wireguard + # Additional inteface is only used to get access to "LAN" from wireguard (lib.mkIf cfg.internal.enable { networking.wg-quick.interfaces."${cfg.internal.name}" = mkInterface [ "${cfg.net.v4.subnet}.0/${toString cfg.net.v4.mask}" diff --git a/modules/nixos/system/docker/default.nix b/modules/nixos/system/docker/default.nix index cab9fb5..f051814 100644 --- a/modules/nixos/system/docker/default.nix +++ b/modules/nixos/system/docker/default.nix @@ -23,9 +23,5 @@ in ]; }; }; - - my.system.persist.directories = [ - "/var/lib/docker" - ]; }; } diff --git a/modules/nixos/system/nix/default.nix b/modules/nixos/system/nix/default.nix index 12a395e..ad13539 100644 --- a/modules/nixos/system/nix/default.nix +++ b/modules/nixos/system/nix/default.nix @@ -22,10 +22,6 @@ in options.my.system.nix = with lib; { enable = my.mkDisableOption "nix configuration"; - gc = { - enable = my.mkDisableOption "nix GC configuration"; - }; - cache = { selfHosted = my.mkDisableOption "self-hosted cache"; }; @@ -66,22 +62,6 @@ in }; } - (lib.mkIf cfg.gc.enable { - nix.gc = { - automatic = true; - - # Every week, with some wiggle room - dates = "weekly"; - randomizedDelaySec = "10min"; - - # Use a persistent timer for e.g: laptops - persistent = true; - - # Delete old profiles automatically after 15 days - options = "--delete-older-than 15d"; - }; - }) - (lib.mkIf cfg.cache.selfHosted { nix = { settings = { diff --git a/modules/nixos/system/packages/default.nix b/modules/nixos/system/packages/default.nix index ebea06f..5c29aa0 100644 --- a/modules/nixos/system/packages/default.nix +++ b/modules/nixos/system/packages/default.nix @@ -14,14 +14,12 @@ in config = lib.mkIf cfg.enable { environment.systemPackages = with pkgs; [ + vim wget ]; programs = { - vim = { - enable = true; - defaultEditor = true; # Modal editing is life - }; + vim.defaultEditor = true; # Modal editing is life zsh = { enable = true; # Use integrations diff --git a/modules/nixos/system/persist/default.nix b/modules/nixos/system/persist/default.nix index fbf63fa..7346936 100644 --- a/modules/nixos/system/persist/default.nix +++ b/modules/nixos/system/persist/default.nix @@ -58,6 +58,10 @@ in "/var/lib/nixos" "/var/lib/systemd/coredump" ] + ++ (lib.optionals config.virtualisation.docker.enable [ + "/var/lib/docker" + ]) + # FIXME: podman ++ cfg.directories ; }; diff --git a/modules/nixos/system/podman/default.nix b/modules/nixos/system/podman/default.nix index 8400dfd..52630c7 100644 --- a/modules/nixos/system/podman/default.nix +++ b/modules/nixos/system/podman/default.nix @@ -44,9 +44,5 @@ in ]; }; }; - - my.system.persist.directories = [ - "/var/lib/containers" - ]; }; } diff --git a/overlays/downgrade-transmission/default.nix b/overlays/downgrade-transmission/default.nix deleted file mode 100644 index 9d3fc8a..0000000 --- a/overlays/downgrade-transmission/default.nix +++ /dev/null @@ -1,14 +0,0 @@ -self: prev: -{ - transmission_4 = prev.transmission_4.overrideAttrs (_: { - version = "4.0.5"; - - src = self.fetchFromGitHub { - owner = "transmission"; - repo = "transmission"; - rev = "4.0.5"; - hash = "sha256-gd1LGAhMuSyC/19wxkoE2mqVozjGPfupIPGojKY0Hn4="; - fetchSubmodules = true; - }; - }); -} diff --git a/pkgs/cgt-calc/default.nix b/pkgs/cgt-calc/default.nix deleted file mode 100644 index 9966944..0000000 --- a/pkgs/cgt-calc/default.nix +++ /dev/null @@ -1,47 +0,0 @@ -{ lib -, fetchFromGitHub -, python3Packages -, withTeXLive ? true -, texliveSmall -}: -python3Packages.buildPythonApplication rec { - pname = "cgt-calc"; - version = "1.13.0"; - pyproject = true; - - src = fetchFromGitHub { - owner = "KapJI"; - repo = "capital-gains-calculator"; - rev = "v${version}"; - hash = "sha256-y/Y05wG89nccXyxfjqazyPJhd8dOkfwRJre+Rzx97Hw="; - }; - - build-system = with python3Packages; [ - poetry-core - ]; - - dependencies = with python3Packages; [ - defusedxml - jinja2 - pandas - requests - types-requests - yfinance - ]; - - makeWrapperArgs = lib.optionals withTeXLive [ - "--prefix" - "PATH" - ":" - "${lib.getBin texliveSmall}/bin" - ]; - - meta = with lib; { - description = "UK capital gains tax calculator"; - homepage = "https://github.com/KapJI/capital-gains-calculator"; - license = with licenses; [ mit ]; - mainProgram = "cgt-calc"; - maintainers = with maintainers; [ ambroisie ]; - platforms = platforms.unix; - }; -} diff --git a/pkgs/default.nix b/pkgs/default.nix index 949bcf7..6b7fce1 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -2,8 +2,6 @@ pkgs.lib.makeScope pkgs.newScope (pkgs: { bw-pass = pkgs.callPackage ./bw-pass { }; - cgt-calc = pkgs.callPackage ./cgt-calc { }; - change-audio = pkgs.callPackage ./change-audio { }; change-backlight = pkgs.callPackage ./change-backlight { }; diff --git a/pkgs/lohr/default.nix b/pkgs/lohr/default.nix index b89ccff..ddeac7a 100644 --- a/pkgs/lohr/default.nix +++ b/pkgs/lohr/default.nix @@ -1,16 +1,16 @@ { lib, fetchFromGitHub, rustPlatform }: rustPlatform.buildRustPackage rec { pname = "lohr"; - version = "0.4.6"; + version = "0.4.5"; src = fetchFromGitHub { owner = "alarsyo"; repo = "lohr"; rev = "v${version}"; - hash = "sha256-dunQgtap+XCK5LoSyOqIY/6p6HizBeiyPWNuCffwjDU="; + hash = "sha256-p6E/r+OxFTpxDpOKSlacOxvRLfHSKg1mHNAfTytfqDY="; }; - cargoHash = "sha256-EUhyrhPe+mUgMmm4o+bxRIiSNReJRfw+/O1fPr8r7lo="; + cargoHash = "sha256-hext0S0o9D9pN9epzXtD5dwAYMPCLpBBOBT4FX0mTMk="; meta = with lib; { description = "Git mirroring daemon"; diff --git a/pkgs/unbound-zones-adblock/default.nix b/pkgs/unbound-zones-adblock/default.nix index 11a6c90..642ac41 100644 --- a/pkgs/unbound-zones-adblock/default.nix +++ b/pkgs/unbound-zones-adblock/default.nix @@ -1,7 +1,7 @@ { lib, gawk, stdenvNoCC, stevenblack-blocklist }: stdenvNoCC.mkDerivation { name = "unbound-zones-adblock"; - inherit (stevenblack-blocklist) version; + version = stevenblack-blocklist.rev; src = stevenblack-blocklist; @@ -30,7 +30,7 @@ stdenvNoCC.mkDerivation { description = "Unified host lists, ready to be used by unbound"; longDescription = '' This is a simple derivation based on StevenBlack's unified hosts list. - The files have been modified for easy use with unbound. + The files have been modified for easy use wih unbound. ''; homepage = "https://github.com/StevenBlack/hosts"; license = licenses.mit;