Merge remote-tracking branch 'refs/remotes/origin/nixos' into nixos

nixos
Moritz Böhme 2024-03-21 18:52:56 +01:00
commit ac9b136e6c
Signed by: moritz
GPG Key ID: 970C6E89EB0547A9
14 changed files with 270 additions and 128 deletions

View File

@ -715,6 +715,21 @@
"type": "github" "type": "github"
} }
}, },
"nix-filter": {
"locked": {
"lastModified": 1705332318,
"narHash": "sha256-kcw1yFeJe9N4PjQji9ZeX47jg0p9A0DuU4djKvg1a7I=",
"owner": "numtide",
"repo": "nix-filter",
"rev": "3449dc925982ad46246cfc36469baf66e1b64f17",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "nix-filter",
"type": "github"
}
},
"nix-index-database": { "nix-index-database": {
"inputs": { "inputs": {
"nixpkgs": [ "nixpkgs": [
@ -750,6 +765,27 @@
"url": "https://git.moritzboeh.me/moritz/NixLazy.nvim" "url": "https://git.moritzboeh.me/moritz/NixLazy.nvim"
} }
}, },
"nix-monitored": {
"inputs": {
"nix-filter": "nix-filter",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1708169437,
"narHash": "sha256-qR3UF6xf+ts/lCY2UlacKtNzZq/9jxsgsdXxiQ5gcPU=",
"owner": "ners",
"repo": "nix-monitored",
"rev": "382ed0cad468cb0b5426bf0905da573efa96c218",
"type": "github"
},
"original": {
"owner": "ners",
"repo": "nix-monitored",
"type": "github"
}
},
"nix-super": { "nix-super": {
"inputs": { "inputs": {
"flake-compat": "flake-compat_2", "flake-compat": "flake-compat_2",
@ -1013,38 +1049,6 @@
"type": "github" "type": "github"
} }
}, },
"nvim-puppeteer": {
"flake": false,
"locked": {
"lastModified": 1710266483,
"narHash": "sha256-rRsLPeLaJNvOxzwGO+LOXW8FMhHpVkjuccTZdaK3O7c=",
"owner": "chrisgrieser",
"repo": "nvim-puppeteer",
"rev": "ea340595967919222f3ba5c6c6def0787a336c82",
"type": "github"
},
"original": {
"owner": "chrisgrieser",
"repo": "nvim-puppeteer",
"type": "github"
}
},
"nvim-treesitter": {
"flake": false,
"locked": {
"lastModified": 1711032686,
"narHash": "sha256-jkZ8NuCUjUqHmpr8v1g/dbPDBTO6WRWmEhEJHY9HZWM=",
"owner": "nvim-treesitter",
"repo": "nvim-treesitter",
"rev": "722617e6726c1508adadf83d531f54987c703be0",
"type": "github"
},
"original": {
"owner": "nvim-treesitter",
"repo": "nvim-treesitter",
"type": "github"
}
},
"pre-commit-hooks": { "pre-commit-hooks": {
"inputs": { "inputs": {
"flake-compat": "flake-compat_3", "flake-compat": "flake-compat_3",
@ -1088,13 +1092,12 @@
"neovim-nightly-overlay": "neovim-nightly-overlay", "neovim-nightly-overlay": "neovim-nightly-overlay",
"nix-index-database": "nix-index-database", "nix-index-database": "nix-index-database",
"nix-lazy-nvim": "nix-lazy-nvim", "nix-lazy-nvim": "nix-lazy-nvim",
"nix-monitored": "nix-monitored",
"nix-super": "nix-super", "nix-super": "nix-super",
"nixpkgs": "nixpkgs_7", "nixpkgs": "nixpkgs_7",
"none-ls-nvim": "none-ls-nvim", "none-ls-nvim": "none-ls-nvim",
"nur": "nur", "nur": "nur",
"nvim-lspconfig": "nvim-lspconfig", "nvim-lspconfig": "nvim-lspconfig",
"nvim-puppeteer": "nvim-puppeteer",
"nvim-treesitter": "nvim-treesitter",
"pre-commit-hooks": "pre-commit-hooks", "pre-commit-hooks": "pre-commit-hooks",
"smartcolumn-nvim": "smartcolumn-nvim", "smartcolumn-nvim": "smartcolumn-nvim",
"stable": "stable", "stable": "stable",

View File

@ -22,6 +22,8 @@
# Programs # Programs
nix-super.url = "github:privatevoid-net/nix-super"; nix-super.url = "github:privatevoid-net/nix-super";
nix-monitored.url = "github:ners/nix-monitored";
nix-monitored.inputs.nixpkgs.follows = "nixpkgs";
timers.url = "git+https://gitea.moritzboeh.me/moritz/timers.git"; timers.url = "git+https://gitea.moritzboeh.me/moritz/timers.git";
# Neovim # Neovim
@ -31,10 +33,6 @@
nix-lazy-nvim.url = "git+https://git.moritzboeh.me/moritz/NixLazy.nvim"; nix-lazy-nvim.url = "git+https://git.moritzboeh.me/moritz/NixLazy.nvim";
nvim-lspconfig.flake = false; nvim-lspconfig.flake = false;
nvim-lspconfig.url = "github:neovim/nvim-lspconfig"; nvim-lspconfig.url = "github:neovim/nvim-lspconfig";
nvim-puppeteer.flake = false;
nvim-puppeteer.url = "github:chrisgrieser/nvim-puppeteer";
nvim-treesitter.flake = false;
nvim-treesitter.url = "github:nvim-treesitter/nvim-treesitter";
smartcolumn-nvim.flake = false; smartcolumn-nvim.flake = false;
smartcolumn-nvim.url = "github:m4xshen/smartcolumn.nvim"; smartcolumn-nvim.url = "github:m4xshen/smartcolumn.nvim";
telekasten-nvim.flake = false; telekasten-nvim.flake = false;

View File

@ -19,6 +19,7 @@
gaming.enable = true; gaming.enable = true;
personal.enable = true; personal.enable = true;
impermanence.enable = true; impermanence.enable = true;
webis.enable = true;
}; };
programs.hyprland = { programs.hyprland = {
nvidiaSupport = true; nvidiaSupport = true;
@ -26,9 +27,8 @@
extraConfig = "exec=hyprctl keyword monitor HDMI-A-1,3840x2160@120,auto,1.2"; extraConfig = "exec=hyprctl keyword monitor HDMI-A-1,3840x2160@120,auto,1.2";
keyboardLayouts = [ "us" "de" ]; keyboardLayouts = [ "us" "de" ];
}; };
programs.exercism.enable = true;
services.wallpaper.enable = true; services.wallpaper.enable = true;
services.ollama.enable = true;
programs.ledger.enable = true;
}; };
home-manager.users.moritz.home.packages = with pkgs; [ home-manager.users.moritz.home.packages = with pkgs; [

View File

@ -44,7 +44,7 @@ let
gi = pkgs.writeFishApplication { gi = pkgs.writeFishApplication {
name = "gi"; name = "gi";
runtimeInputs = with pkgs; [ fzf gum curl ]; runtimeInputs = with pkgs; [ fzf gum curl coreutils-full ];
text = /* fish */ '' text = /* fish */ ''
set url https://www.gitignore.io/api set url https://www.gitignore.io/api
@ -57,10 +57,12 @@ let
set choice (string join "," $argv[1..]) set choice (string join "," $argv[1..])
end end
set contents "$(curl -sL $url/$choice | head -n -2 | tail -n +4)"
if gum confirm "Overwrite current .gitignore?" if gum confirm "Overwrite current .gitignore?"
curl -sL $url/$choice > .gitignore echo "$contents" > .gitignore
else else
curl -sL $url/$choice >> .gitignore echo "$contents" >> .gitignore
end end
''; '';
completions = /* fish */ '' completions = /* fish */ ''

View File

@ -90,6 +90,19 @@ in
stable.texlive.combined.scheme-full # NOTE breaks often stable.texlive.combined.scheme-full # NOTE breaks often
thunderbird thunderbird
vlc vlc
(symlinkJoin {
name = "obsidian-wayland";
paths = [ obsidian ];
nativeBuildInputs = [ makeWrapper ];
postBuild = ''
wrapProgram $out/bin/obsidian \
--add-flags "--socket=wayland --enable-features=UseOzonePlatform --ozone-platform=wayland"
'';
})
];
nixpkgs.config.permittedInsecurePackages = [
"electron-25.9.0" # obsidian
]; ];
programs.nix-ld.enable = true; programs.nix-ld.enable = true;

View File

@ -1,6 +1,5 @@
{ config { config
, lib , lib
, pkgs
, ... , ...
}: }:
@ -50,21 +49,23 @@ in
userName = cfg.identity.name; userName = cfg.identity.name;
userEmail = cfg.identity.email; userEmail = cfg.identity.email;
extraConfig = { extraConfig = {
commit.verbose = true;
diff.algorithm = "histogram";
fetch.fsckobjects = true;
init.defaultBranch = "main"; init.defaultBranch = "main";
merge.conflictstyle = "zdiff3"; merge.conflictstyle = "zdiff3";
diff.external = getExe pkgs.difftastic;
push.autoSetupRemote = true; push.autoSetupRemote = true;
receive.fsckObjects = true;
transfer.fsckobjects = true;
}; };
signing = mkIf cfg.signing { signing = mkIf cfg.signing {
key = "0x970C6E89EB0547A9"; key = "0x970C6E89EB0547A9";
signByDefault = true; signByDefault = true;
}; };
lfs.enable = true; lfs.enable = true;
delta.enable = true;
}; };
}; };
programs.git = { programs.git.enable = true;
enable = true;
config.safe.directory = "/home/moritz/.dotfiles";
};
}; };
} }

View File

@ -9,6 +9,23 @@
with lib; with lib;
let let
cfg = config.my.programs.nix; cfg = config.my.programs.nix;
mkSuper = system: nix:
if cfg.useSuper
then inputs.nix-super.packages.${system}.default
else nix;
mkNom = system: nix:
if cfg.useNom
then
inputs.nix-monitored.packages.${system}.default.override
{
withNotify = false;
nix = nix;
}
else nix;
mkNix = system: nix: mkNom system (mkSuper system nix);
in in
{ {
options.my.programs.nix = { options.my.programs.nix = {
@ -21,48 +38,65 @@ in
}; };
}; };
optimise.enable = mkEnableOption "nix-optimise"; optimise.enable = mkEnableOption "nix-optimise";
useSuper = mkEnableOption "use nix super" // { default = true; };
useNom = mkEnableOption "use nix output monitor by default" // { default = true; };
}; };
config.nix = { config = {
nixPath = [ "nixpkgs=${inputs.nixpkgs}" ]; my.nixpkgs.overlays = [
(final: prev:
{
nixos-rebuild = prev.nixos-rebuild.override {
nix = mkNom final.system final.nix;
};
})
];
package = inputs.nix-super.packages.${pkgs.system}.default; home-manager.users.moritz.programs.direnv.nix-direnv.package = pkgs.nix-direnv.override {
nix = config.nix.package;
extraOptions = "experimental-features = nix-command flakes";
gc = {
automatic = cfg.gc.enable;
options = "--max-freed ${cfg.gc.minimumFreedGB} --delete-older-than 14d";
dates = "weekly";
}; };
optimise = { nix = {
automatic = cfg.optimise.enable; nixPath = [ "nixpkgs=${inputs.nixpkgs}" ];
dates = [ "weekly" ];
};
registry = { package = mkNix pkgs.system pkgs.nix;
master-upstream.to = {
type = "github"; extraOptions = "experimental-features = nix-command flakes";
owner = "nixos";
repo = "nixpkgs"; gc = {
automatic = cfg.gc.enable;
options = "--max-freed ${cfg.gc.minimumFreedGB} --delete-older-than 14d";
dates = "weekly";
}; };
master.flake = inputs.master;
nixpkgs.flake = inputs.nixpkgs;
stable.flake = inputs.stable;
dotfiles.flake = self;
default.flake = self;
};
settings = { optimise = {
substituters = [ automatic = cfg.optimise.enable;
"https://cache.nixos.org/" dates = [ "weekly" ];
]; };
trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
];
trusted-users = [ "root" "@wheel" ]; registry = {
master-upstream.to = {
type = "github";
owner = "nixos";
repo = "nixpkgs";
};
master.flake = inputs.master;
nixpkgs.flake = inputs.nixpkgs;
stable.flake = inputs.stable;
dotfiles.flake = self;
default.flake = self;
};
settings = {
substituters = [
"https://cache.nixos.org/"
];
trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
];
trusted-users = [ "root" "@wheel" ];
};
}; };
}; };
} }

View File

@ -10,26 +10,6 @@ in
options.my.programs.nvim.enable = mkEnableOption "nvim"; options.my.programs.nvim.enable = mkEnableOption "nvim";
config = mkIf cfg.enable { config = mkIf cfg.enable {
my.nixpkgs.overlays = [
(
_: prev:
with lib.my;
{
vimPlugins = prev.vimPlugins // {
nvim-treesitter = prev.vimPlugins.nvim-treesitter.overrideAttrs (_: {
version = mkVersionInput inputs.nvim-treesitter;
src = inputs.nvim-treesitter;
});
# HACK: to fix error in nixpkgs version of nvim-lspconfig
nvim-lspconfig = prev.vimPlugins.nvim-lspconfig.overrideAttrs (_: {
version = mkVersionInput inputs.nvim-lspconfig;
src = inputs.nvim-lspconfig;
});
};
}
)
];
home-manager.users.moritz = { home-manager.users.moritz = {
xdg.configFile."nvim/snippets" = { xdg.configFile."nvim/snippets" = {
recursive = true; recursive = true;

View File

@ -98,7 +98,10 @@ with builtins;
lazy = false; lazy = false;
} }
{ {
plugin = nvim-lspconfig; plugin = pkgs.vimPlugins.nvim-lspconfig.overrideAttrs (_: {
version = lib.my.mkVersionInput inputs.nvim-lspconfig;
src = inputs.nvim-lspconfig;
});
event = [ "BufRead" "BufNewFile" ]; event = [ "BufRead" "BufNewFile" ];
conf = readFile ./lua/nvim-lspconfig.lua; conf = readFile ./lua/nvim-lspconfig.lua;
dependencies = [ dependencies = [
@ -266,14 +269,6 @@ with builtins;
} }
]; ];
} }
{
plugin = pkgs.vimUtils.buildVimPlugin {
pname = "nvim-puppeteer";
version = lib.my.mkVersionInput inputs.nvim-puppeteer;
src = inputs.nvim-puppeteer;
};
lazy = false; # NOTE: plugin lazy-loads itself.
}
{ {
plugin = conform-nvim; plugin = conform-nvim;
keys = [ keys = [

View File

@ -11,10 +11,19 @@ local formatters_by_ft = {
sh = { "shfmt" }, sh = { "shfmt" },
toml = { "taplo" }, toml = { "taplo" },
yaml = { "yamlfix" }, yaml = { "yamlfix" },
gleam = { "gleam" },
} }
conform.setup({ conform.setup({
formatters_by_ft = formatters_by_ft, formatters_by_ft = formatters_by_ft,
formatters = {
gleam = {
command = "gleam",
args = { "format", "--stdin" },
stdin = true,
cwd = require("conform.util").root_file({ "gleam.toml" }),
},
},
}) })
vim.api.nvim_create_user_command("Format", function(opts) vim.api.nvim_create_user_command("Format", function(opts)

View File

@ -28,7 +28,7 @@ cmp.setup({
["<Tab>"] = cmp.mapping(function(fallback) ["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_next_item({ behavior = cmp.SelectBehavior.Select }) cmp.select_next_item({ behavior = cmp.SelectBehavior.Select })
elseif luasnip.jumpable(1) then elseif luasnip.locally_jumpable(1) then
luasnip.jump(1) luasnip.jump(1)
else else
fallback() fallback()
@ -37,7 +37,7 @@ cmp.setup({
["<S-Tab>"] = cmp.mapping(function(fallback) ["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then if cmp.visible() then
cmp.select_prev_item({ behavior = cmp.SelectBehavior.Select }) cmp.select_prev_item({ behavior = cmp.SelectBehavior.Select })
elseif luasnip.jumpable(-1) then elseif luasnip.locally_jumpable(-1) then
luasnip.jump(-1) luasnip.jump(-1)
else else
fallback() fallback()

View File

@ -130,6 +130,7 @@ local servers = {
"gopls", "gopls",
"nil_ls", "nil_ls",
"nixd", "nixd",
"pylsp",
"ruff_lsp", "ruff_lsp",
"templ", "templ",
"typst_lsp", "typst_lsp",
@ -150,18 +151,6 @@ lspconfig_setup("tailwindcss", {
init_options = { userLanguages = { templ = "html" } }, init_options = { userLanguages = { templ = "html" } },
}) })
lspconfig_setup("pylsp", {
settings = {
pylsp = {
plugins = {
rope_autoimport = {
enabled = true,
},
},
},
},
})
lspconfig_setup("rust_analyzer", { lspconfig_setup("rust_analyzer", {
settings = { settings = {
["rust-analyzer"] = { ["rust-analyzer"] = {

View File

@ -0,0 +1,120 @@
local ls = require("luasnip")
local s = ls.snippet
local sn = ls.snippet_node
local isn = ls.indent_snippet_node
local t = ls.text_node
local i = ls.insert_node
local f = ls.function_node
local c = ls.choice_node
local d = ls.dynamic_node
local r = ls.restore_node
local events = require("luasnip.util.events")
local ai = require("luasnip.nodes.absolute_indexer")
local extras = require("luasnip.extras")
local l = extras.lambda
local rep = extras.rep
local p = extras.partial
local m = extras.match
local n = extras.nonempty
local dl = extras.dynamic_lambda
local fmt = require("luasnip.extras.fmt").fmt
local fmta = require("luasnip.extras.fmt").fmta
local conds = require("luasnip.extras.expand_conditions")
local postfix = require("luasnip.extras.postfix").postfix
local types = require("luasnip.util.types")
local parse = require("luasnip.util.parser").parse_snippet
local ms = ls.multi_snippet
local k = require("luasnip.nodes.key_indexer").new_key
local matches = require("luasnip.extras.postfix").matches
local case_template = [[
case {expression} {{
{pattern1} -> {result1}
{pattern2} -> {result2}{final}
}}
]]
local dot_case = postfix({ filetype = "gleam", trig = ".case", match_pattern = matches.line }, {
d(1, function(_, parent)
return sn(
1,
fmt(case_template, {
expression = t(parent.env.POSTFIX_MATCH),
pattern1 = i(1, "pattern"),
result1 = i(2, "todo"),
pattern2 = i(3, "_"),
result2 = i(4, "todo"),
final = i(0),
})
)
end),
})
local case = s(
{ filetype = "gleam", trig = "case" },
fmt(case_template, {
expression = i(1),
pattern1 = i(2),
result1 = i(3, "todo"),
pattern2 = i(4, "_"),
result2 = i(5, "todo"),
final = i(0),
})
)
local fn_template = [[
fn {name}({args}) -> {rtype} {{
{body}
}}
]]
local fn = s(
{ filetype = "gleam", trig = "fn" },
fmt(fn_template, {
name = i(1),
args = i(2),
rtype = i(3),
body = i(0),
})
)
local pfn = s(
{ filetype = "gleam", trig = "pfn" },
fmt("pub " .. fn_template, {
name = i(1),
args = i(2),
rtype = i(3),
body = i(0),
})
)
local type_template = [[
type {name} {{
{body}
}}
]]
local type = s(
{ filetype = "gleam", trig = "type" },
fmt(type_template, {
name = i(1),
body = i(0),
})
)
local ptype = s(
{ filetype = "gleam", trig = "ptype" },
fmt("pub " .. type_template, {
name = i(1),
body = i(0),
})
)
return {
case,
dot_case,
fn,
pfn,
type,
ptype,
}

View File

@ -56,9 +56,7 @@ with builtins;
require('nvim-treesitter.configs').setup(final_opts) require('nvim-treesitter.configs').setup(final_opts)
''; '';
init = '' init = ''
local runtimepath = vim.opt.runtimepath:get() vim.opt.runtimepath:prepend("${parserDir}")
table.insert(runtimepath, 4, "${parserDir}")
vim.opt.runtimepath = runtimepath
''; '';
priority = 100; priority = 100;
dependencies = [ dependencies = [