From 1649951409142d939957f6d7d6fef4f6f081f7dc Mon Sep 17 00:00:00 2001 From: Nettika Date: Thu, 18 Jul 2024 21:50:11 -0700 Subject: [PATCH] Reorganize hosts and modules --- common/coding.nix | 31 ------------------------ common/default.nix | 7 ------ common/secrets.nix | 13 ---------- flake.nix | 20 +++++++-------- {marauder => hosts/marauder}/backup.nix | 0 {marauder => hosts/marauder}/default.nix | 19 ++++----------- {monolith => hosts/monolith}/default.nix | 16 +++--------- modules/common.nix | 29 ++++++++++++++++++++++ 8 files changed, 46 insertions(+), 89 deletions(-) delete mode 100644 common/coding.nix delete mode 100755 common/default.nix delete mode 100644 common/secrets.nix rename {marauder => hosts/marauder}/backup.nix (100%) rename {marauder => hosts/marauder}/default.nix (91%) rename {monolith => hosts/monolith}/default.nix (86%) create mode 100644 modules/common.nix diff --git a/common/coding.nix b/common/coding.nix deleted file mode 100644 index 1e59e5b..0000000 --- a/common/coding.nix +++ /dev/null @@ -1,31 +0,0 @@ -{ lib, config, ... }: -with lib; -{ - options = { - tools.coding = { - enable = mkEnableOption "Enable coding tools"; - }; - }; - - config = mkIf config.tools.coding.enable { - programs.git = { - enable = true; - lfs.enable = true; - config = { - init.defaultBranch = "master"; - user = { - email = "git@nettika.cat"; - name = "Nettika"; - }; - credential.helper = "store"; - }; - }; - programs.nano = { - enable = true; - nanorc = '' - set autoindent - set linenumbers - ''; - }; - }; -} diff --git a/common/default.nix b/common/default.nix deleted file mode 100755 index b22d840..0000000 --- a/common/default.nix +++ /dev/null @@ -1,7 +0,0 @@ -{ pkgs, lib, config, ... }: -{ - imports = [ - ./coding.nix - ./secrets.nix - ]; -} diff --git a/common/secrets.nix b/common/secrets.nix deleted file mode 100644 index 1ad301f..0000000 --- a/common/secrets.nix +++ /dev/null @@ -1,13 +0,0 @@ -{ lib, config, pkgs, ... }: -with lib; -{ - options = { - tools.secrets = { - enable = mkEnableOption "Enable secret-management tools"; - }; - }; - - config = mkIf config.tools.secrets.enable { - environment.systemPackages = [ pkgs.git-crypt ]; - }; -} diff --git a/flake.nix b/flake.nix index aaa37be..eb9c0dd 100755 --- a/flake.nix +++ b/flake.nix @@ -5,26 +5,24 @@ nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05"; }; - outputs = { nixpkgs, ... }@inputs: + outputs = { self, nixpkgs, ... }@inputs: let secrets = builtins.fromJSON (builtins.readFile ./secrets.json); in { + nixosModules = { + common = import ./modules/common.nix; + }; + nixosConfigurations = { marauder = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; - modules = [ - ./marauder - ./common - ]; - specialArgs = { inherit inputs secrets; }; + modules = [ ./hosts/marauder ]; + specialArgs = { inherit self inputs secrets; }; }; monolith = nixpkgs.lib.nixosSystem { system = "x86_64-linux"; - modules = [ - ./monolith - ./common - ]; - specialArgs = { inherit inputs secrets; }; + modules = [ ./hosts/monolith ]; + specialArgs = { inherit self inputs secrets; }; }; }; }; diff --git a/marauder/backup.nix b/hosts/marauder/backup.nix similarity index 100% rename from marauder/backup.nix rename to hosts/marauder/backup.nix diff --git a/marauder/default.nix b/hosts/marauder/default.nix similarity index 91% rename from marauder/default.nix rename to hosts/marauder/default.nix index 4b2124f..e73fda4 100755 --- a/marauder/default.nix +++ b/hosts/marauder/default.nix @@ -1,6 +1,9 @@ -{ pkgs, inputs, secrets, ... }: +{ self, pkgs, inputs, secrets, ... }: { - imports = [ ./backup.nix ]; + imports = [ + self.nixosModules.common + ./backup.nix + ]; networking.hostName = "marauder"; @@ -60,18 +63,6 @@ }; }; - nixpkgs.config.allowUnfree = true; - - nix.settings.experimental-features = [ "nix-command" "flakes" ]; - - tools.secrets = { - enable = true; - }; - - tools.coding = { - enable = true; - }; - environment.systemPackages = with pkgs; [ # Chat clients discord diff --git a/monolith/default.nix b/hosts/monolith/default.nix similarity index 86% rename from monolith/default.nix rename to hosts/monolith/default.nix index 11033e0..6927870 100755 --- a/monolith/default.nix +++ b/hosts/monolith/default.nix @@ -1,4 +1,6 @@ -{ pkgs, secrets, ... }: { +{ self, pkgs, secrets, ... }: { + imports = [ self.nixosModules.common ]; + networking = { hostName = "monolith"; hostId = "44551c32"; @@ -42,18 +44,6 @@ }; }; - nixpkgs.config.allowUnfree = true; - - nix.settings.experimental-features = [ "nix-command" "flakes" ]; - - tools.secrets = { - enable = true; - }; - - tools.coding = { - enable = true; - }; - services.openssh = { enable = true; settings.PasswordAuthentication = false; diff --git a/modules/common.nix b/modules/common.nix new file mode 100644 index 0000000..5971561 --- /dev/null +++ b/modules/common.nix @@ -0,0 +1,29 @@ +{ pkgs, ... }: +{ + nixpkgs.config.allowUnfree = true; + + nix.settings.experimental-features = [ "nix-command" "flakes" ]; + + programs.git = { + enable = true; + lfs.enable = true; + config = { + init.defaultBranch = "master"; + user = { + email = "git@nettika.cat"; + name = "Nettika"; + }; + credential.helper = "store"; + }; + }; + + programs.nano = { + enable = true; + nanorc = '' + set autoindent + set linenumbers + ''; + }; + + environment.systemPackages = [ pkgs.git-crypt ]; +}