Merge remote-tracking branch 'origin/nixos' into nixos-work

This commit is contained in:
Moritz Böhme 2023-08-01 09:32:01 +02:00
commit 755e406dda
45 changed files with 811 additions and 498 deletions

View file

@ -14,6 +14,18 @@ let
'';
};
nom-system-command = command: "${nom-system}/bin/nom-system && ${command}";
f = pkgs.writeFishApplication {
name = "f";
runtimeInputs = with pkgs; [ fzf bat ];
text = ''
#!/usr/bin/env fish
fzf --query "$argv" --multi --bind "enter:become($EDITOR {+})" --preview "bat --color=always --style=header,grid --line-range :500 {+}"
'';
completions = ''
complete -c f
'';
};
in
{
users.users.moritz = {
@ -58,7 +70,6 @@ in
fish.enable = true;
git.enable = true;
gpg.enable = true;
navi.enable = true;
nix = {
gc.enable = true;
optimise.enable = true;
@ -116,6 +127,7 @@ in
viu
wget
vim
f
];
fonts.fonts = with pkgs; [
@ -152,6 +164,7 @@ in
enable = true;
defaultOptions = [
"--height 50%"
"--bind alt-j:preview-down,alt-k:preview-up"
];
};
zoxide.enable = true;

View file

@ -36,7 +36,25 @@ in
nix-edit.enable = mkDefault true;
nvim.enable = mkDefault true;
python.versions."311".enable = mkDefault true;
spotify.enable = mkDefault true;
spotify-player = {
enable = mkDefault true;
package = pkgs.spotify-player.overrideAttrs (old: {
buildFeatures = lib.lists.remove "notify" (old.buildFeatures or [ ]);
});
config = {
client_id = "3172dbeaf64949728920c58b823bc24b";
copy_command = {
command = "wl-copy";
args = [ ];
};
enable_cover_image_cache = true;
default_device = "spotify-player-daemon";
enable_streaming = false;
playback_window_position = "Bottom";
cover_img_length = 20;
cover_img_width = 10;
};
};
ssh.enable = mkDefault true;
thunar.enable = mkDefault true;
wallpaper.enable = mkDefault true;
@ -47,6 +65,19 @@ in
gammastep.enable = true;
kdeconnect.enable = mkDefault true;
printing.enable = true;
spotify-player = {
enable = mkDefault true;
config = {
client_id = "3172dbeaf64949728920c58b823bc24b";
device = {
name = "spotify-player-daemon";
device_type = "computer";
volume = 70;
bitrate = 320;
audio_cache = true;
};
};
};
wireguard.enable = true;
};
};
@ -75,6 +106,7 @@ in
};
services = {
illum.enable = true;
resolved.enable = true;
gnome.gnome-keyring.enable = true;
pipewire = {
enable = true;

View file

@ -13,7 +13,6 @@ in
config = mkIf cfg.enable {
my = {
programs = {
code.enable = mkDefault true;
ssh.enable = mkForce false;
git.identity.email = mkDefault "moritz.boehme@l.de";
hyprland = {
@ -21,7 +20,7 @@ in
};
miracast.enable = mkDefault true;
python.versions = {
"38".enable = mkDefault true;
# "38".enable = mkDefault true;
"310".enable = mkDefault true;
"311".enable = mkDefault true;
};

View file

@ -38,7 +38,6 @@ in
wallpaper.enable = true;
kitty.enable = true;
rofi.enable = true;
};
wallpapers.enable = true;
services.dunst.enable = true;

View file

@ -48,9 +48,9 @@ let
listToStringMultiLine id
([
"dir = ${quote plugin}"
"name = ${quote plugin.name}"
"lazy = ${boolToString lazy}"
"name = ${quote (getName plugin)}"
]
++ (optional (lazy != null) "lazy = ${boolToString lazy}")
++ (optional (!enabled) "enabled = ${boolToString enabled}")
++ (optional (dependencies != [ ]) "dependencies = ${listToStringMultiLine id (map lazySpecFromPlugin dependencies)}")
++ (optional (init != null) "init = function(plugin)\n${toString init}\nend")
@ -59,7 +59,7 @@ let
++ (optional (event != [ ]) "event = ${listToStringOneLine quote event}")
++ (optional (cmd != [ ]) "cmd = ${listToStringOneLine quote cmd}")
++ (optional (ft != [ ]) "ft = ${listToStringOneLine quote ft}")
++ (optional (priority != 50) "priority = ${toString priority}")
++ (optional (priority != null) "priority = ${toString priority}")
);
lazySpecs = listToStringMultiLine id (map lazySpecFromPlugin cfg.plugins);
lazy = ''
@ -86,7 +86,7 @@ in
type = nullOr str;
default = null;
description = ''
Lua code to be executed when the plugin is loaded.
Lua function to be executed when the plugin is loaded.
'';
};
dependencies = mkOption {
@ -111,8 +111,8 @@ in
'';
};
lazy = mkOption {
type = bool;
default = true;
type = nullOr bool;
default = null;
description = ''
Whether to load the plugin lazily.
'';
@ -145,8 +145,8 @@ in
'';
};
priority = mkOption {
type = int;
default = 50;
type = nullOr int;
default = null;
description = ''
Priority to load the plugin.
'';
@ -222,27 +222,35 @@ in
withNodeJs = true;
withPython3 = true;
extraLuaConfig = lib.concatLines [ (builtins.readFile ./options.lua) lazy ];
extraPackages = with pkgs; [
alejandra
black
deadnix
isort
jq
nil
nixpkgs-fmt
nodePackages.bash-language-server
nodePackages.cspell
rustfmt
shellcheck
shfmt
statix
stylua
sumneko-lua-language-server
taplo
typst
typst-lsp
yamlfmt
];
extraPython3Packages = ps:
let
plugins = map (getAttr "plugin") cfg.plugins;
depAttrName = "python3Dependencies";
filtered = filter (hasAttr depAttrName) plugins;
funcs = map (getAttr depAttrName) filtered;
in
foldl (list: f: list ++ (f ps)) [ ] funcs;
extraPackages = with pkgs;
[
alejandra
black
deadnix
isort
jq
nil
nixpkgs-fmt
nodePackages.bash-language-server
rustfmt
shellcheck
shfmt
statix
stylua
sumneko-lua-language-server
taplo
typst
typst-lsp
yamlfmt
];
plugins = [
pkgs.vimPlugins.lazy-nvim
];

View file

@ -10,6 +10,7 @@ require("catppuccin").setup({
enabled = true,
},
treesitter = true,
telekasten = true,
telescope = true,
lsp_trouble = true,
which_key = true,

View file

@ -0,0 +1,2 @@
-- dont show ghost text
vim.g.codeium_render = false

View file

@ -0,0 +1,3 @@
vim.g.coq_settings = {
auto_start = "shut-up",
}

View file

@ -0,0 +1,4 @@
require("coq_3p")({
{ src = "orgmode", short_name = "ORG" },
{ src = "codeium", short_name = "COD" },
})

View file

@ -31,7 +31,6 @@ with builtins;
{ plugin = nvim-web-devicons; }
];
}
{ plugin = nvim-ts-context-commentstring; }
{
plugin = mini-nvim;
lazy = false;
@ -82,28 +81,6 @@ with builtins;
{ plugin = nvim-web-devicons; }
];
}
{
plugin = nvim-cmp;
conf = readFile ./nvim-cmp.lua;
event = [ "InsertEnter" ];
dependencies = [
{ plugin = cmp-async-path; }
{ plugin = cmp-nvim-lsp; }
{ plugin = cmp_luasnip; }
{
plugin = copilot-cmp;
dependencies = [
{
plugin = copilot-lua;
conf = readFile ./copilot-lua.lua;
dependencies = [{ plugin = which-key-nvim; }];
}
];
}
{ plugin = friendly-snippets; }
{ plugin = luasnip; }
];
}
{
plugin = todo-comments-nvim;
event = [ "BufReadPost" "BufNewFile" ];
@ -200,9 +177,9 @@ with builtins;
conf = readFile ./smartcolumn-nvim.lua;
}
{
plugin = telescope-fzf-native-nvim;
conf = readFile ./telescope-fzf-native-nvim.lua;
plugin = telescope-nvim;
cmd = [ "Telescope" ];
conf = builtins.readFile ./telescope.lua;
keys = [
{ key = "<leader>ff"; cmd = "<cmd>Telescope find_files<cr>"; desc = "Find files"; }
{ key = "<leader>fb"; cmd = "<cmd>Telescope buffers<cr>"; desc = "Find buffers"; }
@ -220,13 +197,9 @@ with builtins;
{ key = "<leader>gs"; cmd = "<cmd>Telescope git_status<cr>"; desc = "Status"; }
];
dependencies = [
{
plugin = telescope-nvim;
dependencies = [
{ plugin = plenary-nvim; }
{ plugin = which-key-nvim; }
];
}
{ plugin = plenary-nvim; }
{ plugin = which-key-nvim; }
{ plugin = telescope-fzf-native-nvim; }
];
}
{
@ -241,7 +214,59 @@ with builtins;
{
plugin = comment-nvim;
event = [ "BufReadPost" "BufNewFile" ];
conf = "require('Comment').setup()";
conf = ''
require("Comment").setup()
'';
}
{
plugin = telekasten-nvim;
dependencies = [
{ plugin = telescope-nvim; }
{ plugin = which-key-nvim; }
];
cmd = [ "Telekasten" ];
keys = [
{ key = "<leader>z"; cmd = "<cmd>Telekasten<cr>"; desc = "zettelkasten"; }
];
conf = builtins.readFile ./zettelkasten-nvim.lua;
}
{
plugin = markdown-preview-nvim;
lazy = false;
}
{
plugin = coq_nvim;
event = [ "BufReadPost" "BufNewFile" ];
init = builtins.readFile ./coq-nvim.lua;
dependencies = [
{
plugin = coq-thirdparty;
conf = builtins.readFile ./coq-thirdparty.lua;
dependencies = [
{
plugin = codeium-vim;
init = builtins.readFile ./codeium-vim.lua;
}
];
}
{
plugin = coq-artifacts;
}
];
}
{
plugin = nvim-surround;
event = [ "BufReadPost" "BufNewFile" ];
conf = ''
require("nvim-surround").setup({})
'';
}
{
plugin = nvim-treesitter-context;
event = [ "BufReadPost" "BufNewFile" ];
conf = ''
require("treesitter-context").setup({})
'';
}
];
}

View file

@ -6,6 +6,9 @@ require("formatter").setup({
log_level = vim.log.levels.WARN,
-- All formatter configurations are opt-in
filetype = {
go = {
require("formatter.filetypes.go").gofmt,
},
json = {
require("formatter.filetypes.json").jq,
},

View file

@ -1,18 +1,8 @@
require("mini.align").setup()
require("mini.surround").setup()
require("mini.move").setup()
require("mini.pairs").setup()
require("mini.starter").setup()
require("mini.tabline").setup()
local tabline_current = vim.api.nvim_get_hl(0, { name = "MiniTablineCurrent" })
vim.api.nvim_set_hl(0, "MiniTablineCurrent", {
fg = tabline_current.fg,
bg = tabline_current.bg,
bold = true,
italic = true,
})
require("mini.statusline").setup({
content = {
active = function()

View file

@ -3,14 +3,12 @@ local null_ls = require("null-ls")
null_ls.setup({
sources = {
-- Code actions
null_ls.builtins.code_actions.cspell,
null_ls.builtins.code_actions.gitsigns,
null_ls.builtins.code_actions.shellcheck,
null_ls.builtins.code_actions.statix,
-- Completion
null_ls.builtins.completion.spell,
-- Diagnostics
null_ls.builtins.diagnostics.cspell,
null_ls.builtins.diagnostics.deadnix,
null_ls.builtins.diagnostics.shellcheck,
null_ls.builtins.diagnostics.statix,
@ -18,7 +16,6 @@ null_ls.setup({
})
-- disable (c)spell initially
null_ls.disable("cspell")
null_ls.disable("spell")
-- make sources toggle able
@ -31,11 +28,5 @@ require("which-key").register({
end,
"spell",
},
S = {
function()
null_ls.toggle("cspell")
end,
"cspell",
},
},
}, { prefix = "<leader>t" })

View file

@ -1,63 +0,0 @@
local cmp = require("cmp")
local luasnip = require("luasnip")
require("luasnip.loaders.from_vscode").lazy_load()
require("copilot_cmp").setup()
local default_sources = {
{ name = "async_path", priority = 1 },
{ name = "copilot", priority = 2 },
{ name = "luasnip", priority = 2 },
{ name = "nvim_lsp", priority = 3 },
}
cmp.setup({
formatting = {
format = require("lspkind").cmp_format({
mode = "symbol", -- show only symbol annotations
maxwidth = 50, -- prevent the popup from showing more than provided characters
ellipsis_char = "...", -- when popup menu exceed maxwidth, the truncated part would show ellipsis_char instead
symbol_map = {
Copilot = "",
},
}),
},
snippet = {
-- REQUIRED - you must specify a snippet engine
expand = function(args)
require("luasnip").lsp_expand(args.body)
end,
},
mapping = cmp.mapping.preset.insert({
["<C-b>"] = cmp.mapping.scroll_docs(-4),
["<C-f>"] = cmp.mapping.scroll_docs(4),
["<C-Space>"] = cmp.mapping.complete(),
["<C-e>"] = cmp.mapping.abort(),
["<CR>"] = cmp.mapping.confirm({ select = true }),
["<Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif luasnip.expand_or_jumpable() then
luasnip.expand_or_jump()
else
fallback()
end
end, { "i", "s" }),
["<S-Tab>"] = cmp.mapping(function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif luasnip.jumpable(-1) then
luasnip.jump(-1)
else
fallback()
end
end, { "i", "s" }),
}),
sources = default_sources,
})
cmp.setup.filetype("org", {
sources = vim.tbl_deep_extend("force", default_sources, {
{ name = "buffer", priority = 1 },
{ name = "orgmode", priority = 3 },
}),
})

View file

@ -5,9 +5,6 @@ vim.diagnostic.config({
virtual_text = false,
})
-- The nvim-cmp almost supports LSP's capabilities so You should advertise it to LSP servers..
local capabilities = require("cmp_nvim_lsp").default_capabilities()
vim.o.foldcolumn = "1" -- '0' is not bad
vim.o.foldlevel = 99 -- Using ufo provider need a large value, feel free to decrease the value
vim.o.foldlevelstart = 99
@ -47,6 +44,7 @@ require("which-key").register({
M = { require("ufo").closeAllFolds, "Close all folds" },
},
})
local capabilities = vim.lsp.protocol.make_client_capabilities()
-- Tell the server the capability of foldingRange,
-- Neovim hasn't added foldingRange to default capabilities, users must add it manually
capabilities.textDocument.foldingRange = {
@ -107,9 +105,6 @@ end
local lspconfig_default_options = {
on_attach = on_attach_def,
capabilities = capabilities,
flags = {
debounce_text_changes = 100,
},
}
---function to add default options to lspconfig
@ -117,8 +112,9 @@ local lspconfig_default_options = {
---@param options table
---@return nil
local function lspconfig_setup(lsp, options)
local final_options = vim.tbl_deep_extend("force", lspconfig_default_options, options)
lspconfig[lsp].setup(final_options)
local coq_options = require("coq").lsp_ensure_capabilities({})
local merged_options = vim.tbl_deep_extend("force", coq_options, lspconfig_default_options, options)
lspconfig[lsp].setup(merged_options)
end
local servers = {
@ -126,13 +122,23 @@ local servers = {
"nil_ls",
"pylsp",
"ruff_lsp",
"rust_analyzer",
"typst_lsp",
"gopls",
}
for _, lsp in ipairs(servers) do
lspconfig_setup(lsp, {})
end
lspconfig_setup("rust_analyzer", {
settings = {
["rust-analyzer"] = {
checkOnSave = {
command = "clippy",
},
},
},
})
lspconfig_setup("lua_ls", {
settings = {
Lua = {

View file

@ -1,4 +1,4 @@
require("smartcolumn").setup({
colorcolumn = 120,
colorcolumn = "120",
disabled_filetypes = { "help", "text", "markdown", "dashboard" },
})

View file

@ -0,0 +1,27 @@
local telekasten = require("telekasten")
telekasten.setup({
home = vim.fn.expand("~/Nextcloud/Notes/zettelkasten"),
auto_set_filetype = false,
image_subdir = "assets",
})
vim.api.nvim_create_autocmd({ "BufReadPost", "BufNewFile" }, {
pattern = "*/zettelkasten/*",
callback = function(_)
require("which-key").register({
g = {
f = { telekasten.follow_link, "Follow link" },
r = { telekasten.show_backlinks, "Show backlinks" },
},
["<leader>"] = {
f = {
f = { telekasten.find_notes, "Find note" },
n = { telekasten.new_note, "New note" },
},
s = {
g = { telekasten.search_note, "Grep notes" },
},
},
}, { buffer = vim.fn.bufnr("%") })
end,
})

View file

@ -0,0 +1,33 @@
{ config
, lib
, pkgs
, ...
}:
with lib;
let
cfg = config.my.programs.spotify-player;
toml = pkgs.formats.toml { };
in
{
options.my.programs.spotify-player = {
enable = mkEnableOption "spotify-player";
package = mkOption {
type = types.package;
default = pkgs.spotify-player;
};
config = mkOption {
inherit (toml) type;
default = { };
};
};
config = mkIf cfg.enable {
home-manager.users.moritz = {
xdg.configFile."spotify-player/app.toml" = {
source = toml.generate "app.toml" cfg.config;
};
home.packages = [ cfg.package ];
};
};
}

View file

@ -4,40 +4,33 @@ with lib;
let
cfg = config.my.programs.tmux;
tmux-sessionizer = pkgs.writeShellApplication {
name = "ts";
runtimeInputs = with pkgs; [ tmux findutils coreutils procps fd ];
tmux-switch = pkgs.writeShellApplication {
name = "tmux-switch";
runtimeInputs = with pkgs; [ tmux ];
text = ''
#!/usr/bin/env bash
options=$(fd -HIg '.git' ~/ --min-depth 1 --max-depth 5 --type d --prune --exec dirname {} | fzf --filter "''$*")
if [[ -z $options ]]; then
exit 1
elif [[ $(wc -l <<< "$options") -eq 1 ]]; then
selected="$options"
else
selected=$(echo "$options" | fzf --query="$*")
fi
if [[ -z $selected ]]; then
exit 0
fi
selected_name=$(basename "$selected" | tr . _)
if ! tmux has-session -t="$selected_name" 2> /dev/null; then
tmux new-session -ds "$selected_name" -c "$selected"
fi
if [[ -z ''${TMUX+x} ]]; then
tmux attach -t "$selected_name"
tmux attach -t "$1"
else
tmux switch-client -t "$selected_name"
tmux switch-client -t "$1"
fi
'';
};
tmux-sessionizer = pkgs.writeFishApplication {
name = "ts";
runtimeInputs = with pkgs; [ tmux findutils coreutils procps fd fzf1 tmux-switch ];
text = readFile ./tmux-sessionizer/script.fish;
completions = readFile ./tmux-sessionizer/completions.fish;
};
tmux-attach = pkgs.writeFishApplication {
name = "ta";
runtimeInputs = with pkgs; [ tmux fzf1 tmux-switch ];
text = readFile ./tmux-attach/script.fish;
completions = readFile ./tmux-attach/completions.fish;
};
in
{
options.my.programs.tmux = {
@ -64,7 +57,10 @@ in
config = mkIf cfg.enable {
my.shell.abbreviations.t = "tmux";
home-manager.users.moritz.home.packages = [ tmux-sessionizer ];
home-manager.users.moritz.home.packages = [
tmux-sessionizer
tmux-attach
];
home-manager.users.moritz.programs = {
tmux = {
enable = true;
@ -72,7 +68,6 @@ in
customPaneNavigationAndResize = true;
keyMode = "vi";
mouse = true;
newSession = true;
prefix = "C-Space";
sensibleOnTop = false;
plugins = with pkgs.tmuxPlugins; [

View file

@ -0,0 +1 @@
complete -c ta -f -a '(tmux list-sessions -F "#{session_name}" 2>/dev/null)'

View file

@ -0,0 +1,5 @@
set selected (tmux list-sessions -F '#{session_name}' 2>/dev/null | fzf1 $argv)
if not test -n "$selected"
exit 1
end
tmux-switch "$selected"

View file

@ -0,0 +1 @@
complete -c ts -f -a '(fd -HIg '.git' ~/ --min-depth 1 --max-depth 5 --type d --prune --exec realpath "{}/.." | xargs -I{} basename {} | string replace "." "")'

View file

@ -0,0 +1,13 @@
set selected (fd -HIg '.git' ~/ --min-depth 1 --max-depth 5 --type d --prune --exec dirname {} | fzf1 $argv)
set selected_name (basename $selected 2>/dev/null | string replace "." "_")
if not test -n "$selected_name"
exit 1
end
if ! tmux has-session -t $selected_name 2> /dev/null
tmux new-session -ds $selected_name -c $selected
end
tmux-switch $selected_name

View file

@ -0,0 +1,58 @@
{ lib, config, pkgs, ... }:
with lib;
let
toml = pkgs.formats.toml { };
cfg = config.my.services.spotify-player;
tomlConfig =
if cfg.configFile != null
then cfg.configFile
else toml.generate "app.toml" cfg.config;
configFolder = pkgs.runCommand "spotify-player-config" { } ''
mkdir $out
ln -s "${tomlConfig}" $out/app.toml
'';
in
{
options.my.services.spotify-player = {
enable = mkEnableOption "spotify_player";
config = mkOption {
inherit (toml) type;
default = { };
};
configFile = mkOption {
type = with types; nullOr path;
default = null;
};
package = mkOption {
type = types.package;
default = pkgs.spotify-player;
};
};
config = mkIf cfg.enable {
assertions = [
{
assertion = cfg.config == { } || cfg.configFile == null;
message = "At least one of the options 'config' or 'configFile' must be set.";
}
{
assertion = cfg.config != { } || cfg.configFile != null;
message = "Only one of the options 'config' or 'configFile' may be set.";
}
];
systemd.user.services.spotify-player = {
after = [ "graphical-session.target" "network.target" ];
partOf = [ "graphical-session.target" ];
wantedBy = [ "graphical-session.target" ];
serviceConfig = {
Type = "forking";
Restart = "always";
RestartSec = "1s";
ExecStart = "${getExe cfg.package} --daemon --config-folder ${configFolder}";
};
};
};
}

View file

@ -21,7 +21,7 @@ in
wantedBy = [ "graphical-session.target" ];
serviceConfig = {
ExitType = "cgroup";
Restart = "on-failure";
Restart = "always";
RestartSec = "1s";
ExecStartPre = "${pkgs.coreutils}/bin/rm -rf %h/.SynologyDrive/SynologyDrive.app %h/.SynologyDrive/cloud-connect.pid";
ExecStart = "${cfg.package}/bin/synology-drive";