refactor module system

This commit is contained in:
2026-11-08 15:22:26 +01:00
parent d4ef8af473
commit c5bb5cc965
40 changed files with 30 additions and 35 deletions
+35
View File
@@ -0,0 +1,35 @@
{
security.rtkit.enable = true;
services.pipewire = {
enable = true;
alsa.enable = true;
alsa.support32Bit = true;
pulse.enable = true;
jack.enable = true;
extraConfig.pipewire = {
"98-crackling-fix" = {
"context.properties" = {
"default.clock.quantum" = 1024;
"default.clock.min-quantum" = 1024;
"default.clock.max-quantum" = 8192;
};
};
};
};
security.pam.loginLimits = [
{
domain = "@users";
item = "rtprio";
type = "-";
value = "95";
}
{
domain = "@users";
item = "memlock";
type = "-";
value = "unlimited";
}
];
}
+26
View File
@@ -0,0 +1,26 @@
{ pkgs, sls-steam, ... }:
{
programs.gamemode.enable = true;
programs.steam = {
enable = true;
protontricks.enable = true;
extraCompatPackages = with pkgs; [ proton-ge-bin ];
package = pkgs.steam.override {
extraEnv = {
LD_AUDIT = "${sls-steam.packages.${pkgs.stdenv.hostPlatform.system}.sls-steam}/library-inject.so:${
sls-steam.packages.${pkgs.stdenv.hostPlatform.system}.sls-steam
}/SLSsteam.so";
};
};
};
home-manager.users.user = {
programs = {
lutris = {
enable = true;
protonPackages = [ pkgs.proton-ge-bin ];
};
prismlauncher.enable = true;
};
};
}
+33
View File
@@ -0,0 +1,33 @@
{ pkgs, ... }:
{
programs.git = {
enable = true;
config = {
signing = {
key = "51AE8C6E80E6AF3BDFBE2BF804B31D181764898D";
signByDefault = true;
};
user = {
name = "KeksNino";
email = "KeksNino@proton.me";
};
init = {
defaultBranch = "main";
};
push = {
autoSetupRemote = true;
};
commit = {
gpgsign = true;
};
tag = {
gpgsign = true;
};
};
};
programs.gnupg.agent = {
enable = true;
pinentryPackage = pkgs.pinentry-curses;
};
}
+5
View File
@@ -0,0 +1,5 @@
{
imports = [
./neovim.nix
];
}
+75
View File
@@ -0,0 +1,75 @@
{
programs.nixvim = {
globals = {
mapleader = " ";
};
keymaps = [
{
action = "<cmd>lua Snacks.explorer.open()<CR>";
key = "<leader>e";
}
{
action = "<cmd>lua Snacks.bufdelete()<CR>";
key = "<C-q>";
}
{
mode = [
"n"
"x"
"o"
];
action = ''<cmd>lua require("flash").jump()<CR>'';
key = "s";
}
{
action = "<cmd>BufferLineCycleNext<CR>";
key = "<tab>";
}
{
action = "<cmd>BufferLineCyclePrev<CR>";
key = "<S-tab>";
}
{
mode = [ "x" ];
action = "<gv";
key = "<";
}
{
mode = [ "x" ];
action = ">gv";
key = ">";
}
{
mode = [ "n" ];
action = ''"_d'';
key = "d";
}
{
mode = [ "n" ];
action = ''"_dd'';
key = "dd";
}
{
mode = [ "v" ];
action = ''"_d'';
key = "d";
}
{
mode = [ "n" ];
action = "<cmd>Telescope live_grep<CR>";
key = "<leader>rg";
}
{
mode = [ "n" ];
action = "<cmd>Telescope find_files<CR>";
key = "<leader>ff";
}
{
mode = [ "n" ];
action = "<cmd>:lua vim.diagnostic.open_float<CR>";
key = "<leader>k";
}
];
};
}
+30
View File
@@ -0,0 +1,30 @@
{
programs.nixvim.lsp = {
servers = {
lua_ls.enable = true;
nixd = {
enable = true;
config = {
settings = {
nixd = {
nixpkgs = {
expr = ''import (builtins.getFlake "/home/user/nix-config").inputs.nixpkgs { }'';
};
formatting = {
command = [ "nixfmt" ];
};
options = {
nixos = {
expr = ''(builtins.getFlake "/home/user/nix-config").nixosConfigurations.desktop.options'';
};
home_manager = {
expr = ''(builtins.getFlake "/home/user/nix-config").nixosConfigurations.desktop.options.home-manager.users.type.getSubOptions []'';
};
};
};
};
};
};
};
};
}
+149
View File
@@ -0,0 +1,149 @@
{
pkgs,
config,
...
}:
{
imports = [
./plugins
./keymaps.nix
./lsp.nix
];
programs.nixvim = {
enable = false;
defaultEditor = true;
clipboard.register = "unnamedplus";
opts = {
number = true;
relativenumber = true;
expandtab = true;
shiftwidth = 2;
smartindent = true;
tabstop = 2;
softtabstop = 2;
showmode = false;
fillchars.eob = " ";
ignorecase = true;
smartcase = true;
mouse = "a";
};
extraPlugins = with pkgs.vimPlugins; [
boole-nvim
tokyodark-nvim
];
extraConfigLua = ''
require('boole').setup({
mappings = {
-- increment = '<C-a>',
decrement = '<C-x>'
},
allow_caps_additions = {
{'enable', 'disable'},
{'true', 'false'}
}
})
require('tokyodark').setup({
gamma = 0.9,
transparent_background = true,
terminal_colors = false,
custom_highlights = function(_, palette)
return {
["@variable"] = {
fg = "#A0A8CD",
},
}
end,
})
vim.cmd.colorscheme("tokyodark")
'';
plugins = {
lualine.enable = true;
bufferline = {
enable = true;
settings = {
options = {
show_buffer_close_icons = false;
show_close_icon = false;
themable = true;
separator_style = "thin";
indicator.style = "none";
always_show_bufferline = false;
color_icons = true;
show_buffer_icons = true;
};
# highlights = {
# fill.bg = "NONE";
# separator.fg = "NONE";
# separator_selected.fg = "NONE";
# separator_visible.fg = "NONE";
# };
};
};
yazi.enable = true;
cord = {
enable = true;
settings.display.theme = "atom";
};
neoscroll.enable = true;
telescope = {
enable = true;
enabledExtensions = [ "persisted" ];
};
which-key.enable = true;
flash.enable = true;
lsp.enable = true;
fugitive.enable = true;
treesitter = {
enable = true;
highlight.enable = true;
indent.enable = true;
grammarPackages = with config.programs.nixvim.plugins.treesitter.package.builtGrammars; [
bash
json
lua
markdown
nix
regex
rust
python
toml
xml
yaml
];
};
gitsigns.enable = true;
nvim-autopairs = {
enable = true;
};
cmp = {
autoEnableSources = true;
settings.sources = [
{ name = "nvim_lsp"; }
{ name = "path"; }
{ name = "buffer"; }
];
};
persisted.enable = true;
render-markdown.enable = true;
oil = {
enable = true;
settings = {
view_options = {
show_hidden = true;
};
};
};
colorizer.enable = true;
};
};
}
+35
View File
@@ -0,0 +1,35 @@
{ pkgs, ... }:
{
programs.nixvim.extraPackages = with pkgs; [
stylua
nixfmt
];
programs.nixvim.plugins = {
conform-nvim = {
enable = true;
settings = {
format_on_save = ''
function(bufnr)
-- Disable "format_on_save lsp_fallback" for lanuages that don't
-- have a well standardized coding style. You can add additional
-- lanuages here or re-enable it for the disabled ones.
local disable_filetypes = { c = true, cpp = true }
if disable_filetypes[vim.bo[bufnr].filetype] then
return nil
else
return {
timeout_ms = 500,
lsp_format = "fallback",
}
end
end
'';
formatters_by_ft = {
lua = [ "stylua" ];
nix = [ "nixfmt" ];
};
};
};
};
}
+6
View File
@@ -0,0 +1,6 @@
{
imports = [
./snacks.nix
./conform.nix
];
}
+81
View File
@@ -0,0 +1,81 @@
{
programs.nixvim.plugins = {
snacks = {
enable = true;
settings = {
bigfile.enabled = true;
dashboard = {
enabled = true;
preset = {
keys = [
{
icon = " ";
key = "f";
desc = "Find File";
action = ":lua Snacks.dashboard.pick('files')";
}
{
icon = " ";
key = "n";
desc = "New File";
action = ":ene | startinsert";
}
{
icon = " ";
key = "g";
desc = "Find Text";
action = ":lua Snacks.dashboard.pick('live_grep')";
}
{
icon = " ";
key = "r";
desc = "Recent Files";
action = ":lua Snacks.dashboard.pick('oldfiles')";
}
{
icon = " ";
key = "c";
desc = "Config";
action = ":lua require('telescope.builtin').find_files({ cwd = '~/nix-config/modules/programs/neovim' })";
}
{
icon = " ";
key = "s";
desc = "Restore Session";
action = ":Telescope persisted";
}
{
icon = " ";
key = "q";
desc = "Quit";
action = ":qa";
}
];
};
sections = [
{
section = "header";
gap = 2;
}
{
section = "keys";
gap = 1;
padding = 1;
}
];
};
explorer = {
enabled = true;
auto_close = true;
};
indent.enabled = false;
input.enabled = true;
picker.enabled = true;
notifier.enabled = true;
quickfile.enabled = true;
statuscolumn.enabled = true;
words.enabled = true;
};
};
};
}
+21
View File
@@ -0,0 +1,21 @@
{ pkgs, ... }:
{
services.printing = {
enable = true;
drivers = with pkgs; [
cups-filters
cups-browsed
canon-cups-ufr2
];
};
services.avahi = {
enable = true;
nssmdns4 = true;
openFirewall = true;
};
home-manager.users.user = {
programs.libreoffice.enable = true;
};
}
+21
View File
@@ -0,0 +1,21 @@
{ pkgs, ... }:
{
nix.distributedBuilds = true;
nix.settings = {
builders-use-substitutes = true;
};
nix.buildMachines = [
{
hostName = "h16.planet-elektronik.de:15005";
sshUser = "nixremote";
sshKey = "/home/user/.ssh/nixremote";
system = pkgs.stdenv.hostPlatform.system;
maxJobs = 8;
speedFactor = 2;
supportedFeatures = [ ];
mandatoryFeatures = [ ];
}
];
}
+87
View File
@@ -0,0 +1,87 @@
{ pkgs, ... }:
{
environment.systemPackages = [
(pkgs.writeShellScriptBin "scan" ''
find . -type f \( -iname "*.mp3" -o -iname "*.flac" -o -iname "*.m4a" -o -iname "*.ogg" -o -iname "*.wav" -o -iname "*.aiff" \) -print0 |
xargs -0 -P"$(nproc)" -I{} bash -c '
if ffprobe -v quiet -show_entries format_tags \
-of default=nw=1:nk=1 "$1" 2>/dev/null |
grep -q -E "Visit https?://[^ ]+"; then
echo "Match found in: $1"
fi
' _ {} | sort
'')
# (pkgs.writeShellScriptBin "2scan" ''
# find . -type f \( -iname "*.mp3" -o -iname "*.flac" -o -iname "*.m4a" -o -iname "*.ogg" -o -iname "*.wav" -o -iname "*.aiff" \) -print0 |
# xargs -0 -P"$(nproc)" -I{} sh -c '
# if ! ffprobe -v quiet -show_entries format_tags \
# -of default=nw=1:nk=1 "$1" 2>/dev/null |
# grep -q -E "Visit https?://[^ ]+"; then
# echo "Match found in: $1"
# fi
# ' _ {}
# '')
(pkgs.writeShellScriptBin "2scan" ''
fd -e flac -e mp3 -e m4a -e aiff -x sh -c '
if ! strings "$1" | grep -qE "^COMMENT=Visit https?://[^ ]+"; then
echo "Match found in: $1"
fi
' sh {}
'')
(pkgs.writeShellScriptBin "enable-hypervisor" ''
sudo modprobe -r kvm_amd kvm
sudo modprobe cpuid_fault_emulation
'')
(pkgs.writeShellScriptBin "disable-hypervisor" ''
sudo modprobe -r cpuid_fault_emulation
sudo modprobe kvm_amd kvm
'')
(pkgs.writeShellScriptBin "check-playlist" ''
PLAYLIST_DIR="/home/user/Music/Playlists/"
BASENAME="/home/user/Music/$SELECTED_SONGS"
# echo $BASENAME | kitty +kitten clipboard
shopt -s extglob
if grep -qF "$BASENAME" "$PLAYLIST_DIR"/!(active\ -\ new|other\ -\ lostfrog).m3u
then
notify-send "Song is in a playlist";
else
notify-send "Song isnt in a playlist";
fi
'')
(pkgs.writeShellScriptBin "mpd-volume" ''
if [ $# != 1 ]; then
echo "Usage: ''${0} up|down"
exit 1
fi
STEP=5
get_vol() {
mpc --host=/tmp/mpd_socket volume
}
set_vol() {
mpc --host=/tmp/mpd_socket volume "$1"
}
case "$1" in
up)
set_vol +$((STEP))
;;
down)
set_vol -$((STEP))
;;
*)
echo "Usage: ''${0} up|down"
exit 1
;;
esac
'')
];
}
+12
View File
@@ -0,0 +1,12 @@
{
imports = [
./shares
./slskd.nix
./navidrome.nix
./services.nix
./zfs.nix
./firewall.nix
./grafana.nix
../scripts.nix
];
}
+10
View File
@@ -0,0 +1,10 @@
{
networking.firewall.allowedTCPPorts = [
2049
5030
3900
3901
3902
3903
];
}
+34
View File
@@ -0,0 +1,34 @@
{
services.grafana = {
enable = true;
openFirewall = true;
settings = {
security.secret_key = "$__file{/run/secrets/grafana/secret_key};";
server = {
http_addr = "0.0.0.0";
http_port = 3000;
enable_gzip = true;
domain = "192.168.132.149";
};
analytics.reporting_enabled = false;
};
};
services.prometheus = {
enable = true;
globalConfig.scrape_interval = "10s";
scrapeConfigs = [
{
job_name = "navidrome";
scheme = "http";
metrics_path = "/metrics";
static_configs = [
{
targets = [ "localhost:4533" ];
}
];
}
];
};
}
+25
View File
@@ -0,0 +1,25 @@
{ lib, ... }:
{
services.navidrome = {
enable = true;
user = "user";
openFirewall = true;
settings = {
MusicFolder = "/home/user/Music";
PlaylistsPath = "Playlists";
Address = "0.0.0.0";
ScanSchedule = "@daily";
EnableInsightsCollector = false;
Scanner.PurgeMissing = "always";
CoverArtPriority = "embedded, cover.*, folder.*, front.*, jacket.*, *, external";
pid.album = "folder";
Subsonic.DefaultReportRealPath = true;
prometheus.enabled = true;
};
};
systemd.services.navidrome.serviceConfig = {
ProtectHome = lib.mkForce false;
};
}
+31
View File
@@ -0,0 +1,31 @@
{ pkgs, ... }:
{
systemd.timers."bc-wishlist-scraper" = {
wantedBy = [ "timers.target" ];
timerConfig = {
OnCalendar = "daily";
Unit = "bc-wishlist-scraper.service";
};
};
systemd.services."bc-wishlist-scraper" = {
script = ''
${pkgs.bash}/bin/bash /home/user/bc-wishlist-scraper/run.sh
'';
};
systemd.user.timers."scdl" = {
wantedBy = [ "timers.target" ];
timerConfig = {
OnCalendar = "daily";
Unit = "scdl.service";
};
};
systemd.user.services."scdl" = {
script = ''
cd ~/Music/scdl && ${pkgs.scdl}/bin/scdl me -f -c --download-archive archive.txt
'';
};
}
+7
View File
@@ -0,0 +1,7 @@
{
imports = [
./garage.nix
./smb.nix
./nfs.nix
];
}
+29
View File
@@ -0,0 +1,29 @@
{ pkgs, ... }:
{
services.garage = {
enable = false;
package = pkgs.garage;
environmentFile = "/home/user/garage_secrets";
settings = {
db_engine = "sqlite";
rpc_bind_addr = "0.0.0.0:3901";
# rpc_public_addr = "garage.example.com:3901";
replication_factor = 1;
s3_api = {
s3_region = "garage";
api_bind_addr = "0.0.0.0:3900";
};
# s3_web = {
# bind_addr = "0.0.0.0:3902";
# };
admin = {
api_bind_addr = "0.0.0.0:3903";
};
};
};
}
+15
View File
@@ -0,0 +1,15 @@
{
services.nfs.server = {
enable = true;
exports = {
"/media/music" = {
"192.168.132.0/24" = [
"rw"
"async"
"no_subtree_check"
"fsid=1"
];
};
};
};
}
+24
View File
@@ -0,0 +1,24 @@
{
services.samba = {
enable = true;
openFirewall = true;
settings = {
global = {
"workgroup" = "WORKGROUP";
"server string" = "smbnix";
"security" = "user";
"interfaces" = "lo eno1 tailscale0";
"hosts allow" = "192.168.132.0/24 100.64.0.0/10 127.0.0.1 localhost";
"hosts deny" = "0.0.0.0/0";
"guest account" = "nobody";
};
"Music" = {
"path" = "/media/music";
"browseable" = "yes";
"read only" = "no";
"guest ok" = "no";
"valid users" = "user";
};
};
};
}
+120
View File
@@ -0,0 +1,120 @@
{ pkgs, ... }:
{
services.slskd = {
enable = true;
environmentFile = /run/secrets/slskd_secrets;
openFirewall = true;
user = "user";
settings = {
remote_file_management = true;
directories = {
downloads = "/media/music/Soulseek";
};
shares = {
directories = [
"/media/music/Tracks"
"/media/music/Tracks2"
"/media/music/samples"
];
};
rooms = [
"Rare Music"
"nicotine"
"! ! LGBTQ+ ! !"
"lossless"
"Linux"
"Breakcore"
"Jungle"
];
transfers = {
upload = {
speed_limit = 3700;
};
groups = {
blacklisted = {
members = [
"relay"
"smbd"
];
};
user_defined = {
my_buddies = {
upload = {
priority = 1;
strategy = "firstinfirstout";
slots = 1000;
};
members = [
"noamifur"
"mesityl"
"diphenhydramine"
"monfi"
];
};
};
};
};
soulseek = {
description = ''
Fuck DRM. Fuck Spotify
Discord: keksnino
https://www.last.fm/user/KeksNino
also check out @musicpuppy
'';
listen_port = 32895;
};
feature = {
swagger = true;
};
integrations = {
webhooks = {
discord_relay = {
call = {
url = "http://localhost:5001/slskd_webhook";
};
on = [ "UploadFileComplete" ];
timeout = 5000;
retry = {
attempts = 3;
};
};
};
};
retention = {
files = {
incomplete = 20160;
};
};
};
};
systemd.user.services.slskd-speed = {
enable = true;
description = "Soulseek True Speed Shower";
after = [ "network-online.target" ];
wants = [ "network-online.target" ];
wantedBy = [ "multi-user.target" ];
serviceConfig = {
Type = "simple";
Environment = "PYTHONUNBUFFERED=1";
Restart = "on-failure";
RestartSec = 30;
StandardOutput = "journal";
StandardError = "journal";
EnvironmentFile = "/run/secrets/slskd_secrets";
ExecStart = ''
${pkgs.python3}/bin/python3 /home/user/slskd-speed.py \
-u "$SLSKD_SLSK_USERNAME" \
-p "$SLSKD_SLSK_PASSWORD" \
-s 30mbit/s \
--slskd-url http://localhost:5030 \
--slskd-key "$SLSKD_API_KEY" \
--loop \
--poll-interval 30 \
--interval 900
'';
};
};
}
+43
View File
@@ -0,0 +1,43 @@
{
boot.loader.grub = {
enable = true;
zfsSupport = true;
efiSupport = true;
efiInstallAsRemovable = true;
mirroredBoots = [
{
devices = [ "nodev" ];
path = "/boot";
}
];
};
fileSystems."/" = {
device = "zpool/root";
fsType = "zfs";
};
fileSystems."/nix" = {
device = "zpool/nix";
fsType = "zfs";
};
fileSystems."/var" = {
device = "zpool/var";
fsType = "zfs";
};
fileSystems."/home" = {
device = "zpool/home";
fsType = "zfs";
};
fileSystems."/boot" = {
device = "/dev/disk/by-uuid/FCFD-4472";
fsType = "vfat";
};
boot.zfs.forceImportRoot = false;
services.zfs.autoScrub.enable = true;
swapDevices = [ ];
services.zfs.autoSnapshot = {
enable = true;
};
}
+60
View File
@@ -0,0 +1,60 @@
{ options, pkgs, ... }:
{
programs.appimage = {
enable = true;
binfmt = true;
package = pkgs.appimage-run.override {
extraPkgs =
pkgs: with pkgs; [
zstd
libgpg-error
];
};
};
hardware.graphics.enable = true;
hardware.graphics.enable32Bit = true;
services.hardware.openrgb.enable = true;
hardware.bluetooth = {
enable = true;
powerOnBoot = false;
};
networking = {
hostName = "nixos-desktop";
networkmanager.enable = true;
firewall.enable = false;
wg-quick.interfaces.wg0.configFile = "/etc/wireguard/wg0.conf";
};
programs.nh = {
enable = true;
flake = "/home/user/nix-config";
};
programs.nix-ld = {
enable = true;
libraries =
options.programs.nix-ld.libraries.default
++ (with pkgs; [
dbus # libdbus-1.so.3
fontconfig # libfontconfig.so.1
freetype # libfreetype.so.6
glib # libglib-2.0.so.0
libGL # libGL.so.1
libxkbcommon # libxkbcommon.so.0
libx11 # libX11.so.6
wayland
krb5
qt6.qtdeclarative
qt6.qtbase
qt6.qtwayland
brotli
webkitgtk_6_0
gtk4
libsoup_3
]);
};
}
+14
View File
@@ -0,0 +1,14 @@
{ pkgs, ... }:
{
programs.virt-manager.enable = true;
users.groups.libvirtd.members = [ "user" ];
virtualisation.libvirtd = {
enable = true;
qemu.vhostUserPackages = with pkgs; [ virtiofsd ];
};
virtualisation.spiceUSBRedirection.enable = true;
}