From 5944fe5cca787f4faeba40b92c199dc91026376b Mon Sep 17 00:00:00 2001 From: Vinzenz Schroeter Date: Sat, 26 Oct 2024 12:32:15 +0200 Subject: [PATCH] split config --- flake.nix | 19 +- home/{gnome-home.nix => gnome.nix} | 3 + home/ronja-home.nix | 2 +- home/vinzenz-home.nix | 248 --------------------- home/vinzenz/default.nix | 104 +++++++++ home/vinzenz/git.nix | 16 ++ home/vinzenz/ssh.nix | 47 ++++ home/vinzenz/vscode.nix | 46 ++++ home/vinzenz/zsh.nix | 29 +++ hosts/vinzenz-lpt2/default.nix | 3 + hosts/vinzenz-lpt2/environment.nix | 14 +- hosts/vinzenz-lpt2/hardware.nix | 4 +- {hosts => modules}/desktop-environment.nix | 12 +- {hosts => modules}/desktop-hardware.nix | 0 {hosts => modules}/gaming.nix | 0 {hosts => modules}/gnome.nix | 0 {hosts => modules}/intel-graphics.nix | 0 {hosts => modules}/latex.nix | 0 {hosts => modules}/printing.nix | 0 19 files changed, 271 insertions(+), 276 deletions(-) rename home/{gnome-home.nix => gnome.nix} (98%) delete mode 100644 home/vinzenz-home.nix create mode 100644 home/vinzenz/default.nix create mode 100644 home/vinzenz/git.nix create mode 100644 home/vinzenz/ssh.nix create mode 100644 home/vinzenz/vscode.nix create mode 100644 home/vinzenz/zsh.nix rename {hosts => modules}/desktop-environment.nix (92%) rename {hosts => modules}/desktop-hardware.nix (100%) rename {hosts => modules}/gaming.nix (100%) rename {hosts => modules}/gnome.nix (100%) rename {hosts => modules}/intel-graphics.nix (100%) rename {hosts => modules}/latex.nix (100%) rename {hosts => modules}/printing.nix (100%) diff --git a/flake.nix b/flake.nix index c5c9d20..d50aed4 100644 --- a/flake.nix +++ b/flake.nix @@ -16,16 +16,21 @@ home-manager, lix-module, ... - }: { + }: let + common-modules = [ + lix-module.nixosModules.default + home-manager.nixosModules.home-manager + ./common + ]; + in { nixosConfigurations = { vinzenz-lpt2 = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; - modules = [ - lix-module.nixosModules.default - home-manager.nixosModules.home-manager - ./common - ./hosts/vinzenz-lpt2 - ]; + modules = + common-modules + ++ [ + ./hosts/vinzenz-lpt2 + ]; }; }; }; diff --git a/home/gnome-home.nix b/home/gnome.nix similarity index 98% rename from home/gnome-home.nix rename to home/gnome.nix index e82151c..828c0ce 100644 --- a/home/gnome-home.nix +++ b/home/gnome.nix @@ -4,6 +4,9 @@ pkgs, ... }: { + imports = [ + ../modules/gnome.nix + ]; config = { home-manager.sharedModules = [ { diff --git a/home/ronja-home.nix b/home/ronja-home.nix index aed4e1e..0457204 100644 --- a/home/ronja-home.nix +++ b/home/ronja-home.nix @@ -3,7 +3,7 @@ pkgs, ... }: { - home .packages = with pkgs; [ + home.packages = with pkgs; [ ## Apps telegram-desktop kdiff3 diff --git a/home/vinzenz-home.nix b/home/vinzenz-home.nix deleted file mode 100644 index 883d538..0000000 --- a/home/vinzenz-home.nix +++ /dev/null @@ -1,248 +0,0 @@ -{ - config, - osConfig, - pkgs, - lib, - ... -}: let - isGnomeEnabled = osConfig.my.desktop.enableGnome; -in - lib.mkMerge [ - { - home.packages = with pkgs; [ - keepassxc - insync - - telegram-desktop - element-desktop - - wireguard-tools - wirelesstools - - alejandra # nix formatter - - arduino - uucp - - kdiff3 - jetbrains-toolbox - ]; - - programs = { - home-manager.enable = true; - - fzf.enable = true; - - zsh = { - initExtra = '' - eval "$(direnv hook zsh)"; - export PATH=$PATH:/home/vinzenz/.cargo/bin - ''; - - shellAliases = { - my-apply = "sudo nixos-rebuild boot"; - my-switch = "sudo nixos-rebuild switch"; - my-update = "sudo nixos-rebuild boot --upgrade"; - my-pull = "git -C ~/Repos/nixos-configuration pull --rebase"; - my-fmt = "alejandra ."; - my-test = "sudo nixos-rebuild test"; - my-direnvallow = "echo \"use nix\" > .envrc && direnv allow"; - my-ip4 = "ip addr show | grep 192"; - }; - - history = { - size = 10000; - path = "${config.xdg.dataHome}/zsh/history"; - expireDuplicatesFirst = true; - }; - - oh-my-zsh = { - enable = true; - theme = "agnoster"; - plugins = ["git" "sudo" "docker" "systemadmin"]; - }; - }; - - git = { - enable = true; - userName = "Vinzenz Schroeter"; - userEmail = "vinzenz.f.s@gmail.com"; - - aliases = { - prettylog = "log --pretty=oneline --graph"; - spring-clean = "!git branch --merged | xargs -n 1 -r git branch -d"; - }; - - extraConfig = { - pull.ff = "only"; - merge.tool = "kdiff3"; - push.autoSetupRemote = "true"; - }; - }; - - vscode = { - enable = true; - package = pkgs.vscodium; - enableUpdateCheck = false; - extensions = with pkgs.vscode-extensions; [ - bbenoist.nix - ms-python.python - kamadorueda.alejandra - editorconfig.editorconfig - yzhang.markdown-all-in-one - redhat.vscode-yaml - pkief.material-icon-theme - mhutchie.git-graph - rust-lang.rust-analyzer - tamasfe.even-better-toml - llvm-vs-code-extensions.vscode-clangd - mkhl.direnv - vadimcn.vscode-lldb - ms-dotnettools.csharp - ]; - userSettings = { - "git.autofetch" = true; - "update.mode" = "none"; - "editor.fontFamily" = "'Fira Code', 'Droid Sans Mono', 'monospace', monospace"; - "editor.fontLigatures" = true; - "editor.formatOnSave" = true; - "editor.formatOnSaveMode" = "modificationsIfAvailable"; - "editor.minimap.autohide" = true; - "diffEditor.diffAlgorithm" = "advanced"; - "explorer.excludeGitIgnore" = true; - "markdown.extension.tableFormatter.normalizeIndentation" = true; - "markdown.extension.toc.orderedList" = false; - "telemetry.telemetryLevel" = "off"; - "redhat.telemetry.enabled" = false; - "workbench.startupEditor" = "readme"; - "workbench.enableExperiments" = false; - "workbench.iconTheme" = "material-icon-theme"; - "rust-analyzer.checkOnSave.command" = "clippy"; - "extensions.autoUpdate" = false; - "extensions.autoCheckUpdates" = false; - "\[makefile\]" = { - "editor.insertSpaces" = false; - "editor.detectIndentation" = false; - }; - }; - }; - - direnv = { - enable = true; - nix-direnv.enable = true; - }; - - chromium = { - enable = true; - extensions = [ - { - # ublock origin - id = "cjpalhdlnbpafiamejdnhcphjbkeiagm"; - } - { - id = "dcpihecpambacapedldabdbpakmachpb"; - updateUrl = "https://raw.githubusercontent.com/iamadamdev/bypass-paywalls-chrome/master/updates.xml"; - } - ]; - }; - - eza = { - enable = true; - git = true; - icons = true; - extraOptions = [ - "--group-directories-first" - "--header" - ]; - }; - - # checked https://rycee.gitlab.io/home-manager/options.html until "programs.notmuch" - - ssh = { - enable = true; - matchBlocks = { - "vpn1" = { - host = "vpn1 hetzner-vpn1"; - hostname = "157.90.146.125"; # 2a01:4f8:c012:7137::/64 - user = "root"; - }; - "vpn1-ts" = { - host = "vpn1-ts hetzner-vpn1.donkey-pentatonic.ts.net"; - hostname = "hetzner-vpn1.donkey-pentatonic.ts.net"; - user = "root"; - }; - "openwrt" = { - host = "openwrt openwrt.lan"; - hostname = "openwrt.lan"; - user = "root"; - }; - "openwrt-ts" = { - hostname = "openwrt.donkey-pentatonic.ts.net"; - port = 2222; - user = "root"; - }; - "openwrt-j" = { - hostname = "openwrt.donkey-pentatonic.ts.net"; - proxyJump = "vpn1"; - port = 2222; - user = "root"; - }; - "pc2-power" = { - hostname = "openwrt.donkey-pentatonic.ts.net"; - proxyJump = "vpn1"; - port = 2222; - user = "pc2-power"; - }; - "avd-power" = { - # hostname = "2001:678:560:23:9833:63ff:fe2d:f477" - # hostname = "195.160.172.25"; - hostname = "avd-jumphost.club.berlin.ccc.de"; - user = "power"; - }; - "avd" = { - hostname = "avd.club.berlin.ccc.de"; - user = "vinzenz"; - }; - }; - }; - }; - - editorconfig = { - enable = true; - settings = { - "*" = { - charset = "utf-8"; - end_of_line = "lf"; - trim_trailing_whitespace = true; - insert_final_newline = true; - max_line_width = 120; - indent_style = "space"; - indent_size = 4; - }; - "*.nix" = { - indent_size = 2; - }; - }; - }; - - home.file."policy.json" = { - target = ".config/containers/policy.json"; - text = '' - { - "default": [ - { - "type": "insecureAcceptAnything" - } - ], - "transports": - { - "docker-daemon": - { - "": [{"type":"insecureAcceptAnything"}] - } - } - } - ''; - }; - } - ] diff --git a/home/vinzenz/default.nix b/home/vinzenz/default.nix new file mode 100644 index 0000000..a10b7ca --- /dev/null +++ b/home/vinzenz/default.nix @@ -0,0 +1,104 @@ +inputs @ { + config, + osConfig, + pkgs, + lib, + ... +}: let + isGnomeEnabled = osConfig.my.desktop.enableGnome; +in { + programs = { + home-manager.enable = true; + fzf.enable = true; + zsh = import ./zsh.nix inputs; + git = import ./git.nix; + vscode = import ./vscode.nix inputs; + ssh = import ./ssh.nix; + + direnv = { + enable = true; + nix-direnv.enable = true; + }; + + chromium = { + enable = true; + extensions = [ + { + # ublock origin + id = "cjpalhdlnbpafiamejdnhcphjbkeiagm"; + } + { + id = "dcpihecpambacapedldabdbpakmachpb"; + updateUrl = "https://raw.githubusercontent.com/iamadamdev/bypass-paywalls-chrome/master/updates.xml"; + } + ]; + }; + + eza = { + enable = true; + git = true; + icons = true; + extraOptions = [ + "--group-directories-first" + "--header" + ]; + }; + }; + + home.packages = with pkgs; [ + keepassxc + insync + + telegram-desktop + element-desktop + + wireguard-tools + wirelesstools + + alejandra # nix formatter + + arduino + uucp + + kdiff3 + jetbrains-toolbox + ]; + + editorconfig = { + enable = true; + settings = { + "*" = { + charset = "utf-8"; + end_of_line = "lf"; + trim_trailing_whitespace = true; + insert_final_newline = true; + max_line_width = 120; + indent_style = "space"; + indent_size = 4; + }; + "*.nix" = { + indent_size = 2; + }; + }; + }; + + home.file."policy.json" = { + target = ".config/containers/policy.json"; + text = '' + { + "default": [ + { + "type": "insecureAcceptAnything" + } + ], + "transports": + { + "docker-daemon": + { + "": [{"type":"insecureAcceptAnything"}] + } + } + } + ''; + }; +} diff --git a/home/vinzenz/git.nix b/home/vinzenz/git.nix new file mode 100644 index 0000000..bb64f13 --- /dev/null +++ b/home/vinzenz/git.nix @@ -0,0 +1,16 @@ +{ + enable = true; + userName = "Vinzenz Schroeter"; + userEmail = "vinzenz.f.s@gmail.com"; + + aliases = { + prettylog = "log --pretty=oneline --graph"; + spring-clean = "!git branch --merged | xargs -n 1 -r git branch -d"; + }; + + extraConfig = { + pull.ff = "only"; + merge.tool = "kdiff3"; + push.autoSetupRemote = "true"; + }; +} diff --git a/home/vinzenz/ssh.nix b/home/vinzenz/ssh.nix new file mode 100644 index 0000000..360958e --- /dev/null +++ b/home/vinzenz/ssh.nix @@ -0,0 +1,47 @@ +{ + enable = true; + matchBlocks = { + "vpn1" = { + host = "vpn1 hetzner-vpn1"; + hostname = "157.90.146.125"; # 2a01:4f8:c012:7137::/64 + user = "root"; + }; + "vpn1-ts" = { + host = "vpn1-ts hetzner-vpn1.donkey-pentatonic.ts.net"; + hostname = "hetzner-vpn1.donkey-pentatonic.ts.net"; + user = "root"; + }; + "openwrt" = { + host = "openwrt openwrt.lan"; + hostname = "openwrt.lan"; + user = "root"; + }; + "openwrt-ts" = { + hostname = "openwrt.donkey-pentatonic.ts.net"; + port = 2222; + user = "root"; + }; + "openwrt-j" = { + hostname = "openwrt.donkey-pentatonic.ts.net"; + proxyJump = "vpn1"; + port = 2222; + user = "root"; + }; + "pc2-power" = { + hostname = "openwrt.donkey-pentatonic.ts.net"; + proxyJump = "vpn1"; + port = 2222; + user = "pc2-power"; + }; + "avd-power" = { + # hostname = "2001:678:560:23:9833:63ff:fe2d:f477" + # hostname = "195.160.172.25"; + hostname = "avd-jumphost.club.berlin.ccc.de"; + user = "power"; + }; + "avd" = { + hostname = "avd.club.berlin.ccc.de"; + user = "vinzenz"; + }; + }; +} diff --git a/home/vinzenz/vscode.nix b/home/vinzenz/vscode.nix new file mode 100644 index 0000000..e88cef4 --- /dev/null +++ b/home/vinzenz/vscode.nix @@ -0,0 +1,46 @@ +{pkgs, ...}: { + enable = true; + package = pkgs.vscodium; + enableUpdateCheck = false; + extensions = with pkgs.vscode-extensions; [ + bbenoist.nix + ms-python.python + kamadorueda.alejandra + editorconfig.editorconfig + yzhang.markdown-all-in-one + redhat.vscode-yaml + pkief.material-icon-theme + mhutchie.git-graph + rust-lang.rust-analyzer + tamasfe.even-better-toml + llvm-vs-code-extensions.vscode-clangd + mkhl.direnv + vadimcn.vscode-lldb + ms-dotnettools.csharp + ]; + userSettings = { + "git.autofetch" = true; + "update.mode" = "none"; + "editor.fontFamily" = "'Fira Code', 'Droid Sans Mono', 'monospace', monospace"; + "editor.fontLigatures" = true; + "editor.formatOnSave" = true; + "editor.formatOnSaveMode" = "modificationsIfAvailable"; + "editor.minimap.autohide" = true; + "diffEditor.diffAlgorithm" = "advanced"; + "explorer.excludeGitIgnore" = true; + "markdown.extension.tableFormatter.normalizeIndentation" = true; + "markdown.extension.toc.orderedList" = false; + "telemetry.telemetryLevel" = "off"; + "redhat.telemetry.enabled" = false; + "workbench.startupEditor" = "readme"; + "workbench.enableExperiments" = false; + "workbench.iconTheme" = "material-icon-theme"; + "rust-analyzer.checkOnSave.command" = "clippy"; + "extensions.autoUpdate" = false; + "extensions.autoCheckUpdates" = false; + "\[makefile\]" = { + "editor.insertSpaces" = false; + "editor.detectIndentation" = false; + }; + }; +} diff --git a/home/vinzenz/zsh.nix b/home/vinzenz/zsh.nix new file mode 100644 index 0000000..c6d011c --- /dev/null +++ b/home/vinzenz/zsh.nix @@ -0,0 +1,29 @@ +{config, ...}: { + initExtra = '' + eval "$(direnv hook zsh)"; + export PATH=$PATH:/home/vinzenz/.cargo/bin + ''; + + shellAliases = { + my-apply = "sudo nixos-rebuild boot"; + my-switch = "sudo nixos-rebuild switch"; + my-update = "sudo nixos-rebuild boot --upgrade"; + my-pull = "git -C ~/Repos/nixos-configuration pull --rebase"; + my-fmt = "alejandra ."; + my-test = "sudo nixos-rebuild test"; + my-direnvallow = "echo \"use nix\" > .envrc && direnv allow"; + my-ip4 = "ip addr show | grep 192"; + }; + + history = { + size = 10000; + path = "${config.xdg.dataHome}/zsh/history"; + expireDuplicatesFirst = true; + }; + + oh-my-zsh = { + enable = true; + theme = "agnoster"; + plugins = ["git" "sudo" "docker" "systemadmin"]; + }; +} diff --git a/hosts/vinzenz-lpt2/default.nix b/hosts/vinzenz-lpt2/default.nix index d8c409e..20b21b3 100644 --- a/hosts/vinzenz-lpt2/default.nix +++ b/hosts/vinzenz-lpt2/default.nix @@ -3,4 +3,7 @@ ./hardware.nix ./environment.nix ]; + config = { + networking.hostName = "vinzenz-lpt2"; + }; } diff --git a/hosts/vinzenz-lpt2/environment.nix b/hosts/vinzenz-lpt2/environment.nix index 8b9e6c1..e85de40 100644 --- a/hosts/vinzenz-lpt2/environment.nix +++ b/hosts/vinzenz-lpt2/environment.nix @@ -1,17 +1,17 @@ {pkgs, ...}: { imports = [ ../../home - ../../home/gnome-home.nix + ../../home/gnome.nix ../../users/vinzenz.nix - ../desktop-environment.nix - ../gnome.nix - ../gaming.nix - ../printing.nix - ../latex.nix + ../../modules/desktop-environment.nix + ../../modules/gnome.nix + ../../modules/gaming.nix + ../../modules/printing.nix + ../../modules/latex.nix ]; config = { - home-manager.users.vinzenz = import ../../home/vinzenz-home.nix; + home-manager.users.vinzenz = import ../../home/vinzenz; virtualisation = { containers.enable = true; diff --git a/hosts/vinzenz-lpt2/hardware.nix b/hosts/vinzenz-lpt2/hardware.nix index 610d40f..4e11ab5 100644 --- a/hosts/vinzenz-lpt2/hardware.nix +++ b/hosts/vinzenz-lpt2/hardware.nix @@ -4,8 +4,8 @@ ... }: { imports = [ - ../desktop-hardware.nix - ../intel-graphics.nix + ../../modules/desktop-hardware.nix + ../../modules/intel-graphics.nix ]; config = { # intel cpu diff --git a/hosts/desktop-environment.nix b/modules/desktop-environment.nix similarity index 92% rename from hosts/desktop-environment.nix rename to modules/desktop-environment.nix index 97fb613..fa0e1b9 100644 --- a/hosts/desktop-environment.nix +++ b/modules/desktop-environment.nix @@ -6,18 +6,10 @@ }: { config = { services = { - # Enable the X11 windowing system / wayland depending on DE - xserver = { - enable = true; - }; - + xserver.enable = true; libinput.enable = true; - - # flatpak xdg-portal-kde crashes, otherwise this would be global flatpak.enable = true; - fstrim.enable = true; - earlyoom = { enable = true; freeMemThreshold = 5; @@ -106,8 +98,6 @@ hunspell hunspellDicts.de-de hunspellDicts.en-us-large - - gnumake ]; nixpkgs.config.permittedInsecurePackages = []; diff --git a/hosts/desktop-hardware.nix b/modules/desktop-hardware.nix similarity index 100% rename from hosts/desktop-hardware.nix rename to modules/desktop-hardware.nix diff --git a/hosts/gaming.nix b/modules/gaming.nix similarity index 100% rename from hosts/gaming.nix rename to modules/gaming.nix diff --git a/hosts/gnome.nix b/modules/gnome.nix similarity index 100% rename from hosts/gnome.nix rename to modules/gnome.nix diff --git a/hosts/intel-graphics.nix b/modules/intel-graphics.nix similarity index 100% rename from hosts/intel-graphics.nix rename to modules/intel-graphics.nix diff --git a/hosts/latex.nix b/modules/latex.nix similarity index 100% rename from hosts/latex.nix rename to modules/latex.nix diff --git a/hosts/printing.nix b/modules/printing.nix similarity index 100% rename from hosts/printing.nix rename to modules/printing.nix