From 9bf329b9d148169e4a1c63a3e904994d999389c5 Mon Sep 17 00:00:00 2001 From: Nettika Date: Thu, 11 Jul 2024 19:18:29 -0700 Subject: [PATCH] Move mkHost helper into a separate module --- flake.nix | 25 +++++++------------------ hosts/marauder/default.nix | 10 ---------- hosts/monolith/default.nix | 21 +-------------------- lib/default.nix | 18 ++++++++++++++++++ modules/nixos/default.nix | 13 +++++++++---- modules/nixos/users.nix | 9 --------- 6 files changed, 35 insertions(+), 61 deletions(-) create mode 100644 lib/default.nix delete mode 100644 modules/nixos/users.nix diff --git a/flake.nix b/flake.nix index 5bf2f59..6047114 100644 --- a/flake.nix +++ b/flake.nix @@ -6,33 +6,22 @@ nixpkgs-unstable.url = "github:nixos/nixpkgs/nixos-unstable"; }; - outputs = { self, nixpkgs, nixpkgs-unstable } @inputs: + outputs = { nixpkgs, ... }@inputs: let - mkHost = { hostname, system, stateVersion }: nixpkgs.lib.nixosSystem { - system = system; - modules = [ - { - networking = { - hostName = hostname; - networkmanager.enable = true; - }; - system.stateVersion = stateVersion; - } - ./modules/nixos - ./hosts/${hostname} - ]; - specialArgs = { inherit inputs; }; - }; + utils = import ./lib { inherit inputs; }; + inherit (utils) mkHost; in { nixosConfigurations = { marauder = mkHost { - hostname = "marauder"; + hostName = "marauder"; system = "x86_64-linux"; + timeZone = "America/Los_Angeles"; stateVersion = "24.05"; }; monolith = mkHost { - hostname = "monolith"; + hostName = "monolith"; system = "x86_64-linux"; + timeZone = "America/Los_Angeles"; stateVersion = "24.05"; }; }; diff --git a/hosts/marauder/default.nix b/hosts/marauder/default.nix index 13625a2..c97e4f3 100644 --- a/hosts/marauder/default.nix +++ b/hosts/marauder/default.nix @@ -5,18 +5,10 @@ ./backup.nix ./boot.nix ./hardware.nix - ../../modules/nixos ]; - time.timeZone = "America/Los_Angeles"; - nixpkgs.config.allowUnfree = true; - nix.settings.experimental-features = [ - "nix-command" - "flakes" - ]; - services = { xserver = { enable = true; @@ -27,6 +19,4 @@ }; displayManager.defaultSession = "cinnamon"; }; - - system.stateVersion = "24.05"; } diff --git a/hosts/monolith/default.nix b/hosts/monolith/default.nix index 393fdee..c157af7 100644 --- a/hosts/monolith/default.nix +++ b/hosts/monolith/default.nix @@ -1,20 +1 @@ -{ config, lib, pkgs, inputs, outputs, ... }: -{ - imports = [ - outputs.nixosModules - ]; - - time.timeZone = "America/Los_Angeles"; - - nix.settings.experimental-features = [ - "nix-command" - "flakes" - ]; - - networking = { - hostName = "monolith"; - networkmanager.enable = true; - }; - - system.stateVersion = "24.05"; -} +{ ... }: {} diff --git a/lib/default.nix b/lib/default.nix new file mode 100644 index 0000000..ec615cf --- /dev/null +++ b/lib/default.nix @@ -0,0 +1,18 @@ +{ inputs }: { + mkHost = { hostName, system, timeZone, stateVersion }: inputs.nixpkgs.lib.nixosSystem { + inherit system; + modules = [ + { + networking.hostName = hostName; + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + system.stateVersion = stateVersion; + time.timeZone = timeZone; + } + ../modules/nixos + ../hosts/${hostName} + ]; + specialArgs = { + inherit inputs; + }; + }; +} \ No newline at end of file diff --git a/modules/nixos/default.nix b/modules/nixos/default.nix index 3e79d7a..d3fe075 100644 --- a/modules/nixos/default.nix +++ b/modules/nixos/default.nix @@ -1,6 +1,11 @@ -{ ... }: +{ options, config, lib, ... }: { - imports = [ - ./users.nix - ]; + users.users = { + nettika = { + isNormalUser = true; + extraGroups = [ "wheel" "networkmanager" ]; + }; + }; + + networking.networkmanager.enable = true; } \ No newline at end of file diff --git a/modules/nixos/users.nix b/modules/nixos/users.nix deleted file mode 100644 index 39d0e50..0000000 --- a/modules/nixos/users.nix +++ /dev/null @@ -1,9 +0,0 @@ -{ ... }: -{ - users.users = { - nettika = { - isNormalUser = true; - extraGroups = [ "wheel" "networkmanager" ]; - }; - }; -}