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

This commit is contained in:
Moritz Böhme 2024-03-21 18:52:56 +01:00
commit ac9b136e6c
No known key found for this signature in database
GPG key ID: 970C6E89EB0547A9
14 changed files with 270 additions and 128 deletions

View file

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

View file

@ -90,6 +90,19 @@ in
stable.texlive.combined.scheme-full # NOTE breaks often
thunderbird
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;

View file

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

View file

@ -9,6 +9,23 @@
with lib;
let
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
{
options.my.programs.nix = {
@ -21,48 +38,65 @@ in
};
};
optimise.enable = mkEnableOption "nix-optimise";
useSuper = mkEnableOption "use nix super" // { default = true; };
useNom = mkEnableOption "use nix output monitor by default" // { default = true; };
};
config.nix = {
nixPath = [ "nixpkgs=${inputs.nixpkgs}" ];
config = {
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;
extraOptions = "experimental-features = nix-command flakes";
gc = {
automatic = cfg.gc.enable;
options = "--max-freed ${cfg.gc.minimumFreedGB} --delete-older-than 14d";
dates = "weekly";
home-manager.users.moritz.programs.direnv.nix-direnv.package = pkgs.nix-direnv.override {
nix = config.nix.package;
};
optimise = {
automatic = cfg.optimise.enable;
dates = [ "weekly" ];
};
nix = {
nixPath = [ "nixpkgs=${inputs.nixpkgs}" ];
registry = {
master-upstream.to = {
type = "github";
owner = "nixos";
repo = "nixpkgs";
package = mkNix pkgs.system pkgs.nix;
extraOptions = "experimental-features = nix-command flakes";
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 = {
substituters = [
"https://cache.nixos.org/"
];
trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
];
optimise = {
automatic = cfg.optimise.enable;
dates = [ "weekly" ];
};
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";
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 = {
xdg.configFile."nvim/snippets" = {
recursive = true;

View file

@ -98,7 +98,10 @@ with builtins;
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" ];
conf = readFile ./lua/nvim-lspconfig.lua;
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;
keys = [

View file

@ -11,10 +11,19 @@ local formatters_by_ft = {
sh = { "shfmt" },
toml = { "taplo" },
yaml = { "yamlfix" },
gleam = { "gleam" },
}
conform.setup({
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)

View file

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

View file

@ -130,6 +130,7 @@ local servers = {
"gopls",
"nil_ls",
"nixd",
"pylsp",
"ruff_lsp",
"templ",
"typst_lsp",
@ -150,18 +151,6 @@ lspconfig_setup("tailwindcss", {
init_options = { userLanguages = { templ = "html" } },
})
lspconfig_setup("pylsp", {
settings = {
pylsp = {
plugins = {
rope_autoimport = {
enabled = true,
},
},
},
},
})
lspconfig_setup("rust_analyzer", {
settings = {
["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)
'';
init = ''
local runtimepath = vim.opt.runtimepath:get()
table.insert(runtimepath, 4, "${parserDir}")
vim.opt.runtimepath = runtimepath
vim.opt.runtimepath:prepend("${parserDir}")
'';
priority = 100;
dependencies = [