From d7ce40ffa759adaefc4280a6f15e59c995cdd1ae Mon Sep 17 00:00:00 2001 From: Henri Dohmen Date: Mon, 21 Apr 2025 22:48:50 +0200 Subject: [PATCH] refactor --- flake.nix | 5 +++-- host/c2/default.nix | 2 +- host/solo/default.nix | 6 +++--- mod/default.nix => lib.nix | 13 +++++-------- mod/collections/{pc-common.nix => pc.nix} | 9 +++++---- mod/network.nix | 2 ++ mod/{nix.nix => nix-configuration.nix} | 0 mod/services.nix | 1 - mod/software/development.nix | 18 ++++++++++++++++++ mod/{ => software}/games.nix | 1 - mod/{ => software}/keyboard.nix | 0 mod/{software.nix => software/programs.nix} | 9 +-------- mod/{ => software}/shell.nix | 2 -- mod/{ => software}/window-manager.nix | 0 14 files changed, 38 insertions(+), 30 deletions(-) rename mod/default.nix => lib.nix (70%) rename mod/collections/{pc-common.nix => pc.nix} (53%) rename mod/{nix.nix => nix-configuration.nix} (100%) create mode 100644 mod/software/development.nix rename mod/{ => software}/games.nix (99%) rename mod/{ => software}/keyboard.nix (100%) rename mod/{software.nix => software/programs.nix} (83%) rename mod/{ => software}/shell.nix (96%) rename mod/{ => software}/window-manager.nix (100%) diff --git a/flake.nix b/flake.nix index afe0008..6c43d0b 100644 --- a/flake.nix +++ b/flake.nix @@ -17,8 +17,9 @@ }@inputs: let lib = nixpkgs.lib; - mod = import ./mod { inherit lib; }; - specialArgs = { inherit inputs mod; }; + lib' = import ./lib.nix { inherit lib; }; + mod = lib'.walk-dir ./mod; + specialArgs = { inherit inputs mod lib'; }; in { nixosConfigurations = { diff --git a/host/c2/default.nix b/host/c2/default.nix index 289e936..faad6d7 100644 --- a/host/c2/default.nix +++ b/host/c2/default.nix @@ -5,7 +5,7 @@ imports = with mod; [ - collections.pc-common + collections.pc ./hardware-configuration.nix ] ++ (with inputs.nixos-hardware.nixosModules; [ diff --git a/host/solo/default.nix b/host/solo/default.nix index e675554..1788bc9 100644 --- a/host/solo/default.nix +++ b/host/solo/default.nix @@ -5,10 +5,10 @@ services.xserver.enable = true; imports = with mod; [ - collections.pc-common - keyboard + collections.pc + software.keyboard + software.games nvidia-gpu - games ./hardware-configuration.nix ]; diff --git a/mod/default.nix b/lib.nix similarity index 70% rename from mod/default.nix rename to lib.nix index 049d6de..58b7e18 100644 --- a/mod/default.nix +++ b/lib.nix @@ -1,7 +1,6 @@ { lib, ... }: - -let - walk = +rec { + walk-dir = path: let dir = builtins.readDir path; @@ -12,10 +11,8 @@ let if value == "regular" then import (path + "/${name}") else if value == "directory" then - walk (path + "/${name}") + walk-dir (path + "/${name}") else - builtins.throw "Cannot handle item of type ${value}"; + builtins.throw "Item of type ${value} are unsupported."; }) dir; - -in -walk ./. +} diff --git a/mod/collections/pc-common.nix b/mod/collections/pc.nix similarity index 53% rename from mod/collections/pc-common.nix rename to mod/collections/pc.nix index f2ddca4..b9ea57c 100644 --- a/mod/collections/pc-common.nix +++ b/mod/collections/pc.nix @@ -6,12 +6,13 @@ fonts locale network - nix + nix-configuration security services - shell - software + software.development + software.programs + software.shell + software.window-manager users - window-manager ]; } diff --git a/mod/network.nix b/mod/network.nix index 7039c07..5c8df29 100644 --- a/mod/network.nix +++ b/mod/network.nix @@ -11,6 +11,8 @@ useRoutingFeatures = "client"; }; + systemd.services.NetworkManager-wait-online.enable = false; + networking.networkmanager.ensureProfiles.profiles = { "tuda-vpn" = { connection = { diff --git a/mod/nix.nix b/mod/nix-configuration.nix similarity index 100% rename from mod/nix.nix rename to mod/nix-configuration.nix diff --git a/mod/services.nix b/mod/services.nix index 52c8227..c3722ad 100644 --- a/mod/services.nix +++ b/mod/services.nix @@ -1,6 +1,5 @@ { ... }: { - systemd.services.NetworkManager-wait-online.enable = false; services.printing.enable = true; services.avahi = { enable = true; diff --git a/mod/software/development.nix b/mod/software/development.nix new file mode 100644 index 0000000..0db1648 --- /dev/null +++ b/mod/software/development.nix @@ -0,0 +1,18 @@ +{ pkgs, ... }: +{ + documentation.dev.enable = true; + + environment.systemPackages = with pkgs; [ + rustup + python313 + python313Packages.mypy + gcc + clang + gdb + gnumake + binutils + nixfmt-rfc-style + man-pages + man-pages-posix + ]; +} diff --git a/mod/games.nix b/mod/software/games.nix similarity index 99% rename from mod/games.nix rename to mod/software/games.nix index 830b445..8651eac 100644 --- a/mod/games.nix +++ b/mod/software/games.nix @@ -3,6 +3,5 @@ environment.systemPackages = with pkgs; [ runelite ]; - programs.steam.enable = true; } diff --git a/mod/keyboard.nix b/mod/software/keyboard.nix similarity index 100% rename from mod/keyboard.nix rename to mod/software/keyboard.nix diff --git a/mod/software.nix b/mod/software/programs.nix similarity index 83% rename from mod/software.nix rename to mod/software/programs.nix index c5deb6d..7d33bee 100644 --- a/mod/software.nix +++ b/mod/software/programs.nix @@ -35,15 +35,8 @@ obsidian ]; - dev = with pkgs; [ - rustup - python313 - gcc - binutils - ]; - in - editors ++ messengers ++ util ++ media ++ productivity ++ dev; + editors ++ messengers ++ util ++ media ++ productivity; virtualisation = { docker.enable = true; diff --git a/mod/shell.nix b/mod/software/shell.nix similarity index 96% rename from mod/shell.nix rename to mod/software/shell.nix index 95181f1..00ff1bd 100644 --- a/mod/shell.nix +++ b/mod/software/shell.nix @@ -10,7 +10,6 @@ docker-compose fd gh - gnumake htop killall ripgrep @@ -19,7 +18,6 @@ unzip wget wl-clipboard - nixfmt-rfc-style ]; programs = { diff --git a/mod/window-manager.nix b/mod/software/window-manager.nix similarity index 100% rename from mod/window-manager.nix rename to mod/software/window-manager.nix