From 40d91223a023635e609b4df4d65c090ef9940661 Mon Sep 17 00:00:00 2001 From: Jake Hillion Date: Wed, 11 Jan 2023 20:34:07 +0000 Subject: [PATCH] flake: cleanup host selection logic --- flake.nix | 65 +++++-------------- .../system | 1 + .../microserver.home.ts.hillion.co.uk/system | 1 + .../system | 1 + hosts/vm.strangervm.ts.hillion.co.uk/system | 1 + 5 files changed, 22 insertions(+), 47 deletions(-) create mode 100644 hosts/gendry.jakehillion-terminals.ts.hillion.co.uk/system create mode 100644 hosts/microserver.home.ts.hillion.co.uk/system create mode 100644 hosts/microserver.parents.ts.hillion.co.uk/system create mode 100644 hosts/vm.strangervm.ts.hillion.co.uk/system diff --git a/flake.nix b/flake.nix index 0b494ca..36cbfbe 100644 --- a/flake.nix +++ b/flake.nix @@ -10,53 +10,24 @@ description = "Hillion Nix flake"; outputs = { self, nixpkgs, nixpkgs-unstable, agenix }@inputs: { - nixosConfigurations."gendry.jakehillion-terminals.ts.hillion.co.uk" = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - specialArgs = inputs; - modules = [ - ./hosts/gendry.jakehillion-terminals.ts.hillion.co.uk/default.nix - agenix.nixosModule - { - system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev; - } - ]; - }; - - nixosConfigurations."vm.strangervm.ts.hillion.co.uk" = nixpkgs.lib.nixosSystem { - system = "x86_64-linux"; - specialArgs = inputs; - modules = [ - ./hosts/vm.strangervm.ts.hillion.co.uk/default.nix - agenix.nixosModule - { - system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev; - } - ]; - }; - - nixosConfigurations."microserver.parents.ts.hillion.co.uk" = nixpkgs.lib.nixosSystem { - system = "aarch64-linux"; - specialArgs = inputs; - modules = [ - ./hosts/microserver.parents.ts.hillion.co.uk/default.nix - agenix.nixosModule - { - system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev; - } - ]; - }; - - nixosConfigurations."microserver.home.ts.hillion.co.uk" = nixpkgs.lib.nixosSystem { - system = "aarch64-linux"; - specialArgs = inputs; - modules = [ - ./hosts/microserver.home.ts.hillion.co.uk/default.nix - agenix.nixosModule - { - system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev; - } - ]; - }; + nixosConfigurations = + let + fqdns = builtins.attrNames (builtins.readDir ./hosts); + mkHost = fqdn: + let system = builtins.readFile ./hosts/${fqdn}/system; in + nixpkgs.lib.nixosSystem { + inherit system; + specialArgs = inputs; + modules = [ + ./hosts/${fqdn}/default.nix + agenix.nixosModule + { + system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev; + } + ]; + }; + in + nixpkgs.lib.genAttrs fqdns mkHost; formatter."x86_64-linux" = nixpkgs.legacyPackages."x86_64-linux".nixpkgs-fmt; formatter."aarch64-darwin" = nixpkgs.legacyPackages."aarch64-darwin".nixpkgs-fmt; diff --git a/hosts/gendry.jakehillion-terminals.ts.hillion.co.uk/system b/hosts/gendry.jakehillion-terminals.ts.hillion.co.uk/system new file mode 100644 index 0000000..9bdfd5f --- /dev/null +++ b/hosts/gendry.jakehillion-terminals.ts.hillion.co.uk/system @@ -0,0 +1 @@ +x86_64-linux \ No newline at end of file diff --git a/hosts/microserver.home.ts.hillion.co.uk/system b/hosts/microserver.home.ts.hillion.co.uk/system new file mode 100644 index 0000000..ab65297 --- /dev/null +++ b/hosts/microserver.home.ts.hillion.co.uk/system @@ -0,0 +1 @@ +aarch64-linux \ No newline at end of file diff --git a/hosts/microserver.parents.ts.hillion.co.uk/system b/hosts/microserver.parents.ts.hillion.co.uk/system new file mode 100644 index 0000000..ab65297 --- /dev/null +++ b/hosts/microserver.parents.ts.hillion.co.uk/system @@ -0,0 +1 @@ +aarch64-linux \ No newline at end of file diff --git a/hosts/vm.strangervm.ts.hillion.co.uk/system b/hosts/vm.strangervm.ts.hillion.co.uk/system new file mode 100644 index 0000000..9bdfd5f --- /dev/null +++ b/hosts/vm.strangervm.ts.hillion.co.uk/system @@ -0,0 +1 @@ +x86_64-linux \ No newline at end of file