diff --git a/flake.lock b/flake.lock index 1f7bb189..d5104222 100644 --- a/flake.lock +++ b/flake.lock @@ -14,11 +14,11 @@ ] }, "locked": { - "lastModified": 1770165109, - "narHash": "sha256-9VnK6Oqai65puVJ4WYtCTvlJeXxMzAp/69HhQuTdl/I=", + "lastModified": 1754433428, + "narHash": "sha256-NA/FT2hVhKDftbHSwVnoRTFhes62+7dxZbxj5Gxvghs=", "owner": "ryantm", "repo": "agenix", - "rev": "b027ee29d959fda4b60b57566d64c98a202e0feb", + "rev": "9edb1787864c4f59ae5074ad498b6272b3ec308d", "type": "github" }, "original": { @@ -53,15 +53,15 @@ "flake-compat": { "flake": false, "locked": { - "lastModified": 1767039857, - "narHash": "sha256-vNpUSpF5Nuw8xvDLj2KCwwksIbjua2LZCqhV1LNRDns=", - "owner": "NixOS", + "lastModified": 1747046372, + "narHash": "sha256-CIVLLkVgvHYbgI2UpXvIIBJ12HWgX+fjA8Xf8PUmqCY=", + "owner": "edolstra", "repo": "flake-compat", - "rev": "5edf11c44bc78a0d334f6334cdaf7d60d732daab", + "rev": "9100a0f413b0c601e0533d1d94ffd501ce2e7885", "type": "github" }, "original": { - "owner": "NixOS", + "owner": "edolstra", "repo": "flake-compat", "type": "github" } @@ -73,11 +73,11 @@ ] }, "locked": { - "lastModified": 1769996383, - "narHash": "sha256-AnYjnFWgS49RlqX7LrC4uA+sCCDBj0Ry/WOJ5XWAsa0=", + "lastModified": 1756770412, + "narHash": "sha256-+uWLQZccFHwqpGqr2Yt5VsW/PbeJVTn9Dk6SHWhNRPw=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "57928607ea566b5db3ad13af0e57e921e6b12381", + "rev": "4524271976b625a4a605beefd893f270620fd751", "type": "github" }, "original": { @@ -117,11 +117,11 @@ ] }, "locked": { - "lastModified": 1770726378, - "narHash": "sha256-kck+vIbGOaM/dHea7aTBxdFYpeUl/jHOy5W3eyRvVx8=", + "lastModified": 1757588530, + "narHash": "sha256-tJ7A8mID3ct69n9WCvZ3PzIIl3rXTdptn/lZmqSS95U=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "5eaaedde414f6eb1aea8b8525c466dc37bba95ae", + "rev": "b084b2c2b6bc23e83bbfe583b03664eb0b18c411", "type": "github" }, "original": { @@ -159,11 +159,11 @@ ] }, "locked": { - "lastModified": 1771505064, - "narHash": "sha256-lh9rF+C/nKFyWAqbHIa6tK9L/6N0UaQg7zw15aP4jBM=", + "lastModified": 1757578556, + "narHash": "sha256-w1PGkTGow5XzsjccV364No46rkuGxTqo7m/4cfhnkIk=", "owner": "nix-community", "repo": "home-manager", - "rev": "a0a01d8811fd5e99e003078ed64a0e7b531545dd", + "rev": "b7112b12ea5b8c3aa6af344498ed9ca27dd03ba3", "type": "github" }, "original": { @@ -175,11 +175,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1771369470, - "narHash": "sha256-0NBlEBKkN3lufyvFegY4TYv5mCNHbi5OmBDrzihbBMQ=", + "lastModified": 1757487488, + "narHash": "sha256-zwE/e7CuPJUWKdvvTCB7iunV4E/+G0lKfv4kk/5Izdg=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "0182a361324364ae3f436a63005877674cf45efb", + "rev": "ab0f3607a6c7486ea22229b92ed2d355f1482ee0", "type": "github" }, "original": { @@ -196,19 +196,20 @@ ], "nixpkgs": [ "nixpkgs" - ] + ], + "treefmt-nix": "treefmt-nix" }, "locked": { - "lastModified": 1771506707, - "narHash": "sha256-R9oBi0EPsWN4bHfYgcyiSzx31/Fkgg3IHubf30II7Ow=", + "lastModified": 1753980880, + "narHash": "sha256-aj1pbYxL6N+XFqBHjB4B1QP0bnKRcg1AfpgT5zUFsW8=", "owner": "nix-community", "repo": "NUR", - "rev": "30ad144e51a0ae8b47aa84c1139e84fc278d6e86", + "rev": "16db3e61da7606984a05b4dfc33cd1d26d22fb22", "type": "github" }, "original": { "owner": "nix-community", - "ref": "main", + "ref": "master", "repo": "NUR", "type": "github" } @@ -240,6 +241,27 @@ "repo": "default", "type": "github" } + }, + "treefmt-nix": { + "inputs": { + "nixpkgs": [ + "nur", + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1733222881, + "narHash": "sha256-JIPcz1PrpXUCbaccEnrcUS8jjEb/1vJbZz5KkobyFdM=", + "owner": "numtide", + "repo": "treefmt-nix", + "rev": "49717b5af6f80172275d47a418c9719a31a78b53", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "treefmt-nix", + "type": "github" + } } }, "root": "root", diff --git a/flake.nix b/flake.nix index 0bdd180e..50767290 100644 --- a/flake.nix +++ b/flake.nix @@ -54,7 +54,7 @@ type = "github"; owner = "nix-community"; repo = "NUR"; - ref = "main"; + ref = "master"; inputs = { flake-parts.follows = "flake-parts"; nixpkgs.follows = "nixpkgs"; diff --git a/flake/overlays.nix b/flake/overlays.nix index c10afc33..0c47989d 100644 --- a/flake/overlays.nix +++ b/flake/overlays.nix @@ -1,4 +1,4 @@ -{ self, lib, ... }: +{ self, ... }: let default-overlays = import "${self}/overlays"; @@ -8,7 +8,7 @@ let # Expose my custom packages pkgs = _final: prev: { - ambroisie = lib.recurseIntoAttrs (import "${self}/pkgs" { pkgs = prev; }); + ambroisie = prev.recurseIntoAttrs (import "${self}/pkgs" { pkgs = prev; }); }; }; in diff --git a/hosts/homes/ambroisie@bazin/default.nix b/hosts/homes/ambroisie@bazin/default.nix index 365b70df..dddfa151 100644 --- a/hosts/homes/ambroisie@bazin/default.nix +++ b/hosts/homes/ambroisie@bazin/default.nix @@ -38,6 +38,14 @@ }; }; + xdg = { + mime-apps = { + applications = { + browser = "garcon_host_browser.desktop"; + }; + }; + }; + zsh = { notify = { enable = true; diff --git a/hosts/nixos/porthos/secrets/secrets.nix b/hosts/nixos/porthos/secrets/secrets.nix index f1842b4c..b3812b43 100644 --- a/hosts/nixos/porthos/secrets/secrets.nix +++ b/hosts/nixos/porthos/secrets/secrets.nix @@ -83,9 +83,18 @@ in "servarr/autobrr/session-secret.age".publicKeys = all; "servarr/cross-seed/configuration.json.age".publicKeys = all; - "sso/auth-key.age".publicKeys = all; - "sso/ambroisie/password-hash.age".publicKeys = all; - "sso/ambroisie/totp-secret.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; + }; "tandoor-recipes/secret-key.age".publicKeys = all; diff --git a/hosts/nixos/porthos/secrets/servarr/cross-seed/configuration.json.age b/hosts/nixos/porthos/secrets/servarr/cross-seed/configuration.json.age index b8cbe6aa..94fdf975 100644 Binary files a/hosts/nixos/porthos/secrets/servarr/cross-seed/configuration.json.age and b/hosts/nixos/porthos/secrets/servarr/cross-seed/configuration.json.age differ diff --git a/modules/home/delta/default.nix b/modules/home/delta/default.nix index e76edc60..16d3d597 100644 --- a/modules/home/delta/default.nix +++ b/modules/home/delta/default.nix @@ -1,6 +1,9 @@ { config, pkgs, lib, ... }: let cfg = config.my.home.delta; + + configFormat = pkgs.formats.gitIni { }; + configPath = "${config.xdg.configHome}/delta/config"; in { options.my.home.delta = with lib; { @@ -14,14 +17,28 @@ in }; config = lib.mkIf cfg.enable { - programs.delta = { - enable = true; + assertions = [ + { + # For its configuration + assertion = cfg.enable -> cfg.git.enable; + message = '' + `config.my.home.delta` must enable `config.my.home.delta.git` to be + properly configured. + ''; + } + { + assertion = cfg.enable -> config.programs.git.enable; + message = '' + `config.my.home.delta` relies on `config.programs.git` to be + enabled. + ''; + } + ]; - inherit (cfg) package; + home.packages = [ cfg.package ]; - enableGitIntegration = cfg.git.enable; - - options = { + xdg.configFile."delta/config".source = configFormat.generate "delta-config" { + delta = { features = "diff-highlight decorations"; # Less jarring style for `diff-highlight` emulation @@ -45,5 +62,18 @@ in }; }; }; + + programs.git = lib.mkIf cfg.git.enable { + delta = { + enable = true; + inherit (cfg) package; + }; + + includes = [ + { + path = configPath; + } + ]; + }; }; } diff --git a/modules/home/discord/default.nix b/modules/home/discord/default.nix index f9892df3..bfa5d40e 100644 --- a/modules/home/discord/default.nix +++ b/modules/home/discord/default.nix @@ -1,6 +1,8 @@ { config, lib, pkgs, ... }: let cfg = config.my.home.discord; + + jsonFormat = pkgs.formats.json { }; in { options.my.home.discord = with lib; { @@ -10,15 +12,14 @@ in }; config = lib.mkIf cfg.enable { - programs.discord = { - enable = true; + home.packages = with pkgs; [ + cfg.package + ]; - inherit (cfg) package; - - settings = { + xdg.configFile."discord/settings.json".source = + jsonFormat.generate "discord.json" { # Do not keep me from using the app just to force an update SKIP_HOST_UPDATE = true; }; - }; }; } diff --git a/modules/home/feh/default.nix b/modules/home/feh/default.nix index 3a952a22..d72eed2c 100644 --- a/modules/home/feh/default.nix +++ b/modules/home/feh/default.nix @@ -10,4 +10,11 @@ in config.programs.feh = lib.mkIf cfg.enable { enable = true; }; + + config.my.home.xdg.mime-apps = lib.mkIf cfg.enable { + applications.media.image = { + bitmap = [ "feh.desktop" ]; + vector = [ "feh.desktop" ]; + }; + }; } diff --git a/modules/home/firefox/default.nix b/modules/home/firefox/default.nix index 19a008cc..2c04c8e8 100644 --- a/modules/home/firefox/default.nix +++ b/modules/home/firefox/default.nix @@ -52,7 +52,6 @@ in "browser.newtabpage.activity-stream.feeds.sections" = false; "browser.newtabpage.activity-stream.feeds.system.topstories" = false; # Disable top stories "browser.newtabpage.activity-stream.section.highlights.includePocket" = false; # Disable pocket - "browser.urlbar.trimURLs" = false; # Always show the `http://` prefix "extensions.pocket.enabled" = false; # Disable pocket "media.eme.enabled" = true; # Enable DRM "media.gmp-widevinecdm.enabled" = true; # Enable DRM @@ -80,4 +79,8 @@ in }; }; }; + + config.my.home.xdg.mime-apps = lib.mkIf cfg.enable { + applications.editor = [ "firefox.desktop" ]; + }; } diff --git a/modules/home/git/default.nix b/modules/home/git/default.nix index c3a51a0f..ca59a5fb 100644 --- a/modules/home/git/default.nix +++ b/modules/home/git/default.nix @@ -21,31 +21,29 @@ in config.programs.git = lib.mkIf cfg.enable { enable = true; + # Who am I? + userEmail = mkMailAddress "bruno" "belanyi.fr"; + userName = "Bruno BELANYI"; + inherit (cfg) package; + aliases = { + git = "!git"; + lol = "log --graph --decorate --pretty=oneline --abbrev-commit --topo-order"; + lola = "lol --all"; + assume = "update-index --assume-unchanged"; + unassume = "update-index --no-assume-unchanged"; + assumed = "!git ls-files -v | grep ^h | cut -c 3-"; + pick = "log -p -G"; + push-new = "!git push -u origin " + + ''"$(git branch | grep '^* ' | cut -f2- -d' ')"''; + root = "git rev-parse --show-toplevel"; + }; + lfs.enable = true; # There's more - settings = { - # Who am I? - user = { - email = mkMailAddress "bruno" "belanyi.fr"; - name = "Bruno BELANYI"; - }; - - alias = { - git = "!git"; - lol = "log --graph --decorate --pretty=oneline --abbrev-commit --topo-order"; - lola = "lol --all"; - assume = "update-index --assume-unchanged"; - unassume = "update-index --no-assume-unchanged"; - assumed = "!git ls-files -v | grep ^h | cut -c 3-"; - pick = "log -p -G"; - push-new = "!git push -u origin " - + ''"$(git branch | grep '^* ' | cut -f2- -d' ')"''; - root = "git rev-parse --show-toplevel"; - }; - + extraConfig = { # Makes it a bit more readable blame = { coloring = "repeatedLines"; diff --git a/modules/home/mail/himalaya/default.nix b/modules/home/mail/himalaya/default.nix index 849a415a..84eccf59 100644 --- a/modules/home/mail/himalaya/default.nix +++ b/modules/home/mail/himalaya/default.nix @@ -20,4 +20,8 @@ in ''; }; }; + + config.my.home.xdg.mime-apps = lib.mkIf cfg.enable { + applications.editor = [ "himalaya.desktop" ]; + }; } diff --git a/modules/home/mpv/default.nix b/modules/home/mpv/default.nix index 8af394cf..1ccd0baf 100644 --- a/modules/home/mpv/default.nix +++ b/modules/home/mpv/default.nix @@ -17,5 +17,12 @@ in pkgs.mpvScripts.uosc # Nicer UI ]; }; + + my.home.xdg.mime-apps = { + applications.media = { + audio = [ "mpv.desktop" ]; + video = [ "mpv.desktop" ]; + }; + }; }; } diff --git a/modules/home/terminal/alacritty/default.nix b/modules/home/terminal/alacritty/default.nix index daf3e806..35a08c66 100644 --- a/modules/home/terminal/alacritty/default.nix +++ b/modules/home/terminal/alacritty/default.nix @@ -48,5 +48,9 @@ in }; }; }; + + my.home.xdg.mime-apps = { + applications.terminal = [ "Alacritty.desktop" ]; + }; }; } diff --git a/modules/home/terminal/termite/default.nix b/modules/home/terminal/termite/default.nix index e8f67a7d..b4ecdad5 100644 --- a/modules/home/terminal/termite/default.nix +++ b/modules/home/terminal/termite/default.nix @@ -49,5 +49,9 @@ in color15 = ${whiteBold} ''; }; + + my.home.xdg.mime-apps = { + applications.terminal = [ "termite.desktop" ]; + }; }; } diff --git a/modules/home/trgui/default.nix b/modules/home/trgui/default.nix index ee545a98..a890965c 100644 --- a/modules/home/trgui/default.nix +++ b/modules/home/trgui/default.nix @@ -13,5 +13,9 @@ in home.packages = with pkgs; [ cfg.package ]; + + my.home.xdg.mime-apps = { + applications.torrent = "TrguiNG.desktop"; + }; }; } diff --git a/modules/home/vim/default.nix b/modules/home/vim/default.nix index 930a853a..b12ba8d4 100644 --- a/modules/home/vim/default.nix +++ b/modules/home/vim/default.nix @@ -104,4 +104,8 @@ in }; config.xdg.configFile = lib.mkIf cfg.enable configFiles; + + config.my.home.xdg.mime-apps = lib.mkIf cfg.enable { + applications.editor = [ "nvim.desktop" ]; + }; } diff --git a/modules/home/vim/ftdetect/glsl.lua b/modules/home/vim/ftdetect/glsl.lua new file mode 100644 index 00000000..2f4f1ddd --- /dev/null +++ b/modules/home/vim/ftdetect/glsl.lua @@ -0,0 +1,7 @@ +-- Use GLSL filetype for common shader file extensions +vim.filetype.add({ + extension = { + frag = "glsl", + vert = "glsl", + }, +}) diff --git a/modules/home/vim/init.vim b/modules/home/vim/init.vim index 11429250..39ef32e3 100644 --- a/modules/home/vim/init.vim +++ b/modules/home/vim/init.vim @@ -81,6 +81,9 @@ set updatetime=250 " Disable all mouse integrations set mouse= +" Set dark mode by default +set background=dark + " Setup some overrides for gruvbox lua << EOF local gruvbox = require("gruvbox") diff --git a/modules/home/vim/lua/ambroisie/lsp.lua b/modules/home/vim/lua/ambroisie/lsp.lua index 05ca47a9..fef04873 100644 --- a/modules/home/vim/lua/ambroisie/lsp.lua +++ b/modules/home/vim/lua/ambroisie/lsp.lua @@ -85,18 +85,4 @@ M.on_attach = function(client, bufnr) wk.add(keys) end ---- list all active LSP clients for specific buffer, or all buffers ---- @param bufnr int? buffer number ---- @return table all active LSP client names -M.list_clients = function(bufnr) - local clients = vim.lsp.get_clients({ bufnr = bufnr }) - local names = {} - - for _, client in ipairs(clients) do - table.insert(names, client.name) - end - - return names -end - return M diff --git a/modules/home/vim/lua/ambroisie/utils.lua b/modules/home/vim/lua/ambroisie/utils.lua index 5cb8df10..0ee7c83b 100644 --- a/modules/home/vim/lua/ambroisie/utils.lua +++ b/modules/home/vim/lua/ambroisie/utils.lua @@ -7,6 +7,15 @@ M.is_executable = function(cmd) return cmd and vim.fn.executable(cmd) == 1 end +--- return a function that checks if a given command is executable +--- @param cmd string? command to check +--- @return fun(): boolean executable +M.is_executable_condition = function(cmd) + return function() + return M.is_executable(cmd) + end +end + --- whether or not we are currently in an SSH connection --- @return boolean ssh connection M.is_ssh = function() @@ -25,6 +34,20 @@ M.is_ssh = function() return false end +--- list all active LSP clients for specific buffer, or all buffers +--- @param bufnr int? buffer number +--- @return table all active LSP client names +M.list_lsp_clients = function(bufnr) + local clients = vim.lsp.get_clients({ bufnr = bufnr }) + local names = {} + + for _, client in ipairs(clients) do + table.insert(names, client.name) + end + + return names +end + --- partially apply a function with given arguments M.partial = function(f, ...) local a = { ... } diff --git a/modules/home/vim/plugin/settings/git.lua b/modules/home/vim/plugin/settings/git.lua index 2c4504dd..b9b92a69 100644 --- a/modules/home/vim/plugin/settings/git.lua +++ b/modules/home/vim/plugin/settings/git.lua @@ -33,6 +33,10 @@ gitsigns.setup({ }) local keys = { + -- Navigation + { "[c", utils.partial(nav_hunk, "prev"), desc = "Previous hunk/diff" }, + { "]c", utils.partial(nav_hunk, "next"), desc = "Next hunk/diff" }, + -- Commands { "g", group = "Git" }, { "gb", gitsigns.toggle_current_line_blame, desc = "Toggle blame virtual text" }, { "gd", gitsigns.diffthis, desc = "Diff buffer" }, @@ -51,20 +55,14 @@ local keys = { { "g]", utils.partial(gitsigns.nav_hunk, "next"), desc = "Next hunk" }, } -local moves = { - mode = { "n", "x", "o" }, - { "[c", utils.partial(nav_hunk, "prev"), desc = "Previous hunk/diff" }, - { "]c", utils.partial(nav_hunk, "next"), desc = "Next hunk/diff" }, -} - local objects = { mode = "o", - { "ih", gitsigns.select_hunk, desc = "git hunk" }, + { "ih", gitsigns.select_hunk, desc = "Git hunk" }, } -- Visual local visual = { mode = { "x" }, - { "ih", gitsigns.select_hunk, desc = "git hunk" }, + { "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" }, @@ -73,6 +71,5 @@ local visual = { } wk.add(keys) -wk.add(moves) wk.add(objects) wk.add(visual) diff --git a/modules/home/vim/plugin/settings/lspconfig.lua b/modules/home/vim/plugin/settings/lspconfig.lua index 1596e84a..7817d4c1 100644 --- a/modules/home/vim/plugin/settings/lspconfig.lua +++ b/modules/home/vim/plugin/settings/lspconfig.lua @@ -1,3 +1,4 @@ +local lspconfig = require("lspconfig") local lsp = require("ambroisie.lsp") local utils = require("ambroisie.utils") @@ -24,27 +25,59 @@ vim.diagnostic.config({ -- Inform servers we are able to do completion, snippets, etc... local capabilities = require("cmp_nvim_lsp").default_capabilities() --- Shared configuration -vim.lsp.config("*", { - capabilities = capabilities, - on_attach = lsp.on_attach, -}) +-- C/C++ +if utils.is_executable("clangd") then + lspconfig.clangd.setup({ + capabilities = capabilities, + on_attach = lsp.on_attach, + }) +end -local servers = { - -- C/C++ - clangd = {}, - -- Haskell - hls = {}, - -- Nix - nil_ls = {}, - -- Python - pyright = {}, - ruff = {}, - -- Rust - rust_analyzer = {}, - -- Shell - bashls = { +-- Haskell +if utils.is_executable("haskell-language-server-wrapper") then + lspconfig.hls.setup({ + capabilities = capabilities, + on_attach = lsp.on_attach, + }) +end + +-- Nix +if utils.is_executable("nil") then + lspconfig.nil_ls.setup({ + capabilities = capabilities, + on_attach = lsp.on_attach, + }) +end + +-- Python +if utils.is_executable("pyright") then + lspconfig.pyright.setup({ + capabilities = capabilities, + on_attach = lsp.on_attach, + }) +end + +if utils.is_executable("ruff") then + lspconfig.ruff.setup({ + capabilities = capabilities, + on_attach = lsp.on_attach, + }) +end + +-- Rust +if utils.is_executable("rust-analyzer") then + lspconfig.rust_analyzer.setup({ + capabilities = capabilities, + on_attach = lsp.on_attach, + }) +end + +-- Shell +if utils.is_executable("bash-language-server") then + lspconfig.bashls.setup({ filetypes = { "bash", "sh", "zsh" }, + capabilities = capabilities, + on_attach = lsp.on_attach, settings = { bashIde = { shfmt = { @@ -55,17 +88,28 @@ local servers = { }, }, }, - }, - -- Starlark - starpls = {}, - -- Generic - harper_ls = {}, - typos_lsp = {}, -} - -for server, config in pairs(servers) do - if not vim.tbl_isempty(config) then - vim.lsp.config(server, config) - end - vim.lsp.enable(server) + }) +end + +-- Starlark +if utils.is_executable("starpls") then + lspconfig.starpls.setup({ + capabilities = capabilities, + on_attach = lsp.on_attach, + }) +end + +-- Generic +if utils.is_executable("harper-ls") then + lspconfig.harper_ls.setup({ + capabilities = capabilities, + on_attach = lsp.on_attach, + }) +end + +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/lualine.lua b/modules/home/vim/plugin/settings/lualine.lua index 2dbc916e..bbe46475 100644 --- a/modules/home/vim/plugin/settings/lualine.lua +++ b/modules/home/vim/plugin/settings/lualine.lua @@ -1,6 +1,6 @@ local lualine = require("lualine") local oil = require("oil") -local lsp = require("ambroisie.lsp") +local utils = require("ambroisie.utils") local function list_spell_languages() if not vim.opt.spell:get() then @@ -11,7 +11,7 @@ local function list_spell_languages() end local function list_lsp_clients() - local client_names = lsp.list_clients(0) + local client_names = utils.list_lsp_clients(0) if #client_names == 0 then return "" diff --git a/modules/home/vim/plugin/settings/null-ls.lua b/modules/home/vim/plugin/settings/null-ls.lua index 00295bcc..258a2094 100644 --- a/modules/home/vim/plugin/settings/null-ls.lua +++ b/modules/home/vim/plugin/settings/null-ls.lua @@ -10,11 +10,11 @@ null_ls.setup({ null_ls.register({ null_ls.builtins.diagnostics.buildifier.with({ -- Only used if available - condition = utils.partial(utils.is_executable, "buildifier"), + condition = utils.is_executable_condition("buildifier"), }), null_ls.builtins.formatting.buildifier.with({ -- Only used if available - condition = utils.partial(utils.is_executable, "buildifier"), + condition = utils.is_executable_condition("buildifier"), }), }) @@ -22,7 +22,7 @@ null_ls.register({ null_ls.register({ null_ls.builtins.formatting.nixpkgs_fmt.with({ -- Only used if available - condition = utils.partial(utils.is_executable, "nixpkgs-fmt"), + condition = utils.is_executable_condition("nixpkgs-fmt"), }), }) @@ -30,19 +30,19 @@ null_ls.register({ null_ls.register({ null_ls.builtins.diagnostics.mypy.with({ -- Only used if available - condition = utils.partial(utils.is_executable, "mypy"), + condition = utils.is_executable_condition("mypy"), }), null_ls.builtins.diagnostics.pylint.with({ -- Only used if available - condition = utils.partial(utils.is_executable, "pylint"), + condition = utils.is_executable_condition("pylint"), }), null_ls.builtins.formatting.black.with({ extra_args = { "--fast" }, -- Only used if available - condition = utils.partial(utils.is_executable, "black"), + condition = utils.is_executable_condition("black"), }), null_ls.builtins.formatting.isort.with({ -- Only used if available - condition = utils.partial(utils.is_executable, "isort"), + condition = utils.is_executable_condition("isort"), }), }) diff --git a/modules/home/vim/plugin/settings/tree-sitter.lua b/modules/home/vim/plugin/settings/tree-sitter.lua index 2958c2a9..d5fff465 100644 --- a/modules/home/vim/plugin/settings/tree-sitter.lua +++ b/modules/home/vim/plugin/settings/tree-sitter.lua @@ -1,95 +1,54 @@ -local treesitter = require("nvim-treesitter") -local ts_select = require("nvim-treesitter-textobjects.select") -local ts_move = require("nvim-treesitter-textobjects.move") -local utils = require("ambroisie.utils") -local wk = require("which-key") +local ts_config = require("nvim-treesitter.configs") -local function select_textobject(query) - return utils.partial(ts_select.select_textobject, query) -end - -local function goto_next_start(query) - return utils.partial(ts_move.goto_next_start, query) -end -local function goto_next_end(query) - return utils.partial(ts_move.goto_next_end, query) -end -local function goto_previous_start(query) - return utils.partial(ts_move.goto_previous_start, query) -end -local function goto_previous_end(query) - return utils.partial(ts_move.goto_previous_end, query) -end - -local objects = { - mode = { "x", "o" }, - { "aa", select_textobject("@parameter.outer"), desc = "a parameter" }, - { "ia", select_textobject("@parameter.inner"), desc = "inner parameter" }, - { "ab", select_textobject("@block.outer"), desc = "a block" }, - { "ib", select_textobject("@block.inner"), desc = "inner block" }, - { "ac", select_textobject("@class.outer"), desc = "a class" }, - { "ic", select_textobject("@class.inner"), desc = "inner class" }, - { "af", select_textobject("@function.outer"), desc = "a function" }, - { "if", select_textobject("@function.inner"), desc = "inner function" }, - { "ak", select_textobject("@comment.outer"), desc = "a comment" }, - { "aS", select_textobject("@statement.outer"), desc = "a statement" }, -} -local moves = { - mode = { "n", "x", "o" }, - -- Next start - { "]m", goto_next_start("@function.outer"), desc = "Next method start" }, - { "]S", goto_next_start("@statement.outer"), desc = "Next statement start" }, - { "]]", goto_next_start("@class.outer"), desc = "Next class start" }, - -- Next end - { "]M", goto_next_end("@function.outer"), desc = "Next method end" }, - { "][", goto_next_end("@class.outer"), desc = "Next class end" }, - -- Previous start - { "[m", goto_previous_start("@function.outer"), desc = "Previous method start" }, - { "[S", goto_previous_start("@statement.outer"), desc = "Previous statement start" }, - { "[[", goto_previous_start("@class.outer"), desc = "Previous class start" }, - -- Previous end - { "[M", goto_previous_end("@function.outer"), desc = "Previous method end" }, - { "[]", goto_previous_end("@class.outer"), desc = "Previous class end" }, -} -wk.add(objects) -wk.add(moves) - -require("nvim-treesitter-textobjects").setup({ - select = { - -- Jump to matching text objects - lookahead = true, +ts_config.setup({ + highlight = { + enable = true, + -- Avoid duplicate highlighting + additional_vim_regex_highlighting = false, }, - move = { - -- Add to jump list - set_jumps = true, + indent = { + enable = true, + }, + textobjects = { + select = { + enable = true, + -- 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" }, + }, + }, + move = { + enable = true, + -- 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" }, + }, + goto_next_end = { + ["]M"] = { query = "@function.outer", desc = "Next method end" }, + ["]["] = { query = "@class.outer", desc = "Next class end" }, + }, + 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" }, + }, + goto_previous_end = { + ["[M"] = { query = "@function.outer", desc = "Previous method end" }, + ["[]"] = { query = "@class.outer", desc = "Previous class end" }, + }, + }, }, }) - --- Automatically setup treesitter for supported filetypes -local function treesitter_try_attach(buf, language) - -- Try to load language - -- NOTE: the best way I found to check if a filetype has a grammar - if not vim.treesitter.language.add(language) then - return false - end - - -- Syntax highlighting - vim.treesitter.start(buf, language) - -- Indentation - vim.bo.indentexpr = "v:lua.require('nvim-treesitter').indentexpr()" - - return true -end - -vim.api.nvim_create_autocmd("FileType", { - pattern = "*", - group = vim.api.nvim_create_augroup("treesitter_attach", { clear = true }), - callback = function(args) - local buf, filetype = args.buf, args.match - local language = vim.treesitter.language.get_lang(filetype) - if not language then - return - end - treesitter_try_attach(buf, language) - end, -}) diff --git a/modules/home/xdg/default.nix b/modules/home/xdg/default.nix index 7a0c5179..d65284f5 100644 --- a/modules/home/xdg/default.nix +++ b/modules/home/xdg/default.nix @@ -3,6 +3,10 @@ let cfg = config.my.home.xdg; in { + imports = [ + ./mime-apps.nix + ]; + options.my.home.xdg = with lib; { enable = my.mkDisableOption "XDG configuration"; }; diff --git a/modules/home/xdg/mime-apps.nix b/modules/home/xdg/mime-apps.nix new file mode 100644 index 00000000..8dd52980 --- /dev/null +++ b/modules/home/xdg/mime-apps.nix @@ -0,0 +1,280 @@ +{ config, lib, ... }: +let + cfg = config.my.home.xdg.mime-apps; + app = cfg.applications; + + strOrStrList = with lib.types; coercedTo str lib.singleton (listOf str); + mkMimeAppOption = kind: lib.mkOption { + description = "Application to associate as ${kind}"; + default = null; + type = lib.types.nullOr strOrStrList; + }; +in +{ + options.my.home.xdg.mime-apps = with lib; { + enable = my.mkDisableOption "XDG MIME Applications configuration"; + + applications = lib.mapAttrsRecursive (_: mkMimeAppOption) { + archive = "archive manager"; + browser = "internet browser"; + calendar = "calendar"; + editor = "text editor"; + fileManager = "file manager"; + mail = "mail client"; + media = { + audio = "audio player"; + document = { + comic = "comic book reader"; + ebook = "ebook reader"; + pdf = "PDF reader"; + }; + image = { + bitmap = "bitmap image viewer"; + vector = "vector image viewer"; + editor = "image editor"; + }; + video = "video player"; + }; + office = { + database = "database management program"; + formula = "formula editor"; + graphics = "graphics editor"; + presentation = "presentation editor"; + spreadsheet = "spreadsheet editor"; + text = "word processor"; + }; + terminal = "terminal"; + torrent = "bittorrent client"; + }; + }; + + config = lib.mkIf cfg.enable { + xdg = { + mimeApps = { + enable = true; + defaultApplications = lib.filterAttrs (_: apps: apps != null) { + "application/epub+zip" = app.media.document.ebook; + "application/gzip" = app.archive; + "application/json" = app.editor; + "application/ld+json" = app.editor; + "application/mxf " = app.media.video; + "application/ogg" = app.media.audio; + "application/pdf" = app.media.document.pdf; + "application/rss+xml" = app.editor; + "application/smil+xml " = app.media.video; + "application/vnd.amazon.ebook" = app.media.document.ebook; + "application/vnd.apple.mpegurl " = app.media.video; + "application/vnd.comicbook+zip" = app.media.document.comic; + "application/vnd.comicbook-rar" = app.media.document.comic; + "application/vnd.mozilla.xul+xml" = app.browser; + "application/vnd.ms-excel" = app.office.spreadsheet; + "application/vnd.ms-powerpoint" = app.office.presentation; + "application/vnd.ms-word" = app.office.text; + "application/vnd.oasis.opendocument.database" = app.office.database; + "application/vnd.oasis.opendocument.formula" = app.office.formula; + "application/vnd.oasis.opendocument.graphics" = app.office.graphics; + "application/vnd.oasis.opendocument.graphics-template" = app.office.graphics; + "application/vnd.oasis.opendocument.presentation" = app.office.presentation; + "application/vnd.oasis.opendocument.presentation-template" = app.office.presentation; + "application/vnd.oasis.opendocument.spreadsheet" = app.office.spreadsheet; + "application/vnd.oasis.opendocument.spreadsheet-template" = app.office.spreadsheet; + "application/vnd.oasis.opendocument.text" = app.office.text; + "application/vnd.oasis.opendocument.text-master" = app.office.text; + "application/vnd.oasis.opendocument.text-template" = app.office.text; + "application/vnd.oasis.opendocument.text-web" = app.office.text; + "application/vnd.openxmlformats-officedocument.presentationml.presentation" = app.office.presentation; + "application/vnd.openxmlformats-officedocument.presentationml.template" = app.office.presentation; + "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" = app.office.spreadsheet; + "application/vnd.openxmlformats-officedocument.spreadsheetml.template" = app.office.spreadsheet; + "application/vnd.openxmlformats-officedocument.wordprocessingml.document" = app.office.text; + "application/vnd.openxmlformats-officedocument.wordprocessingml.template" = app.office.text; + "application/vnd.rar" = app.archive; + "application/vnd.stardivision.calc" = app.office.spreadsheet; + "application/vnd.stardivision.draw" = app.office.graphics; + "application/vnd.stardivision.impress" = app.office.presentation; + "application/vnd.stardivision.math" = app.office.formula; + "application/vnd.stardivision.writer" = app.office.text; + "application/vnd.sun.xml.base" = app.office.database; + "application/vnd.sun.xml.calc" = app.office.spreadsheet; + "application/vnd.sun.xml.calc.template" = app.office.spreadsheet; + "application/vnd.sun.xml.draw" = app.office.graphics; + "application/vnd.sun.xml.draw.template" = app.office.graphics; + "application/vnd.sun.xml.impress" = app.office.presentation; + "application/vnd.sun.xml.impress.template" = app.office.presentation; + "application/vnd.sun.xml.math" = app.office.formula; + "application/vnd.sun.xml.writer" = app.office.text; + "application/vnd.sun.xml.writer.global" = app.office.text; + "application/vnd.sun.xml.writer.template" = app.office.text; + "application/vnd.wordperfect" = app.office.text; + "application/x-7z-compressed" = app.archive; + "application/x-arj" = app.archive; + "application/x-bittorrent" = app.torrent; + "application/x-bzip" = app.archive; + "application/x-bzip-compressed-tar" = app.archive; + "application/x-bzip2" = app.archive; + "application/x-cb7" = app.media.document.comic; + "application/x-cbr" = app.media.document.comic; + "application/x-cbt" = app.media.document.comic; + "application/x-cbz" = app.media.document.comic; + "application/x-compress" = app.archive; + "application/x-compressed-tar" = app.archive; + "application/x-csh" = app.editor; + "application/x-cue" = app.media.audio; + "application/x-directory" = app.fileManager; + "application/x-extension-htm" = app.browser; + "application/x-extension-html" = app.browser; + "application/x-extension-ics" = app.calendar; + "application/x-extension-m4a" = app.media.audio; + "application/x-extension-mp4" = app.media.video; + "application/x-extension-shtml" = app.browser; + "application/x-extension-xht" = app.browser; + "application/x-extension-xhtml" = app.browser; + "application/x-fictionbook" = app.media.document.ebook; + "application/x-fictionbook+xml" = app.media.document.ebook; + "application/x-flac" = app.media.audio; + "application/x-gzip" = app.archive; + "application/x-lha" = app.archive; + "application/x-lhz" = app.archive; + "application/x-lzop" = app.archive; + "application/x-matroska" = app.media.video; + "application/x-netshow-channel" = app.media.video; + "application/x-quicktime-media-link" = app.media.video; + "application/x-quicktimeplayer" = app.media.video; + "application/x-rar" = app.archive; + "application/x-sh" = app.editor; + "application/x-shellscript" = app.editor; + "application/x-shorten " = app.media.audio; + "application/x-smil" = app.media.video; + "application/x-tar" = app.archive; + "application/x-tarz" = app.archive; + "application/x-wine-extension-ini" = app.editor; + "application/x-zip-compressed" = app.archive; + "application/x-zoo" = app.archive; + "application/xhtml+xml" = app.browser; + "application/xml" = app.editor; + "application/zip" = app.archive; + "audio/*" = app.media.video; + "image/*" = app.media.image.bitmap; + "image/svg+xml" = app.media.image.vector; + "image/x-compressed-xcf" = app.media.image.editor; + "image/x-fits" = app.media.image.editor; + "image/x-psd" = app.media.image.editor; + "image/x-xcf" = app.media.image.editor; + "inode/directory" = app.fileManager; + "message/rfc822" = app.mail; + "text/*" = app.editor; + "text/calendar" = app.calendar; + "text/html" = app.browser; + "text/plain" = app.editor; + "video/*" = app.media.video; + "x-scheme-handler/about" = app.browser; + "x-scheme-handler/chrome" = app.browser; + "x-scheme-handler/file" = app.fileManager; + "x-scheme-handler/ftp" = app.browser; + "x-scheme-handler/http" = app.browser; + "x-scheme-handler/https" = app.browser; + "x-scheme-handler/mailto" = app.mail; + "x-scheme-handler/mid" = app.mail; + "x-scheme-handler/terminal" = app.terminal; + "x-scheme-handler/unknown" = app.browser; + "x-scheme-handler/webcal" = app.calendar; + "x-scheme-handler/webcals" = app.calendar; + "x-www-browser" = app.browser; + + # FIXME: relevant? https://bbs.archlinux.org/viewtopic.php?id=243125 + + # FIXME: shouldn't be necessary then + # "audio/AMR" = app.media.audio; + # "audio/aac" = app.media.audio; + # "audio/ac3" = app.media.audio; + # "audio/flac" = app.media.audio; + # "audio/mp2" = app.media.audio; + # "audio/mp4" = app.media.audio; + # "audio/mpeg" = app.media.audio; + # "audio/ogg" = app.media.audio; + # "audio/vnd.dts" = app.media.audio; + # "audio/vnd.dts.hd" = app.media.audio; + # "audio/vnd.rn-realaudio" = app.media.audio; + # "audio/webm" = app.media.audio; + # "audio/x-adpcm" = app.media.audio; + # "audio/x-aiff" = app.media.audio; + # "audio/x-ape" = app.media.audio; + # "audio/x-matroska" = app.media.audio; + # "audio/x-mpegurl" = app.media.audio; + # "audio/x-ms-asx" = app.media.audio; + # "audio/x-ms-wma" = app.media.audio; + # "audio/x-musepack" = app.media.audio; + # "audio/x-scpls" = app.media.audio; + # "audio/x-tta" = app.media.audio; + # "audio/x-vorbis+ogg" = app.media.audio; + # "audio/x-wav" = app.media.audio; + # "audio/x-wavpack" = app.media.audio; + # "image/bmp" = app.media.image.bitmap; + # "image/gif" = app.media.image.bitmap; + # "image/heif" = app.media.image.bitmap; + # "image/jpeg" = app.media.image.bitmap; + # "image/jpg" = app.media.image.bitmap; + # "image/pjpeg" = app.media.image.bitmap; + # "image/png" = app.media.image.bitmap; + # "image/tiff" = app.media.image.bitmap; + # "image/vnd.zbrush.pcx" = app.media.image.bitmap; + # "image/webp" = app.media.image.bitmap; + # "image/x-icb" = app.media.image.bitmap; + # "image/x-ico" = app.media.image.bitmap; + # "image/x-pcx" = app.media.image.bitmap; + # "image/x-portable-anymap" = app.media.image.bitmap; + # "image/x-portable-bitmap" = app.media.image.bitmap; + # "image/x-portable-graymap" = app.media.image.bitmap; + # "image/x-portable-pixmap" = app.media.image.bitmap; + # "image/x-tga" = app.media.image.bitmap; + # "image/x-xbitmap" = app.media.image.bitmap; + # "image/x-xpixmap" = app.media.image.bitmap; + # "image/x-xwindowdump" = app.media.image.bitmap; + # "text/tcl" = app.editor; + # "text/x-c++hdr" = app.editor; + # "text/x-c++src" = app.editor; + # "text/x-chdr" = app.editor; + # "text/x-csrc" = app.editor; + # "text/x-java" = app.editor; + # "text/x-makefile" = app.editor; + # "text/x-moc" = app.editor; + # "text/x-pascal" = app.editor; + # "text/x-tex" = app.editor; + # "video/3gpp" = app.media.video; + # "video/3gpp2" = app.media.video; + # "video/dv" = app.media.video; + # "video/mp2t" = app.media.video; + # "video/mp4" = app.media.video; + # "video/mpeg" = app.media.video; + # "video/ogg" = app.media.video; + # "video/quicktime" = app.media.video; + # "video/vnd.mpegurl" = app.media.video; + # "video/vnd.rn-realvideo" = app.media.video; + # "video/webm" = app.media.video; + # "video/x-flic" = app.media.video; + # "video/x-flv" = app.media.video; + # "video/x-matroska" = app.media.video; + # "video/x-ms-wmv" = app.media.video; + # "video/x-msvideo" = app.media.video; + # "video/x-ogm+ogg" = app.media.video; + # "video/x-theora+ogg" = app.media.video; + + # FIXME: kind of weird formats, not quite adapted to attribute name + # "application/eps" = app.media.document.pdf + # "application/oxps" = app.media.document.pdf + # "application/postscript" = app.media.document.pdf + # "application/x-eps" = app.media.document.pdf + # "image/eps" = app.media.document.pdf + # "image/vnd.djvu" = app.media.document.pdf + # "image/vnd.djvu+multipage" = app.media.document.pdf + # "image/x-eps" = app.media.document.pdf + + # FIXME: additionally interesting, but not necessary + # "x-scheme-handler/discord" = [ "discord.desktop" ]; + # "x-scheme-handler/msteams" = [ "teams.desktop" ]; + # "x-scheme-handler/slack" = [ "slack.desktop" ]; + }; + }; + }; + }; +} diff --git a/modules/home/zathura/default.nix b/modules/home/zathura/default.nix index 61625420..7a47e828 100644 --- a/modules/home/zathura/default.nix +++ b/modules/home/zathura/default.nix @@ -17,4 +17,12 @@ in "statusbar-home-tilde" = true; }; }; + + config.my.home.xdg.mime-apps = lib.mkIf cfg.enable { + applications.media.document = { + comic = [ "org.pwmt.zathura.desktop" ]; + ebook = [ "org.pwmt.zathura.desktop" ]; + pdf = [ "org.pwmt.zathura.desktop" ]; + }; + }; } diff --git a/modules/home/zsh/default.nix b/modules/home/zsh/default.nix index 95242628..1e85ccec 100644 --- a/modules/home/zsh/default.nix +++ b/modules/home/zsh/default.nix @@ -8,10 +8,6 @@ in launchTmux = mkEnableOption "auto launch tmux at shell start"; - completionSync = { - enable = mkEnableOption "zsh-completion-sync plugin"; - }; - notify = { enable = mkEnableOption "zsh-done notification"; @@ -23,7 +19,7 @@ in "direnv reload" "fg" "git (?!push|pull|fetch)" - "home-manager (?!switch|build)" + "home-manager (?!switch|build|news)" "htop" "less" "man" @@ -72,7 +68,7 @@ in plugins = [ { name = "fast-syntax-highlighting"; - file = "share/zsh/plugins/fast-syntax-highlighting/fast-syntax-highlighting.plugin.zsh"; + file = "share/zsh/site-functions/fast-syntax-highlighting.plugin.zsh"; src = pkgs.zsh-fast-syntax-highlighting; } { @@ -122,18 +118,6 @@ in }; } - (lib.mkIf cfg.completionSync.enable { - programs.zsh = { - plugins = [ - { - name = "zsh-completion-sync"; - file = "share/zsh-completion-sync/zsh-completion-sync.plugin.zsh"; - src = pkgs.zsh-completion-sync; - } - ]; - }; - }) - (lib.mkIf cfg.notify.enable { programs.zsh = { plugins = [ diff --git a/modules/nixos/hardware/graphics/default.nix b/modules/nixos/hardware/graphics/default.nix index 4b6eb375..7d8b359c 100644 --- a/modules/nixos/hardware/graphics/default.nix +++ b/modules/nixos/hardware/graphics/default.nix @@ -15,6 +15,8 @@ in amd = { enableKernelModule = lib.my.mkDisableOption "Kernel driver module"; + + amdvlk = lib.mkEnableOption "Use AMDVLK instead of Mesa RADV driver"; }; intel = { @@ -33,6 +35,13 @@ in (lib.mkIf (cfg.gpuFlavor == "amd") { hardware.amdgpu = { initrd.enable = cfg.amd.enableKernelModule; + # Vulkan + amdvlk = lib.mkIf cfg.amd.amdvlk { + enable = true; + support32Bit = { + enable = true; + }; + }; }; hardware.graphics = { diff --git a/modules/nixos/services/homebox/default.nix b/modules/nixos/services/homebox/default.nix index 524a6d73..8ed5d776 100644 --- a/modules/nixos/services/homebox/default.nix +++ b/modules/nixos/services/homebox/default.nix @@ -39,7 +39,7 @@ in my.services.backup = { paths = [ - (lib.removePrefix "file://" config.services.homebox.settings.HBOX_STORAGE_CONN_STRING) + config.services.homebox.settings.HBOX_STORAGE_DATA ]; }; diff --git a/modules/nixos/services/mealie/default.nix b/modules/nixos/services/mealie/default.nix index f3774e17..8c02398c 100644 --- a/modules/nixos/services/mealie/default.nix +++ b/modules/nixos/services/mealie/default.nix @@ -32,7 +32,6 @@ in BASE_URL = "https://mealie.${config.networking.domain}"; TZ = config.time.timeZone; ALLOw_SIGNUP = "false"; - TOKEN_TIME = 24 * 180; # 180 days }; # Automatic PostgreSQL provisioning @@ -54,12 +53,6 @@ in }; }; - my.services.backup = { - paths = [ - "/var/lib/mealie" - ]; - }; - services.fail2ban.jails = { mealie = '' enabled = true diff --git a/modules/nixos/services/nextcloud/collabora.nix b/modules/nixos/services/nextcloud/collabora.nix index 408b232e..f8f42a77 100644 --- a/modules/nixos/services/nextcloud/collabora.nix +++ b/modules/nixos/services/nextcloud/collabora.nix @@ -16,12 +16,6 @@ in }; config = lib.mkIf cfg.enable { - services.nextcloud = { - extraApps = { - inherit (config.services.nextcloud.package.packages.apps) richdocuments; - }; - }; - services.collabora-online = { enable = true; inherit (cfg) port; diff --git a/modules/nixos/services/nextcloud/default.nix b/modules/nixos/services/nextcloud/default.nix index 24515ffe..d8d4fce0 100644 --- a/modules/nixos/services/nextcloud/default.nix +++ b/modules/nixos/services/nextcloud/default.nix @@ -35,7 +35,7 @@ in config = lib.mkIf cfg.enable { services.nextcloud = { enable = true; - package = pkgs.nextcloud32; + package = pkgs.nextcloud31; hostName = "nextcloud.${config.networking.domain}"; home = "/var/lib/nextcloud"; maxUploadSize = cfg.maxSize; @@ -62,16 +62,6 @@ in # Allow using the push service without hard-coding my IP in the configuration bendDomainToLocalhost = true; }; - - extraApps = { - inherit (config.services.nextcloud.package.packages.apps) - calendar - contacts - deck - tasks - ; - # notify_push is automatically installed by the module - }; }; # The service above configures the domain, no need for my wrapper diff --git a/modules/nixos/services/sabnzbd/default.nix b/modules/nixos/services/sabnzbd/default.nix index 37ba96cf..9e0d9c3c 100644 --- a/modules/nixos/services/sabnzbd/default.nix +++ b/modules/nixos/services/sabnzbd/default.nix @@ -2,35 +2,17 @@ { config, lib, ... }: let cfg = config.my.services.sabnzbd; + port = 9090; # NOTE: not declaratively set... in { options.my.services.sabnzbd = with lib; { enable = mkEnableOption "SABnzbd binary news reader"; - - port = mkOption { - type = types.port; - default = 9090; - example = 4242; - description = "The port on which SABnzbd will listen for incoming HTTP traffic"; - }; }; config = lib.mkIf cfg.enable { services.sabnzbd = { enable = true; group = "media"; - - # Don't warn about the config file - configFile = null; - # I want to configure servers outside of Nix - allowConfigWrite = true; - - settings = { - misc = { - host = "127.0.0.1"; - inherit (cfg) port; - }; - }; }; # Set-up media group @@ -38,7 +20,7 @@ in my.services.nginx.virtualHosts = { sabnzbd = { - inherit (cfg) port; + inherit port; }; }; diff --git a/modules/nixos/services/transmission/default.nix b/modules/nixos/services/transmission/default.nix index 6a7fbc72..ddd77d4b 100644 --- a/modules/nixos/services/transmission/default.nix +++ b/modules/nixos/services/transmission/default.nix @@ -71,14 +71,10 @@ in }; }; + # Transmission wants to eat *all* my RAM if left to its own devices systemd.services.transmission = { serviceConfig = { - # Transmission wants to eat *all* my RAM if left to its own devices MemoryMax = "33%"; - # Avoid errors due to high number of open files. - LimitNOFILE = 1048576; - # Longer stop timeout to finish all torrents - TimeoutStopSec = "5m"; }; }; diff --git a/overlays/downgrade-transmission/default.nix b/overlays/downgrade-transmission/default.nix index 9fc6d140..9d3fc8ae 100644 --- a/overlays/downgrade-transmission/default.nix +++ b/overlays/downgrade-transmission/default.nix @@ -1,7 +1,14 @@ -self: _prev: +self: prev: { - transmission_4 = self.callPackage ./transmission_4.nix { - fmt = self.fmt_9; - libutp = self.libutp_3_4; - }; + 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/overlays/downgrade-transmission/transmission_4.nix b/overlays/downgrade-transmission/transmission_4.nix deleted file mode 100644 index a49f6b9b..00000000 --- a/overlays/downgrade-transmission/transmission_4.nix +++ /dev/null @@ -1,232 +0,0 @@ -{ stdenv -, lib -, fetchFromGitHub -, fetchpatch2 -, cmake -, pkg-config -, python3 -, openssl -, curl -, libevent -, inotify-tools -, systemd -, zlib -, pcre -, libb64 -, libutp -, libdeflate -, utf8cpp -, fast-float -, fmt -, libpsl -, miniupnpc -, dht -, libnatpmp -, # Build options - enableGTK3 ? false -, gtkmm3 -, libpthread-stubs -, wrapGAppsHook3 -, enableQt5 ? false -, enableQt6 ? false -, qt5 -, qt6Packages -, nixosTests -, enableSystemd ? lib.meta.availableOn stdenv.hostPlatform systemd -, enableDaemon ? true -, enableCli ? true -, installLib ? false -, apparmorRulesFromClosure -}: - -let - inherit (lib) cmakeBool optionals; - - apparmorRules = apparmorRulesFromClosure { name = "transmission-daemon"; } ( - [ - curl - libdeflate - libevent - libnatpmp - libpsl - miniupnpc - openssl - pcre - zlib - ] - ++ optionals enableSystemd [ systemd ] - ++ optionals stdenv.hostPlatform.isLinux [ inotify-tools ] - ); - -in -stdenv.mkDerivation (finalAttrs: { - pname = "transmission"; - version = "4.0.5"; - - src = fetchFromGitHub { - owner = "transmission"; - repo = "transmission"; - rev = finalAttrs.version; - hash = "sha256-gd1LGAhMuSyC/19wxkoE2mqVozjGPfupIPGojKY0Hn4="; - fetchSubmodules = true; - }; - - patches = [ - (fetchpatch2 { - url = "https://github.com/transmission/transmission/commit/febfe49ca3ecab1a7142ecb34012c1f0b2bcdee8.patch?full_index=1"; - hash = "sha256-Ge0+AXf/ilfMieGBAdvvImY7JOb0gGIdeKprC37AROs="; - excludes = [ - # The submodule that we don't use (we use our miniupnp) - "third-party/miniupnp" - # Hunk fails for this one, but we don't care because we don't rely upon - # xcode definitions even for the Darwin build. - "Transmission.xcodeproj/project.pbxproj" - ]; - }) - ]; - - outputs = [ - "out" - "apparmor" - ]; - - cmakeFlags = [ - (cmakeBool "ENABLE_CLI" enableCli) - (cmakeBool "ENABLE_DAEMON" enableDaemon) - (cmakeBool "ENABLE_GTK" enableGTK3) - (cmakeBool "ENABLE_MAC" false) # requires xcodebuild - (cmakeBool "ENABLE_QT" (enableQt5 || enableQt6)) - (cmakeBool "INSTALL_LIB" installLib) - ] - ++ optionals stdenv.hostPlatform.isDarwin [ - # Transmission sets this to 10.13 if not explicitly specified, see https://github.com/transmission/transmission/blob/0be7091eb12f4eb55f6690f313ef70a66795ee72/CMakeLists.txt#L7-L16. - "-DCMAKE_OSX_DEPLOYMENT_TARGET=${stdenv.hostPlatform.darwinMinVersion}" - ]; - - postPatch = '' - # Clean third-party libraries to ensure system ones are used. - # Excluding gtest since it is hardcoded to vendored version. The rest of the listed libraries are not packaged. - pushd third-party - for f in *; do - if [[ ! $f =~ googletest|wildmat|wide-integer|jsonsl ]]; then - rm -r "$f" - fi - done - popd - rm \ - cmake/FindFastFloat.cmake \ - cmake/FindFmt.cmake \ - cmake/FindUtfCpp.cmake - # Upstream uses different config file name. - substituteInPlace CMakeLists.txt --replace 'find_package(UtfCpp)' 'find_package(utf8cpp)' - - # Use gettext even on Darwin - substituteInPlace libtransmission/utils.h \ - --replace-fail '#if defined(HAVE_GETTEXT) && !defined(__APPLE__)' '#if defined(HAVE_GETTEXT)' - ''; - - nativeBuildInputs = [ - pkg-config - cmake - python3 - ] - ++ optionals enableGTK3 [ wrapGAppsHook3 ] - ++ optionals enableQt5 [ qt5.wrapQtAppsHook ] - ++ optionals enableQt6 [ qt6Packages.wrapQtAppsHook ]; - - buildInputs = [ - curl - dht - fast-float - fmt - libb64 - libdeflate - libevent - libnatpmp - libpsl - libutp - miniupnpc - openssl - pcre - utf8cpp - zlib - ] - ++ optionals enableQt5 ( - with qt5; - [ - qttools - qtbase - ] - ) - ++ optionals enableQt6 ( - with qt6Packages; - [ - qttools - qtbase - qtsvg - ] - ) - ++ optionals enableGTK3 [ - gtkmm3 - libpthread-stubs - ] - ++ optionals enableSystemd [ systemd ] - ++ optionals stdenv.hostPlatform.isLinux [ inotify-tools ]; - - postInstall = '' - mkdir $apparmor - cat >$apparmor/bin.transmission-daemon <, - include - profile $out/bin/transmission-daemon { - include - include - include - include "${apparmorRules}" - @{PROC}/sys/kernel/random/uuid r, - @{PROC}/sys/vm/overcommit_memory r, - @{PROC}/@{pid}/environ r, - @{PROC}/@{pid}/mounts r, - /tmp/tr_session_id_* rwk, - - $out/share/transmission/public_html/** r, - - include if exists - } - EOF - install -Dm0444 -t $out/share/icons ../qt/icons/transmission.svg - ''; - - passthru.tests = { - apparmor = nixosTests.transmission_4; # starts the service with apparmor enabled - smoke-test = nixosTests.bittorrent; - }; - - meta = { - description = "Fast, easy and free BitTorrent client"; - mainProgram = - if (enableQt5 || enableQt6) then - "transmission-qt" - else if enableGTK3 then - "transmission-gtk" - else - "transmission-cli"; - longDescription = '' - Transmission is a BitTorrent client which features a simple interface - on top of a cross-platform back-end. - Feature spotlight: - * Uses fewer resources than other clients - * Native Mac, GTK and Qt GUI clients - * Daemon ideal for servers, embedded systems, and headless use - * All these can be remote controlled by Web and Terminal clients - * Bluetack (PeerGuardian) blocklists with automatic updates - * Full encryption, DHT, and PEX support - ''; - homepage = "https://www.transmissionbt.com/"; - license = with lib.licenses; [ - gpl2Plus - mit - ]; - platforms = lib.platforms.unix; - }; -}) diff --git a/pkgs/i3-get-window-criteria/default.nix b/pkgs/i3-get-window-criteria/default.nix index cba51944..2fc840dc 100644 --- a/pkgs/i3-get-window-criteria/default.nix +++ b/pkgs/i3-get-window-criteria/default.nix @@ -1,4 +1,4 @@ -{ lib, coreutils, gnused, makeWrapper, stdenvNoCC, xprop, xwininfo }: +{ lib, coreutils, gnused, makeWrapper, stdenvNoCC, xorg }: stdenvNoCC.mkDerivation rec { pname = "i3-get-window-criteria"; version = "0.1.0"; @@ -22,8 +22,8 @@ stdenvNoCC.mkDerivation rec { wrapperPath = lib.makeBinPath [ coreutils gnused - xprop - xwininfo + xorg.xprop + xorg.xwininfo ]; fixupPhase = ''