convoluted solution looking for a problem

unified modules structure
This commit is contained in:
Vinzenz Schroeter 2023-09-24 10:15:53 +02:00
parent bf3946e06f
commit 1b7989336e
14 changed files with 61 additions and 44 deletions

1
.gitignore vendored
View file

@ -1 +1,2 @@
.directory .directory
result

View file

@ -1,13 +1,13 @@
{...}: { {pkgs, ...}: {
imports = [ imports = [
./modules/server (import ./modules {
(import ./modules/hardware "hetzner-vpn1") hostName = "hetzner-vpn1";
enableDesktop = false;
})
]; ];
config = { config = {
my = { my.server.enable = true;
server.enable = true;
};
users.users.root.openssh.authorizedKeys.keys = [ users.users.root.openssh.authorizedKeys.keys = [
''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICdYqY3Y1/f1bsAi5Qfyr/UWuX9ixu96IeAlhoQaJkbf'' ''ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAICdYqY3Y1/f1bsAi5Qfyr/UWuX9ixu96IeAlhoQaJkbf''

View file

@ -1,6 +0,0 @@
{...}: {
imports = [
./i18n.nix
./nixpkgs.nix
];
}

16
modules/default.nix Normal file
View file

@ -0,0 +1,16 @@
modulesCfg: {lib, ...}: {
imports =
[
./i18n.nix
./nixpkgs.nix
./server.nix
]
++ (map (path: (import path modulesCfg)) [
./desktop
./hardware
]);
config = {
my.modulesCfg = modulesCfg;
};
}

View file

@ -1,14 +1,14 @@
{ modulesCfg: {
config, config,
pkgs, pkgs,
lib, lib,
... ...
}: let }: let
isEnabled = modulesCfg.enableDesktop;
cfg = config.my.desktop; cfg = config.my.desktop;
in { in {
imports = [ imports = lib.optionals isEnabled [
<home-manager/nixos> <home-manager/nixos>
../_common
./gnome.nix ./gnome.nix
./kde.nix ./kde.nix
./vinzenz.nix ./vinzenz.nix
@ -16,9 +16,11 @@ in {
./gaming.nix ./gaming.nix
]; ];
options.my.modulesCfg.enableDesktop = lib.mkEnableOption "enable desktop module";
options.my.desktop = { options.my.desktop = {
enable = lib.mkEnableOption "desktop"; enable = lib.mkEnableOption "desktop";
gnome .enable = lib.mkEnableOption "gnome desktop"; gnome.enable = lib.mkEnableOption "gnome desktop";
kde.enable = lib.mkEnableOption "KDE desktop"; kde.enable = lib.mkEnableOption "KDE desktop";
ronja.enable = lib.mkEnableOption "user ronja"; ronja.enable = lib.mkEnableOption "user ronja";
vinzenz.enable = lib.mkEnableOption "user vinzenz"; vinzenz.enable = lib.mkEnableOption "user vinzenz";

View file

@ -1,9 +1,14 @@
{ {
lib, lib,
pkgs, pkgs,
config,
... ...
}: { }: let
config = { isEnabled = config.my.hardware.enableCommonDesktopSettings;
in {
options.my.hardware.enableCommonDesktopSettings = lib.mkEnableOption "common hw settings for desktops";
config = lib.mkIf isEnabled {
boot = { boot = {
kernelPackages = pkgs.linuxPackages_zen; kernelPackages = pkgs.linuxPackages_zen;
kernelParams = ["quiet" "udev.log_level=3"]; kernelParams = ["quiet" "udev.log_level=3"];

View file

@ -1,13 +1,20 @@
hostName: { modulesCfg: {
modulesPath, modulesPath,
lib, lib,
... ...
}: { }: let
hostName = modulesCfg.hostName;
in {
imports = [ imports = [
(modulesPath + "/installer/scan/not-detected.nix") (modulesPath + "/installer/scan/not-detected.nix")
(builtins.toString ./. + "/${hostName}.nix") (builtins.toString ./. + "/${hostName}.nix")
./common-desktop.nix
]; ];
options.my.modulesCfg.hostName = lib.mkOption {
type = lib.types.str;
};
config = { config = {
networking.hostName = hostName; networking.hostName = hostName;

View file

@ -1,9 +1,7 @@
{...}: { {...}: {
imports = [
./common-desktop.nix
];
config = { config = {
my.hardware.enableCommonDesktopSettings = true;
boot = { boot = {
initrd.availableKernelModules = ["xhci_pci" "ehci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" "sdhci_pci"]; initrd.availableKernelModules = ["xhci_pci" "ehci_pci" "ahci" "usbhid" "usb_storage" "sd_mod" "sdhci_pci"];
initrd.kernelModules = []; initrd.kernelModules = [];

View file

@ -1,9 +1,7 @@
{...}: { {...}: {
imports = [
./common-desktop.nix
];
config = { config = {
my.hardware.enableCommonDesktopSettings = true;
boot = { boot = {
initrd.availableKernelModules = ["nvme" "xhci_pci" "ahci" "usbhid" "sd_mod"]; # "usb_storage" initrd.availableKernelModules = ["nvme" "xhci_pci" "ahci" "usbhid" "sd_mod"]; # "usb_storage"
initrd.kernelModules = []; initrd.kernelModules = [];

View file

@ -6,10 +6,6 @@
}: let }: let
cfg = config.my.server; cfg = config.my.server;
in { in {
imports = [
../_common
];
options.my.server = { options.my.server = {
enable = lib.mkEnableOption "server role"; enable = lib.mkEnableOption "server role";
}; };

View file

@ -1,17 +1,16 @@
{...}: { {...}: {
imports = [ imports = [
./modules/desktop (import ./modules {
(import ./modules/hardware "vinzenz-lpt") hostName = "vinzenz-lpt";
enableDesktop = true;
})
]; ];
config = { config = {
my = { my.desktop = {
desktop = { gnome.enable = true;
enable = true; vinzenz.enable = true;
gnome.enable = true; gaming.enable = true;
vinzenz.enable = true;
gaming.enable = true;
};
}; };
# flatpak xdg-portal-kde crashes, otherwise this would be global # flatpak xdg-portal-kde crashes, otherwise this would be global

View file

@ -1,12 +1,13 @@
{pkgs, ...}: { {pkgs, ...}: {
imports = [ imports = [
./modules/desktop (import ./modules {
(import ./modules/hardware "vinzenz-pc2") hostName = "vinzenz-pc2";
enableDesktop = true;
})
]; ];
config = { config = {
my.desktop = { my.desktop = {
enable = true;
kde.enable = true; kde.enable = true;
vinzenz.enable = true; vinzenz.enable = true;
ronja.enable = true; ronja.enable = true;