diff --git a/config/hosts.nix b/config/hosts.nix index 23c39cf..ea7997a 100644 --- a/config/hosts.nix +++ b/config/hosts.nix @@ -1,16 +1,8 @@ { config, lib, pkgs, ... }: -with lib; let - is-nix-file = filename: type: (builtins.match ".+\.nix$" filename) != null; - is-regular-file = filename: type: type == "regular" || type == "link"; - hostname-from-file = filename: builtins.replaceStrings [".nix"] [""] filename; - - host-files = attrNames (filterAttrs is-nix-file (filterAttrs is-regular-file (builtins.readDir ./hosts))); - hosts = map hostname-from-file host-files; + syslib = pkgs.callPackage ../lib/hosts.nix {}; - load-host-file = hostname: import (./. + "/hosts/${hostname}.nix"); - in { - config.fudo.hosts = genAttrs hosts (hostname: load-host-file hostname); + config.fudo.hosts = syslib.base-host-config ./hosts; } diff --git a/config/hosts/atom.nix b/config/hosts/atom.nix index 1202aa8..3e7b457 100644 --- a/config/hosts/atom.nix +++ b/config/hosts/atom.nix @@ -6,4 +6,5 @@ domain = "sea.fudo.org"; site = "seattle"; profile = "laptop"; + arch = "x86_64-linux"; } diff --git a/config/hosts/clunk.nix b/config/hosts/clunk.nix index f3c931c..b12ea44 100644 --- a/config/hosts/clunk.nix +++ b/config/hosts/clunk.nix @@ -14,4 +14,5 @@ profile = "server"; ssh-pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB07Jf/NB4OlFSEI/eLJlNLA2sM9cHw1hX43r43nQ7a5"; + arch = "x86_64-linux"; } diff --git a/config/hosts/downstairs-desktop.nix b/config/hosts/downstairs-desktop.nix index b6c7184..381c445 100644 --- a/config/hosts/downstairs-desktop.nix +++ b/config/hosts/downstairs-desktop.nix @@ -15,4 +15,6 @@ profile = "desktop"; ssh-pubkey = "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBPqyDT/JqTxWZbpOXzy1Sxba2z2hNzt2BqjLspPvJLVc9zks1GMlnKAY5Nb7y7oi+CzeZMU+KAa069wZ/mYvpas="; + arch = "x86_64-linux"; + nixos-system = false; } diff --git a/config/hosts/france.nix b/config/hosts/france.nix index ca71c85..3375ebf 100644 --- a/config/hosts/france.nix +++ b/config/hosts/france.nix @@ -14,4 +14,5 @@ profile = "server"; ssh-pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIA1COad5NSK3mi66WK5uWf79NLMf5rk350kvJGsEdDmn"; + arch = "x86_64-linux"; } diff --git a/config/hosts/lambda.nix b/config/hosts/lambda.nix index 502594a..0631187 100644 --- a/config/hosts/lambda.nix +++ b/config/hosts/lambda.nix @@ -15,4 +15,5 @@ ssh-pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPB5JY6jnHCRLxjqWKYkK8Xpmfyq2nA+0noPazYGd9a+"; enable-gui = false; + arch = "x86_64-linux"; } diff --git a/config/hosts/limina.nix b/config/hosts/limina.nix index a85eb41..393ee8a 100644 --- a/config/hosts/limina.nix +++ b/config/hosts/limina.nix @@ -14,4 +14,5 @@ ssh-pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMqymGZ5dI6ChI1Qx1QfjBo/h0+xFwpRx/wQSDxWQprI"; tmp-on-tmpfs = false; + arch = "x86_64-linux"; } diff --git a/config/hosts/nostromo.nix b/config/hosts/nostromo.nix index ec31984..086312a 100644 --- a/config/hosts/nostromo.nix +++ b/config/hosts/nostromo.nix @@ -14,4 +14,5 @@ profile = "server"; ssh-pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIHT8Uf6m8ZrSn4nmPyIO+JWLbgXJGX4jJTk0wfqDzzjb"; + arch = "x86_64-linux"; } diff --git a/config/hosts/plato.nix b/config/hosts/plato.nix index 16187c2..103ae06 100644 --- a/config/hosts/plato.nix +++ b/config/hosts/plato.nix @@ -17,4 +17,5 @@ "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDMPjwpcktL0Rhjc/D3ZmzwkSRqSJX5TGjMXVstpg8nNqQQrj9DxPq7gV4a+1LxMtQGPUv4gYx7De1a5LMVk8u6qJJnaLlt3TB1e1SUCBxxeh5sWIY5BMx8Q0/aRTkyTchyczX6FX0LXM7FP6yvxZVZSn2WHRp7REr8G1PUAwuIGy2a4bKOUSh5Uj4riXFXnROW2mp1vUfe5oH4X5HP3ACCXWRVUFdqDt1ldcrqqi+7/8x2G1eOHJcQ7B5FdL3uuq0nBrUzFQTt6KCHy0C2Jc3DFwOS1+ZdGKZpao+/arh/fH+LQfMUePx/AQOkYrJwvuRwbxg8XmlZ89u2gyDuqapzjBmsu+wyd5pF2QglyTRZW9Ijy1NTuzduPm6wgqN0Q09evFJvM9ZjShcIY3xTcCGDxpwTeYgMVXMF79sV9u+JwCSBpaIyteIJ7M/J/NWmaKoUF6Ia9mNts889Ba9TKzQFek19KYetOB2hfXV+7bvXrH+OBppzpdrztJFavBceQTs=" ]; tmp-on-tmpfs = false; + arch = "x86_64-linux"; } diff --git a/config/hosts/procul.nix b/config/hosts/procul.nix index 4fdc024..8ac0a10 100644 --- a/config/hosts/procul.nix +++ b/config/hosts/procul.nix @@ -15,4 +15,6 @@ ssh-pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIKEsvl1mTSWJJrqXbYrc8wYdlOiW5gNg4Nzf2QCxB6XW"; tmp-on-tmpfs = false; + enable-gui = false; + arch = "x86_64-linux"; } diff --git a/config/hosts/pselby-work.nix b/config/hosts/pselby-work.nix index c41cec0..4632b83 100644 --- a/config/hosts/pselby-work.nix +++ b/config/hosts/pselby-work.nix @@ -3,4 +3,6 @@ site = "seattle"; profile = "laptop"; domain = "sea.fudo.org"; + arch = "x86_64-linux"; + nixos-system = false; } diff --git a/config/hosts/socrates.nix b/config/hosts/socrates.nix index 2413030..8de2bb5 100644 --- a/config/hosts/socrates.nix +++ b/config/hosts/socrates.nix @@ -14,4 +14,5 @@ ssh-pubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIP4TqqumZwSDLkg8cTpR734zM+nuqEp1ufaQPoFdqCab"; tmp-on-tmpfs = false; + arch = "x86_64-linux"; } diff --git a/config/hosts/spark.nix b/config/hosts/spark.nix index 47d584a..00e8cca 100644 --- a/config/hosts/spark.nix +++ b/config/hosts/spark.nix @@ -15,4 +15,5 @@ domain = "sea.fudo.org"; site = "seattle"; android-dev = true; + arch = "x86_64-linux"; } diff --git a/config/hosts/system3.nix b/config/hosts/system3.nix index 672671f..d9cc059 100644 --- a/config/hosts/system3.nix +++ b/config/hosts/system3.nix @@ -15,4 +15,5 @@ domain = "sea.fudo.org"; site = "seattle"; android-dev = true; + arch = "x86_64-linux"; } diff --git a/config/hosts/upstairs-desktop.nix b/config/hosts/upstairs-desktop.nix index 313b1ce..71acb9b 100644 --- a/config/hosts/upstairs-desktop.nix +++ b/config/hosts/upstairs-desktop.nix @@ -13,4 +13,6 @@ site = "russell"; domain = "rus.selby.ca"; profile = "desktop"; + arch = "x86_64-linux"; + nixos-system = false; } diff --git a/config/hosts/zbox.nix b/config/hosts/zbox.nix index 94a9404..6ddacd7 100644 --- a/config/hosts/zbox.nix +++ b/config/hosts/zbox.nix @@ -15,4 +15,5 @@ domain = "sea.fudo.org"; site = "seattle"; android-dev = true; + arch = "x86_64-linux"; } diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..45dc8df --- /dev/null +++ b/flake.lock @@ -0,0 +1,48 @@ +{ + "nodes": { + "home-manager": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1631573611, + "narHash": "sha256-u2E/wstadWNcn6vOIoK1xY86QPOzzBZQfT1FbePfdaI=", + "owner": "nix-community", + "repo": "home-manager", + "rev": "7d9ba15214004c979d2c8733f8be12ce6502cf8a", + "type": "github" + }, + "original": { + "owner": "nix-community", + "ref": "release-21.05", + "repo": "home-manager", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1632291606, + "narHash": "sha256-oEN24XJYAFK9tsD13TzLEizpgQigEfgC6i9x1b/1pVU=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "83413f47809790e4ca012e314e7782adeae36cf2", + "type": "github" + }, + "original": { + "id": "nixpkgs", + "ref": "nixos-21.05", + "type": "indirect" + } + }, + "root": { + "inputs": { + "home-manager": "home-manager", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..abb682d --- /dev/null +++ b/flake.nix @@ -0,0 +1,34 @@ +{ + description = "Fudo Host Configuration"; + + inputs = { + nixpkgs.url = "nixpkgs/nixos-21.05"; + home-manager.url = "github:nix-community/home-manager/release-21.05"; + home-manager.inputs.nixpkgs.follows = "nixpkgs"; + }; + + outputs = { self, nixpkgs, home-manager, ... }: { + + nixosConfigurations = let + hostlib = import ./lib/hosts.nix { lib = nixpkgs.lib; }; + hosts = hostlib.base-host-config ./config/hosts; + in nixpkgs.lib.mapAttrs (hostname: hostOpts: let + pkgs = import nixpkgs { + system = hostOpts.arch; + config = { + allowUnfree = true; + permittedInsecurePackages = [ + "openssh-with-gssapi-8.4p1" + ]; + }; + overlays = [ + (import ./fudo-pkgs/overlay.nix) + ]; + }; + in import ./initialize.nix { + inherit hostname pkgs; + home-manager-module = import "${home-manager}/nixos"; + include-secrets = true; + }) hosts; + }; +} diff --git a/lib/fudo/hosts.nix b/lib/fudo/hosts.nix index 97f21a3..b27b6c0 100644 --- a/lib/fudo/hosts.nix +++ b/lib/fudo/hosts.nix @@ -149,7 +149,6 @@ let arch = mkOption { type = str; description = "System architecture of the system."; - default = "x86_64-linux"; }; android-dev = mkEnableOption "Enable ADB on the host."; diff --git a/lib/hosts.nix b/lib/hosts.nix new file mode 100644 index 0000000..88e3389 --- /dev/null +++ b/lib/hosts.nix @@ -0,0 +1,16 @@ +{ lib, ... }: + +with lib; +{ + base-host-config = host-path: let + hostname-from-file = filename: builtins.replaceStrings [".nix"] [""] filename; + + is-nix-file = filename: type: (builtins.match ".+\.nix$" filename) != null; + is-regular-file = filename: type: type == "regular" || type == "link"; + + host-files = attrNames (filterAttrs is-nix-file (filterAttrs is-regular-file (builtins.readDir host-path))); + hosts = map hostname-from-file host-files; + + load-host-file = hostname: import (./. + "/hosts/${hostname}.nix"); + in genAttrs hosts (hostname: load-host-file hostname); +} diff --git a/lib/system.nix b/lib/system.nix index f9703f0..af09310 100644 --- a/lib/system.nix +++ b/lib/system.nix @@ -1,4 +1,4 @@ -{ config, lib, ... }: +{ lib, ... }: with lib; let diff --git a/nix-home b/nix-home index 3f509d0..dcab432 160000 --- a/nix-home +++ b/nix-home @@ -1 +1 @@ -Subproject commit 3f509d08290003c27c51049a8f04e076a79570b7 +Subproject commit dcab43275a732e9a3e3c66c9a92132b4290838d3