diff --git a/.config/nvim/after/plugin/lsp.lua b/.config/nvim/after/plugin/lsp.lua index a9db967e..44796a73 100644 --- a/.config/nvim/after/plugin/lsp.lua +++ b/.config/nvim/after/plugin/lsp.lua @@ -1,4 +1,5 @@ local map = vim.keymap.set +local methods = vim.lsp.protocol.Methods ---------------------- -- Language servers -- @@ -75,22 +76,31 @@ local servers = { ------------- -- Helpers -- ------------- -local on_attach = function(client, bufno) - vim.api.nvim_set_option_value("omnifunc", "v:lua.vim.lsp.omnifunc", { buf = bufno }) - local ts = require("telescope.builtin") - local opts = { buffer = bufno } +local on_attach = function(client, bufnr) + vim.api.nvim_set_option_value("omnifunc", "v:lua.vim.lsp.omnifunc", { buf = bufnr }) + local telescope = require("telescope.builtin") - map("n", "K", vim.lsp.buf.hover, opts) - map("n", "", vim.lsp.buf.signature_help, opts) - map("n", "gd", vim.lsp.buf.definition, opts) + map("n", "K", vim.lsp.buf.hover, { buffer = bufnr }) + map("n", "", vim.lsp.buf.signature_help, { buffer = bufnr }) + map("n", "gd", telescope.lsp_definitions, { buffer = bufnr }) -- conflicts with tabs - -- map("n", "gtd", vim.lsp.buf.type_definition, opts) - map("n", "gi", vim.lsp.buf.implementation, opts) - map("n", "gu", ts.lsp_references, opts) - map("n", "ca", vim.lsp.buf.code_action, opts) - map("n", "cl", vim.lsp.codelens.run, opts) - map("n", "r", vim.lsp.buf.rename, opts) - map("n", "f", function() vim.lsp.buf.format { async = true } end, opts) + -- map("n", "gtd", vim.lsp.buf.type_definition, { buffer = bufnr }) + -- map("n", "gi", vim.lsp.buf.implementation, { buffer = bufnr }) + map("n", "gu", telescope.lsp_references, { buffer = bufnr }) + map("n", "ca", vim.lsp.buf.code_action, { buffer = bufnr }) + map("n", "cl", vim.lsp.codelens.run, { buffer = bufnr }) + map("n", "r", vim.lsp.buf.rename, { buffer = bufnr }) + map("n", "f", function() vim.lsp.buf.format { async = true } end, { buffer = bufnr }) + + local filetype = vim.api.nvim_get_option_value("filetype", { buf = bufnr }) + if + client:supports_method(methods.textDocument_inlayHint) + -- Never start cabal with inlay hint request + -- Related: https://github.com/mrcjkb/haskell-tools.nvim/discussions/485 + and filetype ~= "cabal" + then + vim.lsp.inlay_hint.enable(true, { bufnr = bufnr }) + end end -- Helix style border @@ -112,14 +122,11 @@ function vim.lsp.util.open_floating_preview(contents, syntax, opts, ...) end -- Diagnostic display configuration -vim.diagnostic.config { virtual_text = true, severity_sort = true } +vim.diagnostic.config { virtual_text = false, severity_sort = true } -- Set log level vim.lsp.set_log_level("off") --- Enable inlay hints -vim.lsp.inlay_hint.enable() - -- Gutter symbols setup vim.fn.sign_define("DiagnosticSignError", { text = "E", texthl = "DiagnosticSignError", numhl = "DiagnosticSignError" }) vim.fn.sign_define("DiagnosticSignWarn", { text = "W", texthl = "DiagnosticSignWarn", numhl = "DiagnosticSignWarn" }) diff --git a/.config/nvim/after/plugin/oil.lua b/.config/nvim/after/plugin/oil.lua index a805db9e..6acccbe1 100644 --- a/.config/nvim/after/plugin/oil.lua +++ b/.config/nvim/after/plugin/oil.lua @@ -1,4 +1,6 @@ require("oil").setup { + -- This bug would prevent downloading language files from working + -- https://github.com/stevearc/oil.nvim/issues/483 default_file_explorer = false, columns = { -- "icon", @@ -11,7 +13,7 @@ require("oil").setup { keymaps = { ["g?"] = "actions.show_help", [""] = "actions.select", - [""] = "actions.select_vsplit", + -- [""] = "actions.select_vsplit", [""] = "actions.select_split", [""] = "actions.select_tab", [""] = "actions.preview", diff --git a/.config/nvim/after/plugin/telescope.lua b/.config/nvim/after/plugin/telescope.lua index 33e7bae2..8994860f 100644 --- a/.config/nvim/after/plugin/telescope.lua +++ b/.config/nvim/after/plugin/telescope.lua @@ -1,9 +1,9 @@ -local ts = require("telescope") +local telescope = require("telescope") local actions = require("telescope.actions") local themes = require("telescope.themes") local config = require("telescope.config") local builtin = require("telescope.builtin") -local map = vim.keymap.set +local state = require("telescope.state") -- Clone the default Telescope configuration local vimgrep_arguments = { unpack(config.values.vimgrep_arguments) } @@ -12,31 +12,68 @@ table.insert(vimgrep_arguments, "--hidden") -- search hidden table.insert(vimgrep_arguments, "--glob") -- ignore git table.insert(vimgrep_arguments, "!**/.git/*") -ts.setup { - defaults = { +telescope.setup { + -- Workaround + -- https://github.com/nvim-telescope/telescope.nvim/issues/938#issuecomment-877539724 + defaults = themes.get_ivy { vimgrep_arguments = vimgrep_arguments, mappings = { + n = { + [""] = actions.close, + }, i = { - [""] = actions.close, + [""] = actions.cycle_history_prev, + [""] = actions.cycle_history_next, }, }, + layout_config = { height = 0.4 }, + borderchars = { "", "", "", "│", "", "", "", "" }, }, pickers = { find_files = { find_command = { "rg", "--files", "--hidden", "--glob", "!**/.git/*" }, }, + current_buffer_fuzzy_find = { + layout_config = { height = 0.8 }, + }, + lsp_references = { + layout_config = { height = 0.8 }, + initial_mode = "normal", + }, + live_grep = { + layout_config = { height = 0.8 }, + }, + resume = { + initial_mode = "normal", + }, }, } -- Enable telescope fzf native, if installed pcall(require("telescope").load_extension, "fzf") -map("n", "/", function() builtin.current_buffer_fuzzy_find(themes.get_dropdown { previewer = false }) end) -map("n", "sf", builtin.find_files) -map("n", "gf", builtin.git_files) -map("n", "?", builtin.help_tags) -map("n", "sw", builtin.grep_string) -map("n", "sg", builtin.live_grep) -map("n", "sd", builtin.diagnostics) -map("n", "b", builtin.buffers) -map("n", "sp", builtin.spell_suggest) +-- Waiting for better state management upstream +-- Currently we have to wire the state ourselves +local buffer_picker = nil +local init_buffer_picker = function() + builtin["current_buffer_fuzzy_find"]() + local cached_pickers = state.get_global_key("cached_pickers") or {} + buffer_picker = cached_pickers[1] +end +local cached_buffer_picker = function() + if buffer_picker == nil then + init_buffer_picker() + else + builtin.resume { picker = buffer_picker } + end +end +vim.keymap.set("n", "/", init_buffer_picker) +vim.keymap.set("n", "?", cached_buffer_picker) + +vim.keymap.set("n", "/", builtin["find_files"]) +-- vim.keymap.set("n", "g/", builtin["git_files"]) +vim.keymap.set("n", "?", builtin["help_tags"]) +vim.keymap.set("n", "g/", builtin["live_grep"]) +vim.keymap.set("n", "d", builtin["diagnostics"]) +vim.keymap.set("n", "b", builtin["buffers"]) +vim.keymap.set("n", "sp", builtin["spell_suggest"]) diff --git a/.config/nvim/after/plugin/treesitter.lua b/.config/nvim/after/plugin/treesitter.lua index 83d53e89..c1f391f4 100644 --- a/.config/nvim/after/plugin/treesitter.lua +++ b/.config/nvim/after/plugin/treesitter.lua @@ -25,32 +25,5 @@ require("nvim-treesitter.configs").setup { if ok and stats and stats.size > max_filesize then return true end end, - -- Text objets - textobjects = { - select = { - enable = true, - lookahead = true, - keymaps = { - ["af"] = "@function.outer", - ["if"] = "@function.inner", - ["ac"] = "@class.outer", - ["ic"] = "@class.inner", - }, - selection_modes = { - ["@parameter.outer"] = "v", -- charwise - ["@function.outer"] = "V", -- linewise - ["@class.outer"] = "", -- blockwise - }, - include_surrounding_whitespace = true, - }, - swap = { - enable = true, - swap_next = { - ["a"] = "@parameter.inner", - }, - swap_previous = { - ["A"] = "@parameter.inner", - }, - }, - }, + indent = true, } diff --git a/.config/nvim/lua/maps.lua b/.config/nvim/lua/maps.lua index 348bff1e..06360af9 100644 --- a/.config/nvim/lua/maps.lua +++ b/.config/nvim/lua/maps.lua @@ -12,7 +12,7 @@ vim.keymap.set("v", "=", "=gv") vim.keymap.set("n", "", "zz") vim.keymap.set("n", "", "zz") vim.keymap.set("n", "gd", "gdzz") -vim.keymap.set("n", "gD", "wgd", { remap = true }) +vim.keymap.set("n", "gD", "vgd", { remap = true }) vim.keymap.set("n", "``", "``zz") vim.keymap.set("n", "n", "nzzzv") vim.keymap.set("n", "N", "Nzzzv") @@ -45,8 +45,8 @@ vim.keymap.set("n", "Q", "") -- *do not* repeat the last recorded register -- Diagnostics vim.keymap.set("n", "e", vim.diagnostic.open_float) -vim.keymap.set("n", "pe", vim.diagnostic.goto_prev) -vim.keymap.set("n", "ne", vim.diagnostic.goto_next) +vim.keymap.set("n", "pe", function() vim.diagnostic.jump { count = -1, float = true } end) +vim.keymap.set("n", "ne", function() vim.diagnostic.jump { count = 1, float = true } end) vim.keymap.set("t", "", "") @@ -73,21 +73,18 @@ vim.keymap.set("n", "gl", function() end) -- Fugitive -vim.keymap.set("n", "gP", function() vim.cmd("G push") end) -vim.keymap.set("n", "gp", function() vim.cmd("G pull") end) - vim.keymap.set("n", "", ":Git5") vim.keymap.set("n", "gu", ":diffget //2") vim.keymap.set("n", "gh", ":diffget //3") -vim.api.nvim_create_autocmd("FileType", { - pattern = "fugitive", - callback = function() vim.keymap.set("n", "", ":q", { buffer = true }) end, -}) vim.keymap.set("n", "gb", ":Git blame") vim.keymap.set("n", "gB", ":Git blame --ignore-revs-file=.git-blame-ignore-revs") -vim.api.nvim_create_autocmd("FileType", { - pattern = "fugitiveblame", - callback = function() vim.keymap.set("n", "gb", ":q", { buffer = true }) end, + +vim.api.nvim_create_autocmd("WinClosed", { + group = vim.api.nvim_create_augroup("conf_fugitive_prevwin", {}), + callback = function(args) + local win = tonumber(args.match) + if win == vim.api.nvim_get_current_win() and vim.bo.filetype == "fugitive" then vim.cmd.wincmd("p") end + end, }) -- NoNeckPain diff --git a/.config/nvim/lua/opts.lua b/.config/nvim/lua/opts.lua index 75c66ac7..dc89050d 100644 --- a/.config/nvim/lua/opts.lua +++ b/.config/nvim/lua/opts.lua @@ -31,3 +31,6 @@ vim.o.showmode = false vim.opt.listchars = { tab = "│ ", trail = "␣" } vim.o.list = true + +vim.o.splitright = true +vim.o.splitbelow = true diff --git a/Justfile b/Justfile index 672edec8..17d6a417 100644 --- a/Justfile +++ b/Justfile @@ -5,7 +5,7 @@ os host action: #!/usr/bin/env bash set -euo pipefail - nixpkgs=$(nix-instantiate --eval -E "let sources = import ./nix/sources.nix; in sources.nixpkgs.outPath" | jq -r .) + nixpkgs=$(nix-instantiate --eval -E "let sources = import ./npins; in sources.nixpkgs.outPath" | jq -r .) sudo nixos-rebuild {{ action }} \ -I nixpkgs=${nixpkgs} \ -I nixos-config=./nix/configurations/{{ host }}.nix \ @@ -17,12 +17,16 @@ install host: #!/usr/bin/env bash set -euo pipefail - nixpkgs=$(nix-instantiate --eval -E "let sources = import ./nix/sources.nix; in sources.nixpkgs.outPath" | jq -r .) + nixpkgs=$(nix-instantiate --eval -E "let sources = import ./npins; in sources.nixpkgs.outPath" | jq -r .) sudo nixos-install \ -I nixpkgs=${nixpkgs} \ -I nixos-config=./nix/configurations/{{ host }}.nix \ --file ./default.nix \ --attr "nixosConfigurations.{{ host }}" +cleanup: + sudo nix-env --delete-generations +10 -p /nix/var/nix/profiles/system + nix-env --delete-generations +10 -p ~/.local/state/nix/profiles/home-manager + update: npins update diff --git a/README.md b/README.md index 80b8dcf1..be05b562 100644 --- a/README.md +++ b/README.md @@ -13,7 +13,7 @@ This repo is managed with Nix + GNU stow - Installation (iirc the disko auto install has some issues) ```bash # Are you sure the disko config has the right drive path? - disko -- -m disko ./disko.nix # format the drive + disko -m disko ./disko.nix # format the drive # optional for unknown hard ware nixos-generate-config --no-filesystems --root /mnt --dir . # disko will take care of the file system configuration diff --git a/default.nix b/default.nix index afa2fe55..bb271cfa 100644 --- a/default.nix +++ b/default.nix @@ -1,4 +1,4 @@ -{sources ? import ./nix/sources.nix}: { +{sources ? import ./npins}: { lib = import (sources.nixpkgs + "/lib"); nixosConfigurations = builtins.mapAttrs (_: import (sources.nixpkgs + "/nixos/lib/eval-config.nix")) { diff --git a/nix/configurations/tungsten.nix b/nix/configurations/tungsten.nix index a8e54d66..92d2fb38 100644 --- a/nix/configurations/tungsten.nix +++ b/nix/configurations/tungsten.nix @@ -1,6 +1,6 @@ # Entry point to cherry pick modules let - sources = import ../sources.nix; + sources = import ../../npins; hostname = "tungsten"; username = "leana"; @@ -134,7 +134,6 @@ in ../homeModules/common/vim ../homeModules/common/wired ../homeModules/common/atuin.nix - ../homeModules/common/battery-notify.nix ../homeModules/common/direnv.nix ../homeModules/common/feh.nix ../homeModules/common/firefox.nix @@ -144,7 +143,6 @@ in ../homeModules/common/kitty.nix ../homeModules/common/leana.nix ../homeModules/common/locale.nix - ../homeModules/common/neovim.nix ../homeModules/common/packages.nix ../homeModules/common/password-store.nix ../homeModules/common/sioyek.nix diff --git a/nix/configurations/tungsten/home/programs.nix b/nix/configurations/tungsten/home/programs.nix index 5ddb946f..25377437 100644 --- a/nix/configurations/tungsten/home/programs.nix +++ b/nix/configurations/tungsten/home/programs.nix @@ -76,7 +76,6 @@ pkgs.xbrightness pkgs.dmenu pkgs.xclip - pkgs.playerctl # talk to playerctld pkgs.xscreensaver # talk to xscreensaver pkgs.xcolor @@ -104,12 +103,6 @@ enable = true; components = ["secrets"]; }; - - battery-notify = { - enable = true; - device_full = "/sys/class/power_supply/BAT0/charge_full"; - device_now = "/sys/class/power_supply/BAT0/charge_now"; - }; }; } ]; diff --git a/nix/configurations/tungsten/home/xmobar.nix b/nix/configurations/tungsten/home/xmobar.nix index 14f65dad..55ff9f6c 100644 --- a/nix/configurations/tungsten/home/xmobar.nix +++ b/nix/configurations/tungsten/home/xmobar.nix @@ -9,20 +9,38 @@ , position = BottomH 30 , commands = [ Run Date "%a %d %H:%M:%S" "date" 10 , Run Battery - [ "-t", ":%" - , "--" - , "-O", "󰂄" - , "-i", "󱟦" - , "-o", "󰁾" + [ "-t", " ()" + , "-H", "70" + , "-L", "20" , "-h", "green" - , "-m", "yell" + , "-n", "orange" , "-l", "red" + , "--" + , "-P" + , "-A", "20" + , "-a", "notify-send -u critical \"Battery Low\" \"Please charge your battery\"" ] 10 , Run XMonadLog - ] + , Run + DynNetwork + [ "--template" + , ": ↑ kB/s ↓ kB/s" + , "--Low" + , "102400" + , "--High" + , "1024000" + , "--low" + , "green" + , "--normal" + , "orange" + , "--high" + , "red" + ] + 10 + ] , sepChar = "%" , alignSep = "}{" - , template = " %XMonadLog% }{ %battery% | %date% " + , template = " %XMonadLog% }{ %dynnetwork% | %battery% | %date% " } ''; }; diff --git a/nix/configurations/tungsten/nixos/input.nix b/nix/configurations/tungsten/nixos/input.nix index 5bcfbe2f..01153159 100644 --- a/nix/configurations/tungsten/nixos/input.nix +++ b/nix/configurations/tungsten/nixos/input.nix @@ -17,9 +17,9 @@ services.fprintd.enable = false; - programs.weylus = { - enable = true; - users = ["leana"]; - openFirewall = true; - }; + # programs.weylus = { + # enable = true; + # users = ["leana"]; + # openFirewall = true; + # }; } diff --git a/nix/configurations/vanadium.nix b/nix/configurations/vanadium.nix index 45c3b166..c68d59f5 100644 --- a/nix/configurations/vanadium.nix +++ b/nix/configurations/vanadium.nix @@ -1,6 +1,6 @@ # Entry point to cherry pick modules let - sources = import ../sources.nix; + sources = import ../../npins; hostname = "vanadium"; username = "leana"; @@ -153,7 +153,6 @@ in ../homeModules/common/vim ../homeModules/common/wired ../homeModules/common/atuin.nix - ../homeModules/common/battery-notify.nix ../homeModules/common/direnv.nix ../homeModules/common/feh.nix ../homeModules/common/firefox.nix @@ -164,7 +163,6 @@ in ../homeModules/common/leana.nix ../homeModules/common/locale.nix ../homeModules/common/lazygit.nix - ../homeModules/common/neovim.nix ../homeModules/common/packages.nix ../homeModules/common/password-store.nix ../homeModules/common/sioyek.nix diff --git a/nix/configurations/vanadium/home/dev.nix b/nix/configurations/vanadium/home/dev.nix index 71f9d9d1..c96ed512 100644 --- a/nix/configurations/vanadium/home/dev.nix +++ b/nix/configurations/vanadium/home/dev.nix @@ -23,6 +23,10 @@ pkgs.taplo # toml pkgs.vscode-langservers-extracted # JSON etc pkgs.yaml-language-server # yaml + + # bash + pkgs.shfmt + pkgs.nodePackages.bash-language-server ]; programs.git = { diff --git a/nix/configurations/vanadium/home/firefox.nix b/nix/configurations/vanadium/home/firefox.nix index 0aeba9f8..30f4ab5d 100644 --- a/nix/configurations/vanadium/home/firefox.nix +++ b/nix/configurations/vanadium/home/firefox.nix @@ -10,8 +10,6 @@ in { enable = true; policies = { - RequestedLocales = ["fr" "en-US" "zh-TW"]; - SearchEngines = { Default = "Google en@en"; Remove = ["Google"]; diff --git a/nix/configurations/vanadium/home/programs.nix b/nix/configurations/vanadium/home/programs.nix index b39bcdd0..70b02447 100644 --- a/nix/configurations/vanadium/home/programs.nix +++ b/nix/configurations/vanadium/home/programs.nix @@ -77,7 +77,7 @@ emacs = { enable = true; - package = pkgs.emacs28; + package = pkgs.unsafe-emacs28; }; lazygit.enable = true; @@ -106,7 +106,6 @@ # productivity / media pkgs.evolution pkgs.libreoffice - pkgs.iamb pkgs.calibre # pkgs.rawtherapee pkgs.digikam @@ -159,12 +158,6 @@ enable = true; components = ["secrets"]; }; - - battery-notify = { - enable = true; - device_full = "/sys/class/power_supply/BAT1/charge_full"; - device_now = "/sys/class/power_supply/BAT1/charge_now"; - }; }; } ]; diff --git a/nix/configurations/vanadium/home/xmobar.nix b/nix/configurations/vanadium/home/xmobar.nix index 14f65dad..d819da60 100644 --- a/nix/configurations/vanadium/home/xmobar.nix +++ b/nix/configurations/vanadium/home/xmobar.nix @@ -1,6 +1,10 @@ { programs.xmobar = { enable = true; + # XMobar's config file is not a segment of valid Haskell source code -- it is instead a DSL + # Note how `Run` handles its arguments properly without parens? + # + # Also xmobar wants GHC if we use it as a library, and I'm lazy, you probably want to keep it this way. extraConfig = '' Config { overrideRedirect = False , font = "Iosevka 13" @@ -9,20 +13,48 @@ , position = BottomH 30 , commands = [ Run Date "%a %d %H:%M:%S" "date" 10 , Run Battery - [ "-t", ":%" - , "--" - , "-O", "󰂄" - , "-i", "󱟦" - , "-o", "󰁾" + [ "-t", " ()" + , "-H", "70" + , "-L", "20" , "-h", "green" - , "-m", "yell" + , "-n", "orange" , "-l", "red" - ] 10 + , "--" + , "-P" + , "-A", "20" + , "-a", "notify-send -u critical \"Battery Low\" \"Please charge your battery\"" + ] + 600 , Run XMonadLog + , Run + DynNetwork + [ "--template" + , ": ↑ kB/s ↓ kB/s" + , "--Low" + , "102400" + , "--High" + , "1024000" + , "--low" + , "green" + , "--normal" + , "orange" + , "--high" + , "red" + ] + 100 + , Run + Weather "LFRN" + [ "-t", ": C" + , "-L","10", "-H", "25" + , "--normal", "white" + , "--high", "orange" + , "--low", "blue" + ] + 9000 ] , sepChar = "%" , alignSep = "}{" - , template = " %XMonadLog% }{ %battery% | %date% " + , template = " %XMonadLog% }{ %dynnetwork% | %LFRN% | %battery% | %date% " } ''; }; diff --git a/nix/configurations/vanadium/home/xmonad/xmonad.hs b/nix/configurations/vanadium/home/xmonad/xmonad.hs index 2810b591..44994725 100644 --- a/nix/configurations/vanadium/home/xmonad/xmonad.hs +++ b/nix/configurations/vanadium/home/xmonad/xmonad.hs @@ -16,6 +16,7 @@ import XMonad.Util.SpawnOnce (spawnOnce) import XMonad.Layout.NoBorders (smartBorders) import XMonad.Layout.Reflect (reflectHoriz) import XMonad.Layout.Spacing (smartSpacingWithEdge) +import XMonad.Layout.Renamed (named) import XMonad.Layout.ResizableTile (ResizableTall(ResizableTall), MirrorResize (MirrorShrink, MirrorExpand)) import XMonad.Hooks.ManageHelpers (isFullscreen, (~?), composeOne, (-?>)) @@ -93,9 +94,10 @@ main = xmonad let tallr = reflectMsg . reflectHoriz $ ResizableTall 1 (1/10) (3/7) [] in smartBorders - ( smartSpacingWithEdge 5 tallr - ||| Full - ) + ( named "Normal" + (smartSpacingWithEdge 5 tallr) + ||| Full + ) , manageHook = let @@ -184,9 +186,9 @@ main = xmonad -- Screenshots ++ (let - fullscreen = "maim | xclip -in -selection clipboard -t image/png" - withSelection = "maim -s -b 5 -o | xclip -in -selection clipboard -t image/png" - toFloat = "maim -s -b 5 -o | feh --auto-zoom -" + fullscreen = "maim -u | xclip -in -selection clipboard -t image/png" + withSelection = "maim -u -s -b 5 -o | xclip -in -selection clipboard -t image/png" + toFloat = "maim -u -s -b 5 -o | feh --auto-zoom -" in [ ((0, xK_Print), spawn fullscreen ) , ((superMask .|. shiftMask, xK_3 ), spawn fullscreen ) diff --git a/nix/configurations/vanadium/nixos/input.nix b/nix/configurations/vanadium/nixos/input.nix index 30cbc716..761e8095 100644 --- a/nix/configurations/vanadium/nixos/input.nix +++ b/nix/configurations/vanadium/nixos/input.nix @@ -21,9 +21,9 @@ services.fprintd.enable = false; - programs.weylus = { - enable = true; - users = ["leana"]; - openFirewall = true; - }; + # programs.weylus = { + # enable = true; + # users = ["leana"]; + # openFirewall = true; + # }; } diff --git a/nix/configurations/vanadium/overlay.nix b/nix/configurations/vanadium/overlay.nix index c2e62065..b866a7f9 100644 --- a/nix/configurations/vanadium/overlay.nix +++ b/nix/configurations/vanadium/overlay.nix @@ -1,5 +1,5 @@ let - sources = import ../../sources.nix; + sources = import ../../../npins; lib = import (sources.nixpkgs + "/lib"); infuse-lib = import sources.infuse { @@ -54,4 +54,18 @@ in ./patches/fcitx5-chinese-addons/disable-fullwidth.patch # Note: disabling pinyin helper breaks canjie ]; + + # TODO: remove this when upstream is updated + sudo.__output.patches.__append = [ + (final.fetchpatch { + name = "CVE-2025-32462"; + url = "https://github.com/sudo-project/sudo/commit/d530367828e3713d09489872743eb92d31fb11ff.patch"; + hash = "sha256-mS8fcPV1QDv9SDuGN7dfDLtVLSBP+apotYW1UsEBPvU="; + }) + (final.fetchpatch { + name = "CVE-2025-32463"; + url = "https://github.com/sudo-project/sudo/commit/fdafc2ceb36382b07e604c0f39903d56bef54016.patch"; + hash = "sha256-4FP8z5pKwcOfJxjJ9X/IbCgriKJm1H/HnswuvYjBlt8="; + }) + ]; } diff --git a/nix/devShells/flora.nix b/nix/devShells/flora.nix index 076867ee..21c35fb8 100644 --- a/nix/devShells/flora.nix +++ b/nix/devShells/flora.nix @@ -2,7 +2,7 @@ # This is the non flake shell that just gets the basics of flora so I can have hls support outside of docker # let - sources = import ../sources.nix; + sources = import ../../npins; in {pkgs ? import sources.pin-florashell {}}: pkgs.mkShell (let diff --git a/nix/devShells/necro-man.nix b/nix/devShells/necro-man.nix index 8b0f2cf1..098e0cdc 100644 --- a/nix/devShells/necro-man.nix +++ b/nix/devShells/necro-man.nix @@ -1,5 +1,5 @@ let - sources = import ../sources.nix; + sources = import ../../npins; in {pkgs ? import sources.pin-necro-man-nixpkgs {}}: let shell = { diff --git a/nix/devShells/vim-tw.nix b/nix/devShells/vim-tw.nix index f9a5ca97..58c6678c 100644 --- a/nix/devShells/vim-tw.nix +++ b/nix/devShells/vim-tw.nix @@ -1,5 +1,5 @@ let - sources = import ../sources.nix; + sources = import ../../npins; in {pkgs ? import sources.pin-vim-tw {}}: pkgs.mkShell { diff --git a/nix/homeModules/common/battery-notify.nix b/nix/homeModules/common/battery-notify.nix deleted file mode 100644 index e7fce649..00000000 --- a/nix/homeModules/common/battery-notify.nix +++ /dev/null @@ -1,70 +0,0 @@ -{ - pkgs, - lib, - config, - ... -}: let - cfg = config.services."battery-notify"; -in { - options = { - services."battery-notify" = { - enable = lib.mkEnableOption "battery-notify"; - triggerLevel = lib.mkOption { - type = with lib.types; ints.between 0 100; - description = "Below which percentage should the script send a notification"; - default = 20; - }; - checkAt = lib.mkOption { - type = with lib.types; listOf str; - description = "At which frequency should the service check for the battery status"; - default = ["*:0/5"]; # every five minutes - }; - device_full = lib.mkOption { - type = with lib.types; str; - description = "The device to read for full energy status"; - }; - device_now = lib.mkOption { - type = with lib.types; str; - description = "The device to read for current energy status"; - }; - }; - }; - - config = lib.mkIf cfg.enable { - systemd.user.services."battery-notify" = { - Unit.Description = "Notify when battery is low"; - Install = { - WantedBy = ["multi-user.target"]; - }; - Service = { - ExecStart = let - script = pkgs.writeShellApplication { - name = "battery-notify"; - runtimeInputs = [ - pkgs.libnotify - pkgs.bc - pkgs.uutils-coreutils-noprefix - ]; - text = '' - now="$(cat ${cfg.device_now})" - full="$(cat ${cfg.device_full})" - - if (( $(bc -l <<< "($now / $full) * 100 < ${builtins.toString cfg.triggerLevel}") )); then - notify-send -u critical "Battery Low" "Please charge your battery" - fi - ''; - }; - in "${lib.getExe script}"; - }; - }; - - systemd.user.timers."battery-notify" = { - Unit.Description = "Notify when battery is low"; - Timer = { - OnCalendar = cfg.checkAt; - Persistent = true; - }; - Install.WantedBy = ["timers.target"]; - }; - }; -} diff --git a/nix/homeModules/common/firefox.nix b/nix/homeModules/common/firefox.nix index 49b09800..81e7b1bf 100644 --- a/nix/homeModules/common/firefox.nix +++ b/nix/homeModules/common/firefox.nix @@ -3,36 +3,24 @@ in { programs.firefox = { # https://mozilla.github.io/policy-templates + # The following have more complex logic, keep them as policies and not profiles policies = { + # Trans lations are of poor quality anyways + RequestedLocales = ["en-US"]; + SearchEngines = { Remove = ["Bing" "DuckDuckGo" "Qwant" "eBay"]; }; - HardwareAcceleration = true; - DisableFirefoxScreenshots = false; - DisablePocket = true; + NoDefaultBookmarks = true; DisplayMenuBar = "never"; DisplayBookmarksToolbar = "never"; - NoDefaultBookmarks = true; - OfferToSaveLogins = false; - OfferToSaveLoginsDefault = false; - PasswordManagerEnabled = false; - FirefoxHome = { - Search = true; - TopSites = true; - SponsoredTopSites = false; - Highlights = false; - Pocket = false; - SponsoredPocket = false; - }; - UserMessaging = { - ExtensionRecommendations = false; - SkipOnboarding = true; - }; DNSOverHTTPS = { Enabled = true; }; }; + # https://searchfox.org/mozilla-central/source/browser/components/enterprisepolicies/Policies.sys.mjs + # Some policies can be rewritten to profiles configuration profiles.default = { settings = { "toolkit.legacyUserProfileCustomizations.stylesheets" = true; @@ -40,6 +28,45 @@ in { "browser.ctrlTab.sortByRecentlyUsed" = false; "layout.css.devPixelsPerPx" = 1.1; "full-screen-api.ignore-widgets" = true; # limit fullscreen mode to window + + # Sponsored crap + # Yes + "browser.newtabpage.activity-stream.showSearch" = true; + "browser.newtabpage.activity-stream.feeds.topsites" = true; + # No + "browser.newtabpage.activity-stream.showSponsoredTopSites" = false; + "browser.newtabpage.activity-stream.feeds.section.highlights" = false; + "browser.newtabpage.activity-stream.feeds.system.topstories" = false; + "browser.newtabpage.activity-stream.feeds.section.topstories" = false; + "browser.newtabpage.activity-stream.showSponsored" = false; + + # URL + # Yes + "browser.urlbar.suggest.quicksuggest.nonsponsored" = true; + # No + "browser.urlbar.suggest.quicksuggest.sponsored" = false; + + # Pasword manager + "signon.rememberSignons" = false; + "services.passwordSavingEnabled" = false; + "pref.privacy.disable_button.view_passwords" = false; + + # Hardware acceleration + "layers.acceleration.disabled" = false; + + # Screenshot + "screenshots.browser.component.enabled" = true; + + # Recommendations + "browser.newtabpage.activity-stream.asrouter.userprefs.cfr.addons" = false; + "browser.newtabpage.activity-stream.asrouter.userprefs.cfr.features" = false; + "extensions.htmlaboutaddons.recommendations.enabled" = false; # Addons + + # Onboarding + "browser.aboutwelcome.enabled" = false; + + # AI crap + "browser.ml.chat.enabled" = false; }; extensions.packages = let @@ -47,6 +74,15 @@ in { in [ addons.ublock-origin addons.privacy-badger + + /* + Here's to you who want to remove news feed eradicator because you find it annoying: + It is here to annoy you so it is less likely for you to be on the agency inversion path. + DO NOT REMOVE IT. I repeat, DO NOT REMOVE IT. + + If you think it's annoying, go do some jump rope, sing, live. + */ + addons.news-feed-eradicator # did you read the comment above? addons.multi-account-containers ]; }; diff --git a/nix/homeModules/common/git.nix b/nix/homeModules/common/git.nix index a38485b7..aef38c0b 100644 --- a/nix/homeModules/common/git.nix +++ b/nix/homeModules/common/git.nix @@ -1,13 +1,24 @@ -{lib, ...}: { +{ + lib, + config, + ... +}: { # git plugins programs.git = { lfs.enable = true; - difftastic = { - enable = true; - enableAsDifftool = true; - }; + patdiff.enable = true; }; + # 懶惰鬼賴皮 + programs.lazygit = let + patdiffCfg = config.programs.git.patdiff; + in + lib.mkIf patdiffCfg.enable { + settings = { + git.paging.externalDiffCommand = "${lib.getExe' patdiffCfg.package "patdiff-git-wrapper"}"; + }; + }; + # git itself programs.git = { extraConfig = { diff --git a/nix/homeModules/common/neovim.nix b/nix/homeModules/common/neovim.nix deleted file mode 100644 index 6df8c118..00000000 --- a/nix/homeModules/common/neovim.nix +++ /dev/null @@ -1,17 +0,0 @@ -{ - pkgs, - lib, - config, - ... -}: let - cfg = config.programs.neovim; -in { - config = lib.mkIf cfg.enable { - home.packages = [ - # might be useful for servers, serves as minimal configuration - pkgs.nodePackages.bash-language-server - pkgs.shellcheck - pkgs.shfmt - ]; - }; -} diff --git a/nix/nixosModules/common/sudo-conf.nix b/nix/nixosModules/common/sudo-conf.nix index 788288c2..b31388f4 100644 --- a/nix/nixosModules/common/sudo-conf.nix +++ b/nix/nixosModules/common/sudo-conf.nix @@ -1,21 +1,5 @@ -{pkgs, ...}: { +{ security.sudo.extraConfig = '' Defaults lecture = always - Defaults lecture_file = ${pkgs.writeText "sudo_lecture_file" '' - λλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλ - - λλλλ - λλλ - λλλ - λλλ Beep Boop - λλλ Are you sure about this? - λ λλλ Think twice :3 - λ λλλ - λ λλλ - λ λλλ - λ λλλλ - - λλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλλ - ''} ''; } diff --git a/nix/overlays/agenix.nix b/nix/overlays/agenix.nix index 571e8ddf..952db8d7 100644 --- a/nix/overlays/agenix.nix +++ b/nix/overlays/agenix.nix @@ -1,5 +1,5 @@ let - sources = import ../sources.nix; + sources = import ../../npins; in final: _: { inherit (final.callPackage sources.agenix {}) agenix; diff --git a/nix/overlays/disko.nix b/nix/overlays/disko.nix index 9c2a41f0..7a7c539d 100644 --- a/nix/overlays/disko.nix +++ b/nix/overlays/disko.nix @@ -1,5 +1,5 @@ let - sources = import ../sources.nix; + sources = import ../../npins; in final: _: { disko = diff --git a/nix/overlays/fcitx5-table-extra-taiwanese.nix b/nix/overlays/fcitx5-table-extra-taiwanese.nix index 3fdad750..b24003f8 100644 --- a/nix/overlays/fcitx5-table-extra-taiwanese.nix +++ b/nix/overlays/fcitx5-table-extra-taiwanese.nix @@ -1,5 +1,5 @@ let - sources = import ../sources.nix; + sources = import ../../npins; in final: prev: { fcitx5-table-extra = prev.fcitx5-table-extra.overrideAttrs (oldAttrs: { diff --git a/nix/overlays/nil.nix b/nix/overlays/nil.nix index 778895ee..daca3bf1 100644 --- a/nix/overlays/nil.nix +++ b/nix/overlays/nil.nix @@ -1,6 +1,6 @@ # Run the one with my cool feature here for now let - sources = import ../sources.nix; + sources = import ../../npins; inherit (sources) nil; inherit (nil.repository) owner repo; in diff --git a/nix/overlays/nix-tree.nix b/nix/overlays/nix-tree.nix index 778eef6d..36c30bfe 100644 --- a/nix/overlays/nix-tree.nix +++ b/nix/overlays/nix-tree.nix @@ -1,7 +1,7 @@ # The one in nixpkgs doesn't work # Getting nix-tree: user error (Failed parsing nix path-info output.) let - sources = import ../sources.nix; + sources = import ../../npins; in final: _: { nix-tree = (import sources.nix-tree).packages.${final.system}.default; diff --git a/nix/overlays/nur.nix b/nix/overlays/nur.nix index 82cb25e6..57c2994f 100644 --- a/nix/overlays/nur.nix +++ b/nix/overlays/nur.nix @@ -1,5 +1,5 @@ let - sources = import ../sources.nix; + sources = import ../../npins; in _: prev: { nur = import sources.nur { diff --git a/nix/overlays/pin-emacs28.nix b/nix/overlays/pin-emacs28.nix index ef61a025..f37787d7 100644 --- a/nix/overlays/pin-emacs28.nix +++ b/nix/overlays/pin-emacs28.nix @@ -1,6 +1,6 @@ let - sources = import ../sources.nix; + sources = import ../../npins; in _: _: { - emacs28 = (import sources.pin-emacs28 {}).emacs; + unsafe-emacs28 = (import sources.pin-emacs28 {}).emacs; } diff --git a/nix/overlays/pin-isabelle-2023.nix b/nix/overlays/pin-isabelle-2023.nix index 121e95c0..38a100c5 100644 --- a/nix/overlays/pin-isabelle-2023.nix +++ b/nix/overlays/pin-isabelle-2023.nix @@ -1,5 +1,5 @@ let - sources = import ../sources.nix; + sources = import ../../npins; in _: _: { # Isabelle version 2023 diff --git a/nix/overlays/pin-wireshark.nix b/nix/overlays/pin-wireshark.nix index f56c1258..dd9c800a 100644 --- a/nix/overlays/pin-wireshark.nix +++ b/nix/overlays/pin-wireshark.nix @@ -1,5 +1,5 @@ let - sources = import ../sources.nix; + sources = import ../../npins; in _: _: { # Wireshark bug diff --git a/nix/overlays/wallpapers.nix b/nix/overlays/wallpapers.nix index ed6018c9..0545f74e 100644 --- a/nix/overlays/wallpapers.nix +++ b/nix/overlays/wallpapers.nix @@ -1,5 +1,5 @@ let - sources = import ../sources.nix; + sources = import ../../npins; in _: _: { wallpapers = import sources.wallpapers {}; diff --git a/nix/overlays/wired-notify.nix b/nix/overlays/wired-notify.nix index 1d1a7081..2e158aa5 100644 --- a/nix/overlays/wired-notify.nix +++ b/nix/overlays/wired-notify.nix @@ -1,4 +1,4 @@ let - sources = import ../sources.nix; + sources = import ../../npins; in (import sources.wired-notify).overlays.default diff --git a/nix/packages/default.nix b/nix/packages/default.nix index a56b9e65..62311f0f 100644 --- a/nix/packages/default.nix +++ b/nix/packages/default.nix @@ -1,4 +1,4 @@ -{sources ? import ../sources.nix}: let +{sources ? import ../../npins}: let scopeOverlay = overlay: final: prev: {export = prev.export or {} // overlay final prev;}; in ( diff --git a/nix/sources.nix b/nix/sources.nix deleted file mode 100644 index fa4ff0b5..00000000 --- a/nix/sources.nix +++ /dev/null @@ -1,2 +0,0 @@ -# Compatibility shim that redirects to npins -import ../npins diff --git a/npins/sources.json b/npins/sources.json index 24b7faf6..3c5cfd5d 100644 --- a/npins/sources.json +++ b/npins/sources.json @@ -84,13 +84,13 @@ "repo": "lix" }, "pre_releases": false, - "version_upper_bound": "2.93.1", + "version_upper_bound": null, "release_prefix": null, "submodules": false, - "version": "2.93.0", - "revision": "47aad376c87e2e65967f17099277428e4b3f8e5a", - "url": "https://git.lix.systems/api/v1/repos/lix-project/lix/archive/2.93.0.tar.gz", - "hash": "0g17i8yz5j0i2v29c2fddksvnc5n8fc5ml2pz0jhxaia7ghmxhc6" + "version": "2.93.2", + "revision": "22be6ff62626c8cdbb9cdb59a3e4bd910fedd0d6", + "url": "https://git.lix.systems/api/v1/repos/lix-project/lix/archive/2.93.2.tar.gz", + "hash": "10pr6xp2m3fmnhywakv9msb33gllkr85qi0bl40wlgn7hlp9r317" }, "lix-module": { "type": "GitRelease", @@ -118,9 +118,9 @@ }, "branch": "main", "submodules": false, - "revision": "4e5ac6ec65c775fbc6adba1c6022b29c7eccde0f", - "url": "https://github.com/oxalica/nil/archive/4e5ac6ec65c775fbc6adba1c6022b29c7eccde0f.tar.gz", - "hash": "0fvkmiipmswzhak0n0hf472q5rw4k7iankv40g89ilw6ra8zwrn2" + "revision": "b043bfe1f3f4c4be4b688e24c5ae96e81f525805", + "url": "https://github.com/oxalica/nil/archive/b043bfe1f3f4c4be4b688e24c5ae96e81f525805.tar.gz", + "hash": "0jpdb5wpk6jc4b2smi7wvjrjjbi2l6r3yi95wz3jsr12xzbs0xnd" }, "nix-tree": { "type": "GitRelease", @@ -160,9 +160,9 @@ }, "branch": "nixos-25.05", "submodules": false, - "revision": "a676066377a2fe7457369dd37c31fd2263b662f4", - "url": "https://github.com/NixOS/nixpkgs/archive/a676066377a2fe7457369dd37c31fd2263b662f4.tar.gz", - "hash": "17vgcpydmk9qw2knszsdnnnh4zfxd2x7jpgifkkkz2rdg8bcwvyd" + "revision": "b43c397f6c213918d6cfe6e3550abfe79b5d1c51", + "url": "https://github.com/NixOS/nixpkgs/archive/b43c397f6c213918d6cfe6e3550abfe79b5d1c51.tar.gz", + "hash": "1dkp9sxci4b4f111x0ck493fiag68qjs5c927khzcj2a5pdbsayl" }, "nur": { "type": "Git", @@ -173,9 +173,9 @@ }, "branch": "main", "submodules": false, - "revision": "00b0005dbbb931014fdfe55d0db1f47af4f9aab5", - "url": "https://github.com/nix-community/nur/archive/00b0005dbbb931014fdfe55d0db1f47af4f9aab5.tar.gz", - "hash": "0lrdcaayxifnq2n4sza7sma0w8rqghc7rkb3ly1n7rdnrbmn3f8b" + "revision": "c41210bd9aea6b7cd8fea393385bef84ee1355e8", + "url": "https://github.com/nix-community/nur/archive/c41210bd9aea6b7cd8fea393385bef84ee1355e8.tar.gz", + "hash": "0lc3rzqspf9lz7fx4xb8k6690bf0hxdam51nlfckf4llx523vl9w" }, "pin-emacs28": { "type": "Git", diff --git a/shell.nix b/shell.nix index 437a936a..019d92c8 100644 --- a/shell.nix +++ b/shell.nix @@ -1,5 +1,5 @@ { - sources ? import ./nix/sources.nix, + sources ? import ./npins, pkgs ? import sources.nixpkgs { overlays = map import [ @@ -7,26 +7,24 @@ ./nix/packages/overlay.nix ]; }, -}: rec { - default = pkgs.mkShell { - packages = with pkgs; [ - just - jq - npins - disko - ]; - }; - - withXMonad = pkgs.mkShell { - inputsFrom = with pkgs; [ - default - - (haskellPackages.ghcWithPackages (self: [ - self.xmonad-contrib - self.xmonad-extras - ])) - haskell-language-server - cabal-install - ]; - }; -} + withXMonad ? false, +}: let + inherit (pkgs) lib; +in + pkgs.mkShell { + packages = with pkgs; + [ + just + jq + npins + disko + ] + ++ lib.optionals withXMonad [ + (haskellPackages.ghcWithPackages (self: [ + self.xmonad-contrib + self.xmonad-extras + ])) + haskell-language-server + cabal-install + ]; + }