This commit is contained in:
Kopatz
2024-05-16 21:14:30 +02:00
parent 55b15b92ff
commit 38bfbe82c6
23 changed files with 595 additions and 101 deletions

4
flake.lock generated
View File

@@ -383,7 +383,7 @@
"inputs": { "inputs": {
"flake-compat": "flake-compat", "flake-compat": "flake-compat",
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs-unstable"
] ]
}, },
"locked": { "locked": {
@@ -509,7 +509,7 @@
"home-manager": "home-manager_3", "home-manager": "home-manager_3",
"nix-darwin": "nix-darwin", "nix-darwin": "nix-darwin",
"nixpkgs": [ "nixpkgs": [
"nixpkgs" "nixpkgs-unstable"
], ],
"pre-commit-hooks": "pre-commit-hooks", "pre-commit-hooks": "pre-commit-hooks",
"treefmt-nix": "treefmt-nix" "treefmt-nix": "treefmt-nix"

189
flake.nix
View File

@@ -22,114 +22,109 @@
nur = { url = "github:nix-community/NUR"; }; nur = { url = "github:nix-community/NUR"; };
nixos-cosmic = { nixos-cosmic = {
url = "github:lilyinstarlight/nixos-cosmic"; url = "github:lilyinstarlight/nixos-cosmic";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs-unstable";
}; };
nixvim = { nixvim = {
url = "github:nix-community/nixvim"; url = "github:nix-community/nixvim";
inputs.nixpkgs.follows = "nixpkgs"; inputs.nixpkgs.follows = "nixpkgs-unstable";
}; };
}; };
outputs = { self, outputs = { self, nur, nixpkgs, nixos-hardware, nixos-wsl, nixpkgs-unstable
nur, , agenix, home-manager, home-manager-unstable, nix-colors, nixos-cosmic
nixpkgs, , nixvim }@inputs:
nixos-hardware,
nixos-wsl,
nixpkgs-unstable,
agenix,
home-manager,
home-manager-unstable,
nix-colors,
nixos-cosmic,
nixvim
}@inputs:
let let
inherit (self) outputs; inherit (self) outputs;
system = "x86_64-linux"; system = "x86_64-linux";
# helper function to create a machine # helper function to create a machine
mkHost = ({modules, specialArgs ? { pkgsVersion = nixpkgs-unstable;}}: nixpkgs-unstable.lib.nixosSystem { mkHost = { modules, specialArgs ? { pkgsVersion = nixpkgs-unstable; } }:
inherit system; nixpkgs-unstable.lib.nixosSystem {
modules = modules ++ [ inherit system;
./modules modules = modules ++ [
({ config, outputs, ... }: { nixpkgs.overlays = with outputs.overlays; [additions modifications unstable-packages nur.overlay]; }) ./modules
home-manager-unstable.nixosModules.home-manager ({ outputs, ... }: {
agenix.nixosModules.default nixpkgs.overlays = with outputs.overlays; [
nixos-cosmic.nixosModules.default additions
]; modifications
specialArgs = specialArgs // { inherit inputs outputs;}; unstable-packages
}); nur.overlay
];
})
home-manager-unstable.nixosModules.home-manager
agenix.nixosModules.default
nixos-cosmic.nixosModules.default
];
specialArgs = specialArgs // { inherit inputs outputs; };
};
in { in {
overlays = import ./overlays.nix {inherit inputs;}; overlays = import ./overlays.nix { inherit inputs; };
nixosConfigurations.server = mkHost { nixosConfigurations = {
modules = [ server = mkHost {
./users/anon modules = [
./modules/collections/server.nix ./users/anon
./systems/server/configuration.nix ./modules/collections/server.nix
]; ./systems/server/configuration.nix
specialArgs = { ];
## Custom variables (e.g. ip, interface, etc) specialArgs = {
vars = import ./systems/userdata-default.nix // import ./systems/server/userdata.nix; ## Custom variables (e.g. ip, interface, etc)
pkgsVersion = nixpkgs-unstable; vars = import ./systems/userdata-default.nix
// import ./systems/server/userdata.nix;
pkgsVersion = nixpkgs-unstable;
};
};
"kop-pc" = mkHost {
modules = [ ./users/kopatz ./systems/pc/configuration.nix ];
};
"nix-laptop" = mkHost {
specialArgs = {
## Custom variables (e.g. ip, interface, etc)
vars = import ./systems/userdata-default.nix
// import ./systems/laptop/userdata.nix;
pkgsVersion = nixpkgs-unstable;
inherit nix-colors;
};
modules = [
### User specific ###
./users/kopatz
./systems/laptop/configuration.nix
./modules/collections/laptop.nix
./modules/ecryptfs.nix
./modules/services/syncthing.nix
./modules/fh/scanning.nix
./modules/support/ntfs.nix
./modules/thunderbolt.nix
#./modules/vmware-host.nix
#./modules/fh/forensik.nix
#./modules/no-sleep-lid-closed.nix
#./modules/static-ip.nix
#./modules/wake-on-lan.nix
nixos-hardware.nixosModules.dell-xps-15-7590-nvidia
];
};
"mini-pc" = mkHost {
specialArgs = {
vars = import ./systems/userdata-default.nix;
pkgsVersion = nixpkgs-unstable;
};
modules = [ ./users/anon ./systems/mini-pc/configuration.nix ];
};
# build vm -> nixos-rebuild build-vm --flake .#vm
"vm" = mkHost {
specialArgs = {
vars = import ./systems/userdata-default.nix;
pkgsVersion = nixpkgs-unstable;
};
modules = [ ./users/vm ./systems/vm/configuration.nix ];
};
"wsl" = mkHost {
modules = [
#"${nixpkgs}/nixos/modules/profiles/minimal.nix"
./users/anon
./modules/nix/settings.nix
./systems/wsl/configuration.nix
nixos-wsl.nixosModules.wsl
];
};
}; };
}; };
nixosConfigurations."kop-pc" = mkHost {
modules = [
./users/kopatz
./systems/pc/configuration.nix
];
};
nixosConfigurations."nix-laptop" = mkHost {
specialArgs = {
## Custom variables (e.g. ip, interface, etc)
vars = import ./systems/userdata-default.nix // import ./systems/laptop/userdata.nix;
pkgsVersion = nixpkgs-unstable;
inherit nix-colors;
};
modules = [
### User specific ###
./users/kopatz
./systems/laptop/configuration.nix
./modules/collections/laptop.nix
./modules/ecryptfs.nix
./modules/services/syncthing.nix
./modules/fh/scanning.nix
./modules/support/ntfs.nix
./modules/thunderbolt.nix
#./modules/vmware-host.nix
#./modules/fh/forensik.nix
#./modules/no-sleep-lid-closed.nix
#./modules/static-ip.nix
#./modules/wake-on-lan.nix
];
};
nixosConfigurations."mini-pc" = mkHost {
specialArgs = {
vars = import ./systems/userdata-default.nix;
pkgsVersion = nixpkgs-unstable;
};
modules = [
./users/anon
./systems/mini-pc/configuration.nix
];
};
# build vm -> nixos-rebuild build-vm --flake .#vm
nixosConfigurations."vm" = mkHost {
specialArgs = {
vars = import ./systems/userdata-default.nix;
pkgsVersion = nixpkgs-unstable;
};
modules = [
./users/vm
./systems/vm/configuration.nix
];
};
nixosConfigurations."wsl" = mkHost {
modules = [
#"${nixpkgs}/nixos/modules/profiles/minimal.nix"
./users/anon
./modules/nix/settings.nix
./systems/wsl/configuration.nix
];
};
};
} }

View File

@@ -0,0 +1,3 @@
{
plugins.nvim-autopairs = { enable = true; };
}

View File

@@ -0,0 +1,6 @@
{
plugins.auto-save = {
enable = true;
enableAutoSave = true;
};
}

View File

@@ -0,0 +1,15 @@
{
plugins.indent-blankline = {
enable = true;
settings = {
indent = {
smart_indent_cap = true;
char = " ";
};
scope = {
enabled = true;
char = "";
};
};
};
}

View File

@@ -0,0 +1 @@
{ plugins.bufferline = { enable = true; }; }

155
home-manager/nixvim/cmp.nix Normal file
View File

@@ -0,0 +1,155 @@
# # Source: https://github.com/hmajid2301/dotfiles/blob/ab7098387426f73c461950c7c0a4f8fb4c843a2c/home-manager/editors/nvim/plugins/coding/cmp.nix
{
plugins = {
luasnip.enable = true;
copilot-lua = {
enable = true;
suggestion.enabled = false;
panel.enabled = false;
};
cmp-buffer = { enable = true; };
cmp-emoji = { enable = true; };
cmp-nvim-lsp = { enable = true; };
cmp-path = { enable = true; };
cmp_luasnip = { enable = true; };
cmp = {
enable = true;
settings = {
snippet.expand = ''
function(args)
require('luasnip').lsp_expand(args.body)
end
'';
sources = [
{ name = "nvim_lsp"; }
{ name = "luasnip"; }
{
name = "buffer";
option.get_bufnrs.__raw = "vim.api.nvim_list_bufs";
}
{ name = "nvim_lua"; }
{ name = "path"; }
{ name = "copilot"; }
];
formatting = {
fields = [ "abbr" "kind" "menu" ];
format =
# lua
''
function(_, item)
local icons = {
Namespace = "󰌗",
Text = "󰉿",
Method = "󰆧",
Function = "󰆧",
Constructor = "",
Field = "󰜢",
Variable = "󰀫",
Class = "󰠱",
Interface = "",
Module = "",
Property = "󰜢",
Unit = "󰑭",
Value = "󰎠",
Enum = "",
Keyword = "󰌋",
Snippet = "",
Color = "󰏘",
File = "󰈚",
Reference = "󰈇",
Folder = "󰉋",
EnumMember = "",
Constant = "󰏿",
Struct = "󰙅",
Event = "",
Operator = "󰆕",
TypeParameter = "󰊄",
Table = "",
Object = "󰅩",
Tag = "",
Array = "[]",
Boolean = "",
Number = "",
Null = "󰟢",
String = "󰉿",
Calendar = "",
Watch = "󰥔",
Package = "",
Copilot = "",
Codeium = "",
TabNine = "",
}
local icon = icons[item.kind] or ""
item.kind = string.format("%s %s", icon, item.kind or "")
return item
end
'';
};
window = {
completion = {
winhighlight =
"FloatBorder:CmpBorder,Normal:CmpPmenu,CursorLine:CmpSel,Search:PmenuSel";
scrollbar = false;
sidePadding = 0;
border = [ "" "" "" "" "" "" "" "" ];
};
settings.documentation = {
border = [ "" "" "" "" "" "" "" "" ];
winhighlight =
"FloatBorder:CmpBorder,Normal:CmpPmenu,CursorLine:CmpSel,Search:PmenuSel";
};
};
mapping = {
"<C-n>" = "cmp.mapping.select_next_item()";
"<C-p>" = "cmp.mapping.select_prev_item()";
"<C-j>" = "cmp.mapping.select_next_item()";
"<C-k>" = "cmp.mapping.select_prev_item()";
"<C-d>" = "cmp.mapping.scroll_docs(-4)";
"<C-f>" = "cmp.mapping.scroll_docs(4)";
"<C-Space>" = "cmp.mapping.complete()";
"<C-e>" = "cmp.mapping.close()";
"<CR>" =
"cmp.mapping.confirm({ behavior = cmp.ConfirmBehavior.Insert, select = true })";
"<Tab>" =
# lua
''
function(fallback)
if cmp.visible() then
cmp.select_next_item()
elseif require("luasnip").expand_or_jumpable() then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-expand-or-jump", true, true, true), "")
else
fallback()
end
end
'';
"<S-Tab>" =
# lua
''
function(fallback)
if cmp.visible() then
cmp.select_prev_item()
elseif require("luasnip").jumpable(-1) then
vim.fn.feedkeys(vim.api.nvim_replace_termcodes("<Plug>luasnip-jump-prev", true, true, true), "")
else
fallback()
end
end
'';
};
};
};
};
}

View File

@@ -0,0 +1,161 @@
{lib, pkgs, ...}:
{
enable = true;
colorschemes.dracula.enable = true;
globals.mapleader = " ";
opts = {
updatetime = 100; # Faster completion
number = true;
relativenumber = true;
autoindent = true;
clipboard = "unnamedplus";
expandtab = true;
shiftwidth = 2;
smartindent = true;
tabstop = 2;
ignorecase = true;
incsearch = true;
smartcase = true;
wildmode = "list:longest";
swapfile = false;
undofile = true; # Build-in persistent undo
termguicolors = lib.mkForce pkgs.stdenv.isLinux;
};
keymaps = [
# Global
# Default mode is "" which means normal-visual-op
{
key = "<leader>x";
action = "<CMD>NvimTreeToggle<CR>";
options.desc = "Toggle NvimTree";
}
# File
#{
# mode = "n";
# key = "<leader>sf";
# action = "+find/file";
#}
{
# Format file
key = "<leader>fm";
action = "<CMD>lua vim.lsp.buf.format()<CR>";
options.desc = "Format the current buffer";
}
# Git
{
mode = "n";
key = "<leader>g";
action = "+git";
}
{
mode = "n";
key = "<leader>gt";
action = "+toggles";
}
{
key = "<leader>gtb";
action = "<CMD>Gitsigns toggle_current_line_blame<CR>";
options.desc = "Gitsigns current line blame";
}
{
key = "<leader>gtd";
action = "<CMD>Gitsigns toggle_deleted";
options.desc = "Gitsigns deleted";
}
{
key = "<leader>gd";
action = "<CMD>Gitsigns diffthis<CR>";
options.desc = "Gitsigns diff this buffer";
}
{
mode = "n";
key = "<leader>gr";
action = "+resets";
}
{
key = "<leader>grh";
action = "<CMD>Gitsigns reset_hunk<CR>";
options.desc = "Gitsigns reset hunk";
}
{
key = "<leader>grb";
action = "<CMD>Gitsigns reset_buffer<CR>";
options.desc = "Gitsigns reset current buffer";
}
# Tabs
{
mode = "n";
key = "<leader>t";
action = "+tab";
}
{
mode = "n";
key = "<leader>tn";
action = "<CMD>tabnew<CR>";
options.desc = "Create new tab";
}
{
mode = "n";
key = "<leader>td";
action = "<CMD>tabclose<CR>";
options.desc = "Close tab";
}
{
mode = "n";
key = "<leader>tt";
action = "<CMD>tabnext<CR>";
options.desc = "Go to the sub-sequent tab";
}
{
mode = "n";
key = "<leader>tp";
action = "<CMD>tabprevious<CR>";
options.desc = "Go to the previous tab";
}
# Terminal
{
# Escape terminal mode using ESC
mode = "t";
key = "<esc>";
action = "<C-\\><C-n>";
options.desc = "Escape terminal mode";
}
# Trouble
{
mode = "n";
key = "<leader>d";
action = "+diagnostics/debug";
}
{
key = "<leader>dt";
action = "<CMD>TroubleToggle<CR>";
options.desc = "Toggle trouble";
}
# Rust
{
mode = "n";
key = "<leader>r";
action = "+rust";
}
{
# Start standalone rust-analyzer (fixes issues when opening files from nvim tree)
mode = "n";
key = "<leader>rs";
action = "<CMD>RustStartStandaloneServerForBuffer<CR>";
options.desc = "Start standalone rust-analyzer";
}
];
}

View File

@@ -0,0 +1,30 @@
{ lib, pkgs, ... }:
let
args = { inherit lib pkgs; };
importFile = file:
let config = import file;
in if builtins.isFunction config then config args else config;
configs = map importFile [
./auto-pairs.nix
./autosave.nix
./blankline.nix
./bufferline.nix
./cmp.nix
./fidget.nix
./git.nix
./lightline.nix
./lsp.nix
./none-ls.nix
./nvim-tree.nix
./telescope.nix
./toggleterm.nix
./treesitter.nix
./trouble.nix
./which_key.nix
./wilder.nix
./config.nix
];
merged =
builtins.foldl' (acc: elem: lib.recursiveUpdate acc elem) { } configs;
in { programs.nixvim = merged; }

View File

@@ -0,0 +1,10 @@
{
plugins.fidget = {
enable = true;
progress = {
suppressOnInsert = true;
ignoreDoneAlready = true;
pollRate = 0.5;
};
};
}

View File

@@ -0,0 +1,9 @@
{
plugins.gitsigns = {
enable = true;
settings = {
current_line_blame = true;
trouble = true;
};
};
}

View File

@@ -0,0 +1 @@
{ plugins.lightline = { enable = true; }; }

View File

@@ -0,0 +1,25 @@
{
plugins = {
lsp = {
enable = true;
servers = {
bashls.enable = true;
clangd.enable = true;
gopls.enable = true;
nixd.enable = true;
};
keymaps.lspBuf = {
"gd" = "definition";
"gD" = "references";
"gt" = "type_definition";
"gi" = "implementation";
"K" = "hover";
};
};
lsp-lines = {
enable = true;
currentLine = true;
};
rust-tools.enable = true;
};
}

View File

@@ -0,0 +1,20 @@
{
plugins.none-ls = {
enable = true;
sources = {
diagnostics = {
golangci_lint.enable = true;
statix.enable = true;
};
formatting = {
fantomas.enable = true;
gofmt.enable = true;
goimports.enable = true;
nixfmt.enable = true;
markdownlint.enable = true;
shellharden.enable = true;
shfmt.enable = true;
};
};
};
}

View File

@@ -0,0 +1,11 @@
{
plugins.nvim-tree = {
enable = true;
openOnSetup = true;
autoReloadOnWrite = true;
tab.sync = {
close = true;
open = true;
};
};
}

View File

@@ -0,0 +1,17 @@
{
plugins.telescope = {
enable = true;
keymaps = {
"<leader>sg" = "live_grep";
"<leader>sf" = {
action = "find_files";
options = { desc = "[S]earch [F]iles"; };
};
"<leader>gf" = {
action = "git_files";
options = { desc = "Search [G]it [F]iles"; };
};
};
extensions.fzf-native = { enable = true; };
};
}

View File

@@ -0,0 +1,8 @@
{
plugins.toggleterm = {
enable = true;
settings = {
open_mapping = "[[<C-t>]]";
};
};
}

View File

@@ -0,0 +1,11 @@
{
plugins = {
treesitter = {
enable = true;
nixGrammars = true;
indent = true;
};
#treesitter-context.enable = true;
rainbow-delimiters.enable = true;
};
}

View File

@@ -0,0 +1,5 @@
{
plugins = {
trouble.enable = true;
};
}

View File

@@ -0,0 +1,5 @@
{
opts = {
timeoutlen = 500;
};
plugins.which-key = { enable = true; }; }

View File

@@ -0,0 +1,6 @@
{
plugins.wilder = {
enable = true;
modes = [ ":" "/" "?" ];
};
}

View File

@@ -29,7 +29,7 @@ in
networking.firewall = { networking.firewall = {
enable = true; enable = true;
allowedTCPPorts = [ 53317 ]; #localsend allowedTCPPorts = [ 25565 53317 ]; #localsend
allowedUDPPorts = [ 1194 53317 ]; #openvpn, localsend allowedUDPPorts = [ 1194 53317 ]; #openvpn, localsend
allowedTCPPortRanges = [ allowedTCPPortRanges = [
{ from = 1714; to = 1764; } # KDE Connect { from = 1714; to = 1764; } # KDE Connect

View File

@@ -21,7 +21,7 @@
#../../home-manager/kde-path.nix #../../home-manager/kde-path.nix
../../home-manager/kitty.nix ../../home-manager/kitty.nix
../../home-manager/lf.nix ../../home-manager/lf.nix
../../home-manager/nvim.nix ../../home-manager/nixvim
../../home-manager/rofi.nix ../../home-manager/rofi.nix
../../home-manager/theme.nix ../../home-manager/theme.nix
../../home-manager/zsh.nix ../../home-manager/zsh.nix