diff --git a/.gitignore b/.gitignore index 727bc05..8e21b1d 100644 --- a/.gitignore +++ b/.gitignore @@ -1 +1,2 @@ .directory +result diff --git a/hetzner-vpn1.nix b/hetzner-vpn1.nix index 415b8cb..2c2f712 100644 --- a/hetzner-vpn1.nix +++ b/hetzner-vpn1.nix @@ -1,13 +1,13 @@ -{...}: { +{pkgs, ...}: { imports = [ - ./modules/server - (import ./modules/hardware "hetzner-vpn1") + (import ./modules { + hostName = "hetzner-vpn1"; + enableDesktop = false; + }) ]; config = { - my = { - server.enable = true; - }; + my.server.enable = true; users.users.root.openssh.authorizedKeys.keys = [ ''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICdYqY3Y1/f1bsAi5Qfyr/UWuX9ixu96IeAlhoQaJkbf'' diff --git a/modules/_common/default.nix b/modules/_common/default.nix deleted file mode 100644 index 6432356..0000000 --- a/modules/_common/default.nix +++ /dev/null @@ -1,6 +0,0 @@ -{...}: { - imports = [ - ./i18n.nix - ./nixpkgs.nix - ]; -} diff --git a/modules/default.nix b/modules/default.nix new file mode 100644 index 0000000..199fa07 --- /dev/null +++ b/modules/default.nix @@ -0,0 +1,16 @@ +modulesCfg: {lib, ...}: { + imports = + [ + ./i18n.nix + ./nixpkgs.nix + ./server.nix + ] + ++ (map (path: (import path modulesCfg)) [ + ./desktop + ./hardware + ]); + + config = { + my.modulesCfg = modulesCfg; + }; +} diff --git a/modules/desktop/default.nix b/modules/desktop/default.nix index f007c14..ea268fc 100644 --- a/modules/desktop/default.nix +++ b/modules/desktop/default.nix @@ -1,14 +1,14 @@ -{ +modulesCfg: { config, pkgs, lib, ... }: let + isEnabled = modulesCfg.enableDesktop; cfg = config.my.desktop; in { - imports = [ + imports = lib.optionals isEnabled [ - ../_common ./gnome.nix ./kde.nix ./vinzenz.nix @@ -16,9 +16,11 @@ in { ./gaming.nix ]; + options.my.modulesCfg.enableDesktop = lib.mkEnableOption "enable desktop module"; + options.my.desktop = { enable = lib.mkEnableOption "desktop"; - gnome .enable = lib.mkEnableOption "gnome desktop"; + gnome.enable = lib.mkEnableOption "gnome desktop"; kde.enable = lib.mkEnableOption "KDE desktop"; ronja.enable = lib.mkEnableOption "user ronja"; vinzenz.enable = lib.mkEnableOption "user vinzenz"; diff --git a/modules/hardware/common-desktop.nix b/modules/hardware/common-desktop.nix index 24df1ed..dea948e 100644 --- a/modules/hardware/common-desktop.nix +++ b/modules/hardware/common-desktop.nix @@ -1,9 +1,14 @@ { lib, pkgs, + config, ... -}: { - config = { +}: let + isEnabled = config.my.hardware.enableCommonDesktopSettings; +in { + options.my.hardware.enableCommonDesktopSettings = lib.mkEnableOption "common hw settings for desktops"; + + config = lib.mkIf isEnabled { boot = { kernelPackages = pkgs.linuxPackages_zen; kernelParams = ["quiet" "udev.log_level=3"]; diff --git a/modules/hardware/default.nix b/modules/hardware/default.nix index 3a06ecb..5e4911e 100644 --- a/modules/hardware/default.nix +++ b/modules/hardware/default.nix @@ -1,13 +1,20 @@ -hostName: { +modulesCfg: { modulesPath, lib, ... -}: { +}: let + hostName = modulesCfg.hostName; +in { imports = [ (modulesPath + "/installer/scan/not-detected.nix") (builtins.toString ./. + "/${hostName}.nix") + ./common-desktop.nix ]; + options.my.modulesCfg.hostName = lib.mkOption { + type = lib.types.str; + }; + config = { networking.hostName = hostName; diff --git a/modules/hardware/vinzenz-lpt.nix b/modules/hardware/vinzenz-lpt.nix index 3706421..152d804 100644 --- a/modules/hardware/vinzenz-lpt.nix +++ b/modules/hardware/vinzenz-lpt.nix @@ -1,9 +1,7 @@ {...}: { - imports = [ - ./common-desktop.nix - ]; - config = { + my.hardware.enableCommonDesktopSettings = true; + boot = { initrd.availableKernelModules = ["xhci_pci" "ehci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" "sdhci_pci"]; initrd.kernelModules = []; diff --git a/modules/hardware/vinzenz-pc2.nix b/modules/hardware/vinzenz-pc2.nix index 607d0f8..ccd65c6 100644 --- a/modules/hardware/vinzenz-pc2.nix +++ b/modules/hardware/vinzenz-pc2.nix @@ -1,9 +1,7 @@ {...}: { - imports = [ - ./common-desktop.nix - ]; - config = { + my.hardware.enableCommonDesktopSettings = true; + boot = { initrd.availableKernelModules = ["nvme" "xhci_pci" "ahci" "usbhid" "sd_mod"]; # "usb_storage" initrd.kernelModules = []; diff --git a/modules/_common/i18n.nix b/modules/i18n.nix similarity index 100% rename from modules/_common/i18n.nix rename to modules/i18n.nix diff --git a/modules/_common/nixpkgs.nix b/modules/nixpkgs.nix similarity index 100% rename from modules/_common/nixpkgs.nix rename to modules/nixpkgs.nix diff --git a/modules/server/default.nix b/modules/server.nix similarity index 96% rename from modules/server/default.nix rename to modules/server.nix index cc13278..f5bf2f5 100644 --- a/modules/server/default.nix +++ b/modules/server.nix @@ -6,10 +6,6 @@ }: let cfg = config.my.server; in { - imports = [ - ../_common - ]; - options.my.server = { enable = lib.mkEnableOption "server role"; }; diff --git a/vinzenz-lpt.nix b/vinzenz-lpt.nix index 641c2ac..f2e0586 100644 --- a/vinzenz-lpt.nix +++ b/vinzenz-lpt.nix @@ -1,17 +1,16 @@ {...}: { imports = [ - ./modules/desktop - (import ./modules/hardware "vinzenz-lpt") + (import ./modules { + hostName = "vinzenz-lpt"; + enableDesktop = true; + }) ]; config = { - my = { - desktop = { - enable = true; - gnome.enable = true; - vinzenz.enable = true; - gaming.enable = true; - }; + my.desktop = { + gnome.enable = true; + vinzenz.enable = true; + gaming.enable = true; }; # flatpak xdg-portal-kde crashes, otherwise this would be global diff --git a/vinzenz-pc2.nix b/vinzenz-pc2.nix index 61818a3..1d6243b 100644 --- a/vinzenz-pc2.nix +++ b/vinzenz-pc2.nix @@ -1,12 +1,13 @@ {pkgs, ...}: { imports = [ - ./modules/desktop - (import ./modules/hardware "vinzenz-pc2") + (import ./modules { + hostName = "vinzenz-pc2"; + enableDesktop = true; + }) ]; config = { my.desktop = { - enable = true; kde.enable = true; vinzenz.enable = true; ronja.enable = true;