From 9b8f894a1a57eff4bf8ed00debea548370322c83 Mon Sep 17 00:00:00 2001 From: reo101 Date: Tue, 13 Aug 2024 15:53:14 +0300 Subject: [PATCH] feat(configurations)!: flatten down, introduce `meta.nix` Flatten down directory structure: - From: `./hosts/${configuration-type}/${system}/{configuration,deploy}.nix` - To: `./hosts/${configuration-type}/{meta,configuration}.nix` Keep `system` and `deploy-rs` config in `meta.nix` Update `flake.lock` --- flake.lock | 90 ++-- flake.nix | 11 +- .../{x86_64-linux => }/__template__/home.nix | 0 hosts/home-manager/__template__/meta.nix | 3 + .../apavel-a01/configuration.nix | 0 .../apavel-a01/home/apavel.nix | 2 +- hosts/nix-darwin/apavel-a01/meta.nix | 3 + .../limonka/configuration.nix | 0 .../limonka/home/pavelatanasov.nix | 4 +- hosts/nix-darwin/limonka/meta.nix | 15 + .../limontozu/configuration.nix | 0 .../limontozu/home/pavelatanasov.nix | 0 hosts/nix-darwin/limontozu/meta.nix | 3 + .../cheetah/configuration.nix | 0 .../{aarch64-linux => }/cheetah/home.nix | 0 hosts/nix-on-droid/cheetah/meta.nix | 3 + .../__template__/configuration.nix | 0 .../__template__/deploy.nix | 0 .../__template__/hardware-configuration.nix | 0 hosts/nixos/__template__/meta.nix | 3 + .../homix/configuration.nix | 0 .../homix/hardware-configuration.nix | 0 .../{x86_64-linux => }/homix/home/reo101.nix | 0 hosts/nixos/homix/meta.nix | 3 + .../jeeves/configuration.nix | 6 +- .../nixos/{x86_64-linux => }/jeeves/disko.nix | 0 .../jeeves/home-assistant/android.nix | 0 .../jeeves/home-assistant/default.nix | 0 .../jeeves/home-assistant/jokes.nix | 0 .../{x86_64-linux => }/jeeves/home/jeeves.nix | 2 +- .../{x86_64-linux => }/jeeves/jellyfin.nix | 0 hosts/nixos/jeeves/meta.nix | 48 ++ .../{x86_64-linux => }/jeeves/mindustry.nix | 0 .../{x86_64-linux => }/jeeves/network.nix | 0 .../nixos/{x86_64-linux => }/jeeves/nginx.nix | 0 .../{x86_64-linux => }/jeeves/ollama.nix | 0 .../nixos/{x86_64-linux => }/jeeves/samba.nix | 0 .../jeeves/transmission.nix | 0 .../{x86_64-linux => }/jeeves/wireguard.nix | 0 hosts/nixos/x86_64-linux/jeeves/deploy.nix | 42 -- modules/flake/configurations/default.nix | 482 ++++++++++++------ modules/flake/deploy/default.nix | 45 -- modules/flake/lib/default.nix | 38 -- 43 files changed, 459 insertions(+), 344 deletions(-) rename hosts/home-manager/{x86_64-linux => }/__template__/home.nix (100%) create mode 100644 hosts/home-manager/__template__/meta.nix rename hosts/nix-darwin/{x86_64-darwin => }/apavel-a01/configuration.nix (100%) rename hosts/nix-darwin/{x86_64-darwin => }/apavel-a01/home/apavel.nix (94%) create mode 100644 hosts/nix-darwin/apavel-a01/meta.nix rename hosts/nix-darwin/{aarch64-darwin => }/limonka/configuration.nix (100%) rename hosts/nix-darwin/{aarch64-darwin => }/limonka/home/pavelatanasov.nix (97%) create mode 100644 hosts/nix-darwin/limonka/meta.nix rename hosts/nix-darwin/{x86_64-darwin => }/limontozu/configuration.nix (100%) rename hosts/nix-darwin/{x86_64-darwin => }/limontozu/home/pavelatanasov.nix (100%) create mode 100644 hosts/nix-darwin/limontozu/meta.nix rename hosts/nix-on-droid/{aarch64-linux => }/cheetah/configuration.nix (100%) rename hosts/nix-on-droid/{aarch64-linux => }/cheetah/home.nix (100%) create mode 100644 hosts/nix-on-droid/cheetah/meta.nix rename hosts/nixos/{x86_64-linux => }/__template__/configuration.nix (100%) rename hosts/nixos/{x86_64-linux => }/__template__/deploy.nix (100%) rename hosts/nixos/{x86_64-linux => }/__template__/hardware-configuration.nix (100%) create mode 100644 hosts/nixos/__template__/meta.nix rename hosts/nixos/{x86_64-linux => }/homix/configuration.nix (100%) rename hosts/nixos/{x86_64-linux => }/homix/hardware-configuration.nix (100%) rename hosts/nixos/{x86_64-linux => }/homix/home/reo101.nix (100%) create mode 100644 hosts/nixos/homix/meta.nix rename hosts/nixos/{x86_64-linux => }/jeeves/configuration.nix (93%) rename hosts/nixos/{x86_64-linux => }/jeeves/disko.nix (100%) rename hosts/nixos/{x86_64-linux => }/jeeves/home-assistant/android.nix (100%) rename hosts/nixos/{x86_64-linux => }/jeeves/home-assistant/default.nix (100%) rename hosts/nixos/{x86_64-linux => }/jeeves/home-assistant/jokes.nix (100%) rename hosts/nixos/{x86_64-linux => }/jeeves/home/jeeves.nix (98%) rename hosts/nixos/{x86_64-linux => }/jeeves/jellyfin.nix (100%) create mode 100644 hosts/nixos/jeeves/meta.nix rename hosts/nixos/{x86_64-linux => }/jeeves/mindustry.nix (100%) rename hosts/nixos/{x86_64-linux => }/jeeves/network.nix (100%) rename hosts/nixos/{x86_64-linux => }/jeeves/nginx.nix (100%) rename hosts/nixos/{x86_64-linux => }/jeeves/ollama.nix (100%) rename hosts/nixos/{x86_64-linux => }/jeeves/samba.nix (100%) rename hosts/nixos/{x86_64-linux => }/jeeves/transmission.nix (100%) rename hosts/nixos/{x86_64-linux => }/jeeves/wireguard.nix (100%) delete mode 100644 hosts/nixos/x86_64-linux/jeeves/deploy.nix delete mode 100644 modules/flake/deploy/default.nix diff --git a/flake.lock b/flake.lock index 326e705..b47dca3 100644 --- a/flake.lock +++ b/flake.lock @@ -14,11 +14,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1722339003, - "narHash": "sha256-ZeS51uJI30ehNkcZ4uKqT4ZDARPyqrHADSKAwv5vVCU=", + "lastModified": 1723293904, + "narHash": "sha256-b+uqzj+Wa6xgMS9aNbX4I+sXeb5biPDi39VgvSFqFvU=", "owner": "ryantm", "repo": "agenix", - "rev": "3f1dae074a12feb7327b4bf43cbac0d124488bb7", + "rev": "f6291c5935fdc4e0bef208cfc0dcab7e3f7a1c41", "type": "github" }, "original": { @@ -37,11 +37,11 @@ "pre-commit-hooks": "pre-commit-hooks" }, "locked": { - "lastModified": 1722299223, - "narHash": "sha256-+5HNJBXb9YXKSmi2TJsnftrgU/msF/4jBAMH9J1bc5c=", + "lastModified": 1722597419, + "narHash": "sha256-YbMzll0Dh2ln/TryDP+S3IGm8nRHkzcSQIubI4ZEOAw=", "owner": "oddlama", "repo": "agenix-rekey", - "rev": "4107b53b152f4ddc504269ec17c4b7005869d762", + "rev": "126b4a5133eb361cbf5bf90e44c71b6f830845ec", "type": "github" }, "original": { @@ -175,11 +175,11 @@ ] }, "locked": { - "lastModified": 1722476845, - "narHash": "sha256-7gZ8uf3qOox8Vrwd+p9EhUHHLhhK8lis/5KcXGmIaow=", + "lastModified": 1723426710, + "narHash": "sha256-yrS9al6l3fYfFfvovnyBWnyELDQOdfKyai4K/jKgoBw=", "owner": "nix-community", "repo": "disko", - "rev": "7e1b215a0a96efb306ad6440bf706d2b307dc267", + "rev": "0d510fe40b56ed74907a021d7e1ffd0042592914", "type": "github" }, "original": { @@ -367,11 +367,11 @@ ] }, "locked": { - "lastModified": 1719994518, - "narHash": "sha256-pQMhCCHyQGRzdfAkdJ4cIWiw+JNuWsTX7f0ZYSyz0VY=", + "lastModified": 1722555600, + "narHash": "sha256-XOQkdLafnb/p9ij77byFQjDf5m5QYl9b2REiVClC+x4=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "9227223f6d922fee3c7b190b2cc238a99527bbb7", + "rev": "8471fe90ad337a8074e957b69ca4d0089218391d", "type": "github" }, "original": { @@ -576,11 +576,11 @@ ] }, "locked": { - "lastModified": 1721042469, - "narHash": "sha256-6FPUl7HVtvRHCCBQne7Ylp4p+dpP3P/OYuzjztZ4s70=", + "lastModified": 1723202784, + "narHash": "sha256-qbhjc/NEGaDbyy0ucycubq4N3//gDFFH3DOmp1D3u1Q=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "f451c19376071a90d8c58ab1a953c6e9840527fd", + "rev": "c7012d0c18567c889b948781bc74a501e92275d1", "type": "github" }, "original": { @@ -678,11 +678,11 @@ }, "hardware": { "locked": { - "lastModified": 1722332872, - "narHash": "sha256-2xLM4sc5QBfi0U/AANJAW21Bj4ZX479MHPMPkB+eKBU=", + "lastModified": 1723310128, + "narHash": "sha256-IiH8jG6PpR4h9TxSGMYh+2/gQiJW9MwehFvheSb5rPc=", "owner": "nixos", "repo": "nixos-hardware", - "rev": "14c333162ba53c02853add87a0000cbd7aa230c2", + "rev": "c54cf53e022b0b3c1d3b8207aa0f9b194c24f0cf", "type": "github" }, "original": { @@ -720,11 +720,11 @@ ] }, "locked": { - "lastModified": 1722462338, - "narHash": "sha256-ss0G8t8RJVDewA3MyqgAlV951cWRK6EtVhVKEZ7J5LU=", + "lastModified": 1723399884, + "narHash": "sha256-97wn0ihhGqfMb8WcUgzzkM/TuAxce2Gd20A8oiruju4=", "owner": "nix-community", "repo": "home-manager", - "rev": "6e090576c4824b16e8759ebca3958c5b09659ee8", + "rev": "086f619dd991a4d355c07837448244029fc2d9ab", "type": "github" }, "original": { @@ -756,11 +756,11 @@ ] }, "locked": { - "lastModified": 1722491724, - "narHash": "sha256-pvZ0sqDNhcUzYXrCF9UYZBf+qd3ri/0fT0b4mFqVuBs=", + "lastModified": 1723367191, + "narHash": "sha256-noi5tre7BLtxImN38jEHeVOtOG1Xu37sJFwHKSAPHjo=", "owner": "Jovian-Experiments", "repo": "Jovian-NixOS", - "rev": "ff83ee27a56651dcd6d4c9b3e3b7c08267dc52ae", + "rev": "91178062f365b64eece94c5dff93e09b07e87d9d", "type": "github" }, "original": { @@ -827,11 +827,11 @@ ] }, "locked": { - "lastModified": 1722471252, - "narHash": "sha256-rgNPBiWN+y2jBiXIEgV/McBfkPeZax80eol0FBoupCk=", + "lastModified": 1723528508, + "narHash": "sha256-4++qlOlqMoZz3h/g48f+TY3r75h+EBToRNmgcVWKpsE=", "owner": "nix-community", "repo": "neovim-nightly-overlay", - "rev": "fe7178b41d84add25c63a695620629050fb35bbd", + "rev": "f019c7b0e7f478e4aaf2b406785a8d6ec6d1957d", "type": "github" }, "original": { @@ -843,11 +843,11 @@ "neovim-src": { "flake": false, "locked": { - "lastModified": 1722463651, - "narHash": "sha256-3YorBqxT1RpL3Z2rLDCJhG+1HnBsgjrW8AOlTkFWlbA=", + "lastModified": 1723504195, + "narHash": "sha256-Tt+UtP3iSQATu2CUgFgtPkobASE7Rbf2AWZeLH8fthU=", "owner": "neovim", "repo": "neovim", - "rev": "e820474cde09273608be5f57e1032aab21e3c97d", + "rev": "9768e88f3891b5594eb2d556bd3bdf40c61d46e1", "type": "github" }, "original": { @@ -882,11 +882,11 @@ ] }, "locked": { - "lastModified": 1722500642, - "narHash": "sha256-Vls0TQRdplex1JslnBxEk3M26Q1vR+OSg+sk5rBG4DA=", + "lastModified": 1722924007, + "narHash": "sha256-+CQDamNwqO33REJLft8c26NbUi2Td083hq6SvAm2xkU=", "owner": "lnl7", "repo": "nix-darwin", - "rev": "b47af8628624856ad6853168298f1f96364d92d6", + "rev": "91010a5613ffd7ee23ee9263213157a1c422b705", "type": "github" }, "original": { @@ -1123,11 +1123,11 @@ }, "nixpkgs_2": { "locked": { - "lastModified": 1722421184, - "narHash": "sha256-/DJBI6trCeVnasdjUo9pbnodCLZcFqnVZiLUfqLH4jA=", + "lastModified": 1723362943, + "narHash": "sha256-dFZRVSgmJkyM0bkPpaYRtG/kRMRTorUIDj8BxoOt1T4=", "owner": "nixos", "repo": "nixpkgs", - "rev": "9f918d616c5321ad374ae6cb5ea89c9e04bf3e58", + "rev": "a58bc8ad779655e790115244571758e8de055e3d", "type": "github" }, "original": { @@ -1225,11 +1225,11 @@ }, "nur": { "locked": { - "lastModified": 1722577920, - "narHash": "sha256-+Nilyq9pr3f13pNqE3UaJ/zxB69fQ8MmkA5xu6oYtIs=", + "lastModified": 1723549487, + "narHash": "sha256-65NYBcYUx0DjL7TGlesle5PdtJVfOCPnv5zvsgB/dRw=", "owner": "nix-community", "repo": "NUR", - "rev": "a3f8a8853ee2e17c2efd5a33a5c91c1d79bc9c49", + "rev": "20b1fc4032363116a880dc64e3fa96f8a24d4e64", "type": "github" }, "original": { @@ -1701,11 +1701,11 @@ ] }, "locked": { - "lastModified": 1722558337, - "narHash": "sha256-001MFcaVzqfl/d+dhAz4FTWHlHCYU/7nZ9OVWiYLkeI=", + "lastModified": 1723551051, + "narHash": "sha256-+H7sSt93MLs82ZVdhuHlUPfUL+anMvR3+UrVyZTIxjo=", "owner": "mitchellh", "repo": "zig-overlay", - "rev": "93eec9c6ff998133fdeed5eb96c4c59fc2b66b7c", + "rev": "2a8a3228bca531f3c4482268f7262dacf372baf6", "type": "github" }, "original": { @@ -1727,11 +1727,11 @@ ] }, "locked": { - "lastModified": 1722209386, - "narHash": "sha256-GAzXTJUJJIXrAlHkInSDwlnVQPL5BV1Enbj3R4ipGFk=", + "lastModified": 1723396350, + "narHash": "sha256-f5RTadUCYeGPDI6Y7xDYa6sJsdKFCdtD4WipGxuof3A=", "owner": "zigtools", "repo": "zls", - "rev": "eba1489b6ffa6db7f0eaefce6e06d53cd9066f7b", + "rev": "3ec8ad16337e5fc391fbdfb394f68f155b2a7a69", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index fa45c68..29a4b34 100644 --- a/flake.nix +++ b/flake.nix @@ -17,7 +17,6 @@ ./modules/flake/modules ./modules/flake/configurations ./modules/flake/agenix - ./modules/flake/deploy ./modules/flake/topology ./modules/flake/packages ./modules/flake/overlays @@ -35,19 +34,19 @@ flake = { inherit (inputs) self; - # Automatic modules, see `./modules/flake/modules.nix` + # Automatic modules, see `./modules/flake/modules/default.nix` autoModules.enableAll = true; - # Automatic configurations, see `./modules/flake/configurations.nix` + # Automatic configurations, see `./modules/flake/configurations/default.nix` autoConfigurations.enableAll = true; - # Automatic packages, see `./modules/flake/packages/default.nix` + # Automatic packages, see `./modules/flake/packages/default/default.nix` autoPackages.enable = true; - # Automatic overlays, see `./modules/flake/overlays/default.nix` + # Automatic overlays, see `./modules/flake/overlays/default/default.nix` autoOverlays.enable = true; - # Automatic devShells, see `./modules/flake/shells/default.nix` + # Automatic devShells, see `./modules/flake/shells/default/default.nix` autoDevShells.enable = true; # Templates diff --git a/hosts/home-manager/x86_64-linux/__template__/home.nix b/hosts/home-manager/__template__/home.nix similarity index 100% rename from hosts/home-manager/x86_64-linux/__template__/home.nix rename to hosts/home-manager/__template__/home.nix diff --git a/hosts/home-manager/__template__/meta.nix b/hosts/home-manager/__template__/meta.nix new file mode 100644 index 0000000..efab059 --- /dev/null +++ b/hosts/home-manager/__template__/meta.nix @@ -0,0 +1,3 @@ +{ + system = "x86_64-linux"; +} diff --git a/hosts/nix-darwin/x86_64-darwin/apavel-a01/configuration.nix b/hosts/nix-darwin/apavel-a01/configuration.nix similarity index 100% rename from hosts/nix-darwin/x86_64-darwin/apavel-a01/configuration.nix rename to hosts/nix-darwin/apavel-a01/configuration.nix diff --git a/hosts/nix-darwin/x86_64-darwin/apavel-a01/home/apavel.nix b/hosts/nix-darwin/apavel-a01/home/apavel.nix similarity index 94% rename from hosts/nix-darwin/x86_64-darwin/apavel-a01/home/apavel.nix rename to hosts/nix-darwin/apavel-a01/home/apavel.nix index 32d4ef9..57eba3b 100644 --- a/hosts/nix-darwin/x86_64-darwin/apavel-a01/home/apavel.nix +++ b/hosts/nix-darwin/apavel-a01/home/apavel.nix @@ -20,7 +20,7 @@ # Zig zigpkgs.master - inputs.zls-overlay.packages.x86_64-darwin.default + # inputs.zls-overlay.packages.x86_64-darwin.default ]; programs.git = { diff --git a/hosts/nix-darwin/apavel-a01/meta.nix b/hosts/nix-darwin/apavel-a01/meta.nix new file mode 100644 index 0000000..aa5d02c --- /dev/null +++ b/hosts/nix-darwin/apavel-a01/meta.nix @@ -0,0 +1,3 @@ +{ + system = "x86_64-darwin"; +} diff --git a/hosts/nix-darwin/aarch64-darwin/limonka/configuration.nix b/hosts/nix-darwin/limonka/configuration.nix similarity index 100% rename from hosts/nix-darwin/aarch64-darwin/limonka/configuration.nix rename to hosts/nix-darwin/limonka/configuration.nix diff --git a/hosts/nix-darwin/aarch64-darwin/limonka/home/pavelatanasov.nix b/hosts/nix-darwin/limonka/home/pavelatanasov.nix similarity index 97% rename from hosts/nix-darwin/aarch64-darwin/limonka/home/pavelatanasov.nix rename to hosts/nix-darwin/limonka/home/pavelatanasov.nix index d31ea1c..b831435 100644 --- a/hosts/nix-darwin/aarch64-darwin/limonka/home/pavelatanasov.nix +++ b/hosts/nix-darwin/limonka/home/pavelatanasov.nix @@ -66,7 +66,7 @@ nurl # Mail - # himalaya + himalaya # Java graalvm-ce @@ -87,7 +87,7 @@ # Zig zigpkgs.master - inputs.zls-overlay.packages.${pkgs.system}.default + # inputs.zls-overlay.packages.${pkgs.system}.default # Android android-tools diff --git a/hosts/nix-darwin/limonka/meta.nix b/hosts/nix-darwin/limonka/meta.nix new file mode 100644 index 0000000..b6b54e2 --- /dev/null +++ b/hosts/nix-darwin/limonka/meta.nix @@ -0,0 +1,15 @@ +{ + system = "aarch64-darwin"; + deploy = { + hostname = "localhost"; + sshUser = "pavelatanasov"; + user = "pavelatanasov"; + sudo = "sudo -u"; + sshOpts = [ ]; + fastConnection = false; + autoRollback = true; + magicRollback = true; + tempPath = "/Users/pavelatanasov/.deploy-rs"; + remoteBuild = true; + }; +} diff --git a/hosts/nix-darwin/x86_64-darwin/limontozu/configuration.nix b/hosts/nix-darwin/limontozu/configuration.nix similarity index 100% rename from hosts/nix-darwin/x86_64-darwin/limontozu/configuration.nix rename to hosts/nix-darwin/limontozu/configuration.nix diff --git a/hosts/nix-darwin/x86_64-darwin/limontozu/home/pavelatanasov.nix b/hosts/nix-darwin/limontozu/home/pavelatanasov.nix similarity index 100% rename from hosts/nix-darwin/x86_64-darwin/limontozu/home/pavelatanasov.nix rename to hosts/nix-darwin/limontozu/home/pavelatanasov.nix diff --git a/hosts/nix-darwin/limontozu/meta.nix b/hosts/nix-darwin/limontozu/meta.nix new file mode 100644 index 0000000..aa5d02c --- /dev/null +++ b/hosts/nix-darwin/limontozu/meta.nix @@ -0,0 +1,3 @@ +{ + system = "x86_64-darwin"; +} diff --git a/hosts/nix-on-droid/aarch64-linux/cheetah/configuration.nix b/hosts/nix-on-droid/cheetah/configuration.nix similarity index 100% rename from hosts/nix-on-droid/aarch64-linux/cheetah/configuration.nix rename to hosts/nix-on-droid/cheetah/configuration.nix diff --git a/hosts/nix-on-droid/aarch64-linux/cheetah/home.nix b/hosts/nix-on-droid/cheetah/home.nix similarity index 100% rename from hosts/nix-on-droid/aarch64-linux/cheetah/home.nix rename to hosts/nix-on-droid/cheetah/home.nix diff --git a/hosts/nix-on-droid/cheetah/meta.nix b/hosts/nix-on-droid/cheetah/meta.nix new file mode 100644 index 0000000..38187ab --- /dev/null +++ b/hosts/nix-on-droid/cheetah/meta.nix @@ -0,0 +1,3 @@ +{ + system = "aarch64-linux"; +} diff --git a/hosts/nixos/x86_64-linux/__template__/configuration.nix b/hosts/nixos/__template__/configuration.nix similarity index 100% rename from hosts/nixos/x86_64-linux/__template__/configuration.nix rename to hosts/nixos/__template__/configuration.nix diff --git a/hosts/nixos/x86_64-linux/__template__/deploy.nix b/hosts/nixos/__template__/deploy.nix similarity index 100% rename from hosts/nixos/x86_64-linux/__template__/deploy.nix rename to hosts/nixos/__template__/deploy.nix diff --git a/hosts/nixos/x86_64-linux/__template__/hardware-configuration.nix b/hosts/nixos/__template__/hardware-configuration.nix similarity index 100% rename from hosts/nixos/x86_64-linux/__template__/hardware-configuration.nix rename to hosts/nixos/__template__/hardware-configuration.nix diff --git a/hosts/nixos/__template__/meta.nix b/hosts/nixos/__template__/meta.nix new file mode 100644 index 0000000..efab059 --- /dev/null +++ b/hosts/nixos/__template__/meta.nix @@ -0,0 +1,3 @@ +{ + system = "x86_64-linux"; +} diff --git a/hosts/nixos/x86_64-linux/homix/configuration.nix b/hosts/nixos/homix/configuration.nix similarity index 100% rename from hosts/nixos/x86_64-linux/homix/configuration.nix rename to hosts/nixos/homix/configuration.nix diff --git a/hosts/nixos/x86_64-linux/homix/hardware-configuration.nix b/hosts/nixos/homix/hardware-configuration.nix similarity index 100% rename from hosts/nixos/x86_64-linux/homix/hardware-configuration.nix rename to hosts/nixos/homix/hardware-configuration.nix diff --git a/hosts/nixos/x86_64-linux/homix/home/reo101.nix b/hosts/nixos/homix/home/reo101.nix similarity index 100% rename from hosts/nixos/x86_64-linux/homix/home/reo101.nix rename to hosts/nixos/homix/home/reo101.nix diff --git a/hosts/nixos/homix/meta.nix b/hosts/nixos/homix/meta.nix new file mode 100644 index 0000000..efab059 --- /dev/null +++ b/hosts/nixos/homix/meta.nix @@ -0,0 +1,3 @@ +{ + system = "x86_64-linux"; +} diff --git a/hosts/nixos/x86_64-linux/jeeves/configuration.nix b/hosts/nixos/jeeves/configuration.nix similarity index 93% rename from hosts/nixos/x86_64-linux/jeeves/configuration.nix rename to hosts/nixos/jeeves/configuration.nix index d0fddff..90350d4 100644 --- a/hosts/nixos/x86_64-linux/jeeves/configuration.nix +++ b/hosts/nixos/jeeves/configuration.nix @@ -23,6 +23,7 @@ # services.kanidm = { }; age.rekey = { + # TODO: store in `meta` hostPubkey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIPopSTZ81UyKp9JSljCLp+Syk51zacjh9fLteqxQ6/aB"; # masterIdentities = [ "${inputs.self}/secrets/privkey.age" ]; # storageMode = "local"; @@ -74,7 +75,10 @@ environment.systemPackages = with pkgs; [ git - neovim + # FIXME: cannot deploy neovim-nightly + # V neovim source + # > error: cannot add path '/nix/store/rhjznh5jdzdkzbnn0fhhvcf9rys0s59d-source' because it lacks a signature by a trusted key + # neovim ]; # NOTE: made with `mkpasswd -m sha-512` diff --git a/hosts/nixos/x86_64-linux/jeeves/disko.nix b/hosts/nixos/jeeves/disko.nix similarity index 100% rename from hosts/nixos/x86_64-linux/jeeves/disko.nix rename to hosts/nixos/jeeves/disko.nix diff --git a/hosts/nixos/x86_64-linux/jeeves/home-assistant/android.nix b/hosts/nixos/jeeves/home-assistant/android.nix similarity index 100% rename from hosts/nixos/x86_64-linux/jeeves/home-assistant/android.nix rename to hosts/nixos/jeeves/home-assistant/android.nix diff --git a/hosts/nixos/x86_64-linux/jeeves/home-assistant/default.nix b/hosts/nixos/jeeves/home-assistant/default.nix similarity index 100% rename from hosts/nixos/x86_64-linux/jeeves/home-assistant/default.nix rename to hosts/nixos/jeeves/home-assistant/default.nix diff --git a/hosts/nixos/x86_64-linux/jeeves/home-assistant/jokes.nix b/hosts/nixos/jeeves/home-assistant/jokes.nix similarity index 100% rename from hosts/nixos/x86_64-linux/jeeves/home-assistant/jokes.nix rename to hosts/nixos/jeeves/home-assistant/jokes.nix diff --git a/hosts/nixos/x86_64-linux/jeeves/home/jeeves.nix b/hosts/nixos/jeeves/home/jeeves.nix similarity index 98% rename from hosts/nixos/x86_64-linux/jeeves/home/jeeves.nix rename to hosts/nixos/jeeves/home/jeeves.nix index 5c852e9..d1d1884 100644 --- a/hosts/nixos/x86_64-linux/jeeves/home/jeeves.nix +++ b/hosts/nixos/jeeves/home/jeeves.nix @@ -16,7 +16,7 @@ home.packages = with pkgs; [ ## Core - neovim + # neovim git gnupg pciutils # lspci diff --git a/hosts/nixos/x86_64-linux/jeeves/jellyfin.nix b/hosts/nixos/jeeves/jellyfin.nix similarity index 100% rename from hosts/nixos/x86_64-linux/jeeves/jellyfin.nix rename to hosts/nixos/jeeves/jellyfin.nix diff --git a/hosts/nixos/jeeves/meta.nix b/hosts/nixos/jeeves/meta.nix new file mode 100644 index 0000000..1b501ce --- /dev/null +++ b/hosts/nixos/jeeves/meta.nix @@ -0,0 +1,48 @@ +{ + # The `system` of the host + system = "x86_64-linux"; + + # `deploy-rs` configuration + deploy = { + # This is the hostname by which you'll refer to this machine using reploy-rs + hostname = "jeeves.reo101.xyz"; + + # This is the user that deploy-rs will use when connecting. + # This will default to your own username if not specified anywhere + sshUser = "jeeves"; + + # This is the user that the profile will be deployed to (will use sudo if not the same as above). + # If `sshUser` is specified, this will be the default (though it will _not_ default to your own username) + user = "root"; + + # Which sudo command to use. Must accept at least two arguments: + # the user name to execute commands as and the rest is the command to execute + # This will default to "sudo -u" if not specified anywhere. + sudo = "sudo -u"; + + # This is an optional list of arguments that will be passed to SSH. + sshOpts = [ "-p" "727" ]; + + # Fast connection to the node. If this is true, copy the whole closure instead of letting the node substitute. + # This defaults to `false` + fastConnection = false; + + # If the previous profile should be re-activated if activation fails. + # This defaults to `true` + autoRollback = true; + + # See the earlier section about Magic Rollback for more information. + # This defaults to `true` + magicRollback = true; + + # The path which deploy-rs will use for temporary files, this is currently only used by `magicRollback` to create an inotify watcher in for confirmations + # If not specified, this will default to `/tmp` + # (if `magicRollback` is in use, this _must_ be writable by `user`) + tempPath = "/tmp"; + + # Build the derivation on the target system + # Will also fetch all external dependencies from the target system's substituters. + # This default to `false` + remoteBuild = true; + }; +} diff --git a/hosts/nixos/x86_64-linux/jeeves/mindustry.nix b/hosts/nixos/jeeves/mindustry.nix similarity index 100% rename from hosts/nixos/x86_64-linux/jeeves/mindustry.nix rename to hosts/nixos/jeeves/mindustry.nix diff --git a/hosts/nixos/x86_64-linux/jeeves/network.nix b/hosts/nixos/jeeves/network.nix similarity index 100% rename from hosts/nixos/x86_64-linux/jeeves/network.nix rename to hosts/nixos/jeeves/network.nix diff --git a/hosts/nixos/x86_64-linux/jeeves/nginx.nix b/hosts/nixos/jeeves/nginx.nix similarity index 100% rename from hosts/nixos/x86_64-linux/jeeves/nginx.nix rename to hosts/nixos/jeeves/nginx.nix diff --git a/hosts/nixos/x86_64-linux/jeeves/ollama.nix b/hosts/nixos/jeeves/ollama.nix similarity index 100% rename from hosts/nixos/x86_64-linux/jeeves/ollama.nix rename to hosts/nixos/jeeves/ollama.nix diff --git a/hosts/nixos/x86_64-linux/jeeves/samba.nix b/hosts/nixos/jeeves/samba.nix similarity index 100% rename from hosts/nixos/x86_64-linux/jeeves/samba.nix rename to hosts/nixos/jeeves/samba.nix diff --git a/hosts/nixos/x86_64-linux/jeeves/transmission.nix b/hosts/nixos/jeeves/transmission.nix similarity index 100% rename from hosts/nixos/x86_64-linux/jeeves/transmission.nix rename to hosts/nixos/jeeves/transmission.nix diff --git a/hosts/nixos/x86_64-linux/jeeves/wireguard.nix b/hosts/nixos/jeeves/wireguard.nix similarity index 100% rename from hosts/nixos/x86_64-linux/jeeves/wireguard.nix rename to hosts/nixos/jeeves/wireguard.nix diff --git a/hosts/nixos/x86_64-linux/jeeves/deploy.nix b/hosts/nixos/x86_64-linux/jeeves/deploy.nix deleted file mode 100644 index b8bfce5..0000000 --- a/hosts/nixos/x86_64-linux/jeeves/deploy.nix +++ /dev/null @@ -1,42 +0,0 @@ -{ - # This is the hostname by which you'll refer to this machine using reploy-rs - hostname = "jeeves.reo101.xyz"; - - # This is the user that deploy-rs will use when connecting. - # This will default to your own username if not specified anywhere - sshUser = "jeeves"; - - # This is the user that the profile will be deployed to (will use sudo if not the same as above). - # If `sshUser` is specified, this will be the default (though it will _not_ default to your own username) - user = "root"; - - # Which sudo command to use. Must accept at least two arguments: - # the user name to execute commands as and the rest is the command to execute - # This will default to "sudo -u" if not specified anywhere. - sudo = "sudo -u"; - - # This is an optional list of arguments that will be passed to SSH. - sshOpts = [ "-p" "727" ]; - - # Fast connection to the node. If this is true, copy the whole closure instead of letting the node substitute. - # This defaults to `false` - fastConnection = false; - - # If the previous profile should be re-activated if activation fails. - # This defaults to `true` - autoRollback = true; - - # See the earlier section about Magic Rollback for more information. - # This defaults to `true` - magicRollback = true; - - # The path which deploy-rs will use for temporary files, this is currently only used by `magicRollback` to create an inotify watcher in for confirmations - # If not specified, this will default to `/tmp` - # (if `magicRollback` is in use, this _must_ be writable by `user`) - tempPath = "/tmp"; - - # Build the derivation on the target system - # Will also fetch all external dependencies from the target system's substituters. - # This default to `false` - remoteBuild = true; -} diff --git a/modules/flake/configurations/default.nix b/modules/flake/configurations/default.nix index 12d0d41..1a1b070 100644 --- a/modules/flake/configurations/default.nix +++ b/modules/flake/configurations/default.nix @@ -6,11 +6,12 @@ let hasFiles hasDirectories recurseDir - configuration-type-to-outputs-modules; + kebabToCamel + configuration-type-to-outputs-modules + configuration-type-to-outputs-configurations; in let # Configuration helpers - configurationTypes = ["nixos" "nix-on-droid" "nix-darwin" "home-manager"]; # `pkgs` with flake's overlays # NOTE: done here to avoid infinite recursion @@ -18,7 +19,15 @@ let (withSystem system ({ pkgs, ... }: pkgs)).extend (final: prev: inputs.self.packages.${system}); - homeManagerModule = { root, system, hostname, users ? null }: { + genUsers = configurationFiles: + lib.pipe configurationFiles [ + (cf: cf."home" or { }) + builtins.attrNames + (builtins.map + (lib.strings.removeSuffix ".nix")) + ]; + + homeManagerModule = { root, meta, users ? null }: { home-manager = { # Use same `pkgs` instance as system (i.e. carry over overlays) useGlobalPkgs = true; @@ -26,11 +35,10 @@ let useUserPackages = true; # Default import all of our exported `home-manager` modules sharedModules = builtins.attrValues config.flake.${configuration-type-to-outputs-modules "home-manager"}; - # Pass in `inputs`, `outputs` and maybe `meta` + # Pass in `inputs`, `hostname` and `meta` extraSpecialArgs = { inherit inputs; - # TODO: meta? - inherit hostname; + inherit meta; }; } // (if users == null then { # nixOnDroid @@ -44,9 +52,9 @@ let }); }; - mkNixosHost = args @ { root, system, hostname, users }: inputs.nixpkgs.lib.nixosSystem { - inherit system; - pkgs = pkgs' system; + mkNixosHost = args @ { root, meta, users }: inputs.nixpkgs.lib.nixosSystem { + inherit (meta) system; + pkgs = pkgs' meta.system; modules = [ # Main configuration @@ -61,19 +69,21 @@ let inputs.nix-topology.nixosModules.default # Sane default `networking.hostName` { - networking.hostName = lib.mkDefault hostname; + networking.hostName = lib.mkDefault meta.hostname; } + # TODO: lib.optionals ] ++ (builtins.attrValues config.flake.${configuration-type-to-outputs-modules "nixos"}); specialArgs = { inherit inputs; + inherit meta; }; }; - mkNixOnDroidHost = args @ { root, system, hostname }: inputs.nix-on-droid.lib.nixOnDroidConfiguration { + mkNixOnDroidHost = args @ { root, meta }: inputs.nix-on-droid.lib.nixOnDroidConfiguration { # NOTE: inferred by `pkgs.system` # inherit system; - pkgs = pkgs' system; + pkgs = pkgs' meta.system; modules = [ # Main configuration @@ -84,14 +94,15 @@ let extraSpecialArgs = { inherit inputs; + inherit meta; }; home-manager-path = inputs.home-manager.outPath; }; - mkNixDarwinHost = args @ { root, system, hostname, users }: inputs.nix-darwin.lib.darwinSystem { - inherit system; - pkgs = pkgs' system; + mkNixDarwinHost = args @ { root, meta, users }: inputs.nix-darwin.lib.darwinSystem { + inherit (meta) system; + pkgs = pkgs' meta.system; modules = [ # Main configuration @@ -107,12 +118,13 @@ let specialArgs = { inherit inputs; + inherit meta; }; }; - mkHomeManagerHost = args @ { root, system, hostname }: inputs.home-manager.lib.homeManagerConfiguration { - inherit system; - pkgs = pkgs' system; + mkHomeManagerHost = args @ { root, meta }: inputs.home-manager.lib.homeManagerConfiguration { + inherit (meta) system; + pkgs = pkgs' meta.system; modules = [ "${root}/home.nix" @@ -120,30 +132,9 @@ let extraSpecialArgs = { inherit inputs; - inherit hostname; + inherit meta; }; }; - - createConfigurations = - pred: mkHost: hosts: - lib.foldAttrs - lib.const - [ ] - (builtins.attrValues - (builtins.mapAttrs - (system: hosts: - lib.concatMapAttrs - (host: configurationFiles: - lib.optionalAttrs - (and [ - (host != "__template__") - (pred { inherit system host configurationFiles; }) - ]) - { - ${host} = mkHost { inherit system host configurationFiles; }; - }) - hosts) - hosts)); in { options = let @@ -153,9 +144,18 @@ in description = '' Automagically generate configurations from walking directories with Nix files ''; - type = types.submodule (submodule: { + internal = true; + type = types.submodule (autoConfigurationsSubmodule: let + inherit (autoConfigurationsSubmodule.config) + configurationTypes + enableAll + baseDir + ; + in { options = { - enableAll = lib.mkEnableOption "Automatic ${builtins.toString configurationTypes} configurations extraction"; + enableAll = lib.mkEnableOption '' + Automatic ${builtins.toString (lib.attrValues configurationTypes)} configurations extraction + ''; baseDir = lib.mkOption { description = '' Base directory of the contained configurations, used as a base for the rest of the options @@ -164,135 +164,291 @@ in default = "${self}/hosts"; defaultText = ''''${self}/hosts''; }; - } // ( - lib.pipe - configurationTypes - [ - (builtins.map - # NOTE: create small submodule for every `configurationType` - (configurationType: - lib.nameValuePair - "${configurationType}" - (lib.mkOption { - type = types.submodule { - options = { - # NOTE: each can be enabled (default global `enableAll`) - enable = lib.mkEnableOption "Automatic ${configurationType} configurations extraction" // { - default = submodule.config.enableAll; - }; - # NOTE: each can be read from a different directory - # (default global `baseDir` + `camelToKebab`-ed `configurationType`) - dir = lib.mkOption { - type = types.path; - default = "${submodule.config.baseDir}/${configurationType}"; - }; - # TODO: split hosts and configurations? - resultHosts = lib.mkOption { - description = '' - The resulting automatic packages - ''; - # TODO: specify - type = types.unspecified; - readOnly = true; - internal = true; - default = - lib.optionalAttrs - config.flake.autoConfigurations.${configurationType}.enable - (recurseDir config.flake.autoConfigurations.${configurationType}.dir); + configurationTypes = lib.mkOption { + type = types.attrsOf (types.submodule (configurationTypeSubmodule@{ name, ... }: let + inherit (configurationTypeSubmodule.config) + # enable + dir + predicate + mkHost + mkDeployNode + ; + in { + options = { + enable = lib.mkEnableOption "Automatic ${name} configurations extraction" // { + default = enableAll; + }; + # NOTE: each can be read from a different directory + dir = lib.mkOption { + type = types.path; + default = "${baseDir}/${name}"; + }; + hostsName = lib.mkOption { + description = '' + Name of the `hosts` output + ''; + type = types.str; + default = "${kebabToCamel name}Hosts"; + }; + configurationsName = lib.mkOption { + description = '' + Name of the `configurations` output + ''; + type = types.str; + default = "${kebabToCamel name}Configurations"; + }; + predicate = lib.mkOption { + description = '' + Function for filtering configurations + ''; + # FIXME: `merge` of `functionTo` type causes a stray `passthru` to attempt getting evaluated + # type = types.functionTo types.anything; + type = types.unspecified; + example = /* nix */ '' + { root, host, configurationFiles, ... }: + # Utils from `./modules/flake/lib/default.nix` + and [ + (! (host == "__template__")) + (hasFiles + [ "configuration.nix" ] + configurationFiles) + (hasDirectories + [ "home" ] + configurationFiles) + ] + ''; + }; + mkHost = lib.mkOption { + description = '' + Function for generating a configuration + ''; + # type = types.functionTo types.anything; + type = types.unspecified; + example = /* nix */ '' + args @ { root, meta, users }: inputs.nixpkgs.lib.nixosSystem { + inherit (meta) system; + + modules = [ + # Main configuration + "''${root}/configuration.nix" + # Home Manager + inputs.home-manager.nixosModules.home-manager + (homeManagerModule args) + ] ++ (builtins.attrValues config.flake.''${configuration-type-to-outputs-modules "nixos"}); + + specialArgs = { + inherit inputs; + inherit meta; }; }; + ''; + }; + mkDeployNode = lib.mkOption { + description = '' + Function for generating a `deploy-rs` node (null to skip) + ''; + type = types.nullOr (types.functionTo types.anything); + default = null; + # TODO: update + example = /* nix */ '' + args @ { root, host, meta, configuration }: + inputs.deploy-rs.''${meta.system}.activate.nixos configuration; + ''; + }; + resultConfigurations = lib.mkOption { + description = '' + The resulting automatic configurations + ''; + # TODO: specify + type = types.unspecified; + readOnly = true; + default = + lib.pipe dir [ + recurseDir + (lib.concatMapAttrs + (host: configurationFiles: + let + root = "${dir}/${host}"; + meta-path = "${root}/meta.nix"; + meta = import meta-path; + deploy-config = meta.deploy or null; + has-mkDeployNode = mkDeployNode != null; + has-deploy-config = builtins.pathExists meta-path && deploy-config != null; + configuration-args = { inherit root host configurationFiles; }; + valid = predicate configuration-args; + configuration = mkHost configuration-args; + deploy-args = { inherit root host meta configuration; }; + deploy = mkDeployNode deploy-args; + in + lib.optionalAttrs valid { + ${host} = { + inherit configuration; + } // lib.optionalAttrs (has-mkDeployNode && has-deploy-config) { + inherit deploy; + }; + })) + ]; + }; + }; + config = {}; + })); + # TODO: put in a more visible place + default = { + nixos = { + predicate = ({ root, host, configurationFiles, ... }: + and [ + (! (host == "__template__")) + (hasFiles + [ "configuration.nix" "meta.nix" ] + configurationFiles) + ]); + mkHost = ({ root, host, configurationFiles, ... }: let + meta = import "${root}/meta.nix" // { + hostname = host; + }; + in + mkNixosHost { + inherit root; + inherit meta; + users = genUsers configurationFiles; + }); + mkDeployNode = ({ root, host, meta, configuration }: + { + inherit (meta.deploy) hostname; + profiles.system = meta.deploy // { + path = inputs.deploy-rs.lib.${meta.system}.activate."nixos" configuration; + }; + }); + }; + nix-on-droid = { + predicate = ({ root, host, configurationFiles, ... }: + and [ + (! (host == "__template__")) + (hasFiles + [ "configuration.nix" "home.nix" "meta.nix" ] + configurationFiles) + ]); + mkHost = ({ root, host, configurationFiles, ... }: let + meta = import "${root}/meta.nix" // { + hostname = host; + }; + in + mkNixOnDroidHost { + inherit root; + inherit meta; + }); + }; + nix-darwin = { + hostsName = "darwinHosts"; + configurationsName = "darwinConfigurations"; + predicate = ({ root, host, configurationFiles, ... }: + and [ + (! (host == "__template__")) + (hasFiles + [ "configuration.nix" "meta.nix" ] + configurationFiles) + (hasDirectories + [ "home" ] + configurationFiles) + ]); + mkHost = ({ root, host, configurationFiles, ... }: let + meta = import "${root}/meta.nix" // { + hostname = host; }; - default = {}; - }))) - builtins.listToAttrs - ]); + in + mkNixDarwinHost { + inherit root; + inherit meta; + users = genUsers configurationFiles; + }); + mkDeployNode = ({ root, host, meta, configuration }: + { + inherit (meta.deploy) hostname; + profiles.system = meta.deploy // { + path = inputs.deploy-rs.lib.${meta.system}.activate."darwin" configuration; + }; + }); + }; + home-manager = { + hostsName = "homeHosts"; + configurationsName = "homeConfigurations"; + predicate = ({ root, host, configurationFiles, ... }: + and [ + (! (host == "__template__")) + (hasFiles + [ "home.nix" "meta.nix" ] + configurationFiles) + ]); + mkHost = ({ root, host, configurationFiles, ... }: let + meta = import "${root}/meta.nix" // { + hostname = host; + }; + in + mkHomeManagerHost { + inherit root; + inherit meta; + }); + }; + }; + }; + resultConfigurations = lib.mkOption { + readOnly = true; + default = lib.pipe configurationTypes [ + (lib.mapAttrs' + (configurationType: configurationTypeConfig: + lib.nameValuePair + configurationTypeConfig.configurationsName + (lib.mapAttrs + (host: { configuration, ... }: + configuration) + configurationTypeConfig.resultConfigurations))) + ]; + }; + resultDeployNodes = lib.mkOption { + readOnly = true; + default = lib.pipe configurationTypes [ + (lib.concatMapAttrs + (configurationType: configurationTypeConfig: + (lib.concatMapAttrs + (host: { deploy ? null, ... }: + lib.optionalAttrs + (deploy != null) + { + ${host} = deploy; + }) + configurationTypeConfig.resultConfigurations))) + ]; + }; + }; }); default = {}; }; }; config = { - flake = { - # Configurations - nixosConfigurations = - createConfigurations - ({ system, host, configurationFiles, ... }: - and - [ - (hasFiles - [ "configuration.nix" ] - configurationFiles) - # (hasDirectories - # [ "home" ] - # config) - ]) - ({ system, host, configurationFiles, ... }: - mkNixosHost { - root = "${config.flake.autoConfigurations.nixos.dir}/${system}/${host}"; - inherit system; - hostname = host; - users = (builtins.map - (lib.strings.removeSuffix ".nix") - (builtins.attrNames (configurationFiles."home" or { }))); - }) - config.flake.autoConfigurations.nixos.resultHosts; - - nixOnDroidConfigurations = - createConfigurations - ({ system, host, configurationFiles, ... }: - and - [ - (hasFiles - [ "configuration.nix" "home.nix" ] - configurationFiles) - ]) - ({ system, host, configurationFiles, ... }: - mkNixOnDroidHost { - root = "${config.flake.autoConfigurations.nix-on-droid.dir}/${system}/${host}"; - inherit system; - hostname = host; - }) - config.flake.autoConfigurations.nix-on-droid.resultHosts; - - darwinConfigurations = - createConfigurations - ({ system, host, configurationFiles, ... }: - and - [ - (hasFiles - [ "configuration.nix" ] - configurationFiles) - (hasDirectories - [ "home" ] - configurationFiles) - ]) - ({ system, host, configurationFiles, ... }: - mkNixDarwinHost { - root = "${config.flake.autoConfigurations.nix-darwin.dir}/${system}/${host}"; - inherit system; - hostname = host; - users = (builtins.map - (lib.strings.removeSuffix ".nix") - (builtins.attrNames (configurationFiles."home" or { }))); - }) - config.flake.autoConfigurations.nix-darwin.resultHosts; - - homeConfigurations = - createConfigurations - ({ system, host, configurationFiles, ... }: - and - [ - (hasFiles - [ "home.nix" ] - configurationFiles) - ]) - ({ system, host, configurationFiles, ... }: - mkHomeManagerHost { - root = "${config.flake.autoConfigurations.home-manager.dir}/${system}/${host}"; - inherit system; - hostname = host; - }) - config.flake.autoConfigurations.home-manager.resultHosts; - }; + # BUG: cannot iterate on `config.flake.autoConfigurations.resultConfigurations` + # because of infinite recursion + flake = let + ogConfigurationTypes = ["nixos" "nix-on-droid" "nix-darwin" "home-manager"]; + configurations = lib.pipe ogConfigurationTypes [ + (lib.map + configuration-type-to-outputs-configurations) + (lib.flip lib.genAttrs + (configurationType: + config.flake.autoConfigurations.resultConfigurations.${configurationType})) + ]; + deployNodes = { + deploy.nodes = config.flake.autoConfigurations.resultDeployNodes; + }; + deployChecks = { + checks = + lib.mapAttrs + (system: deployLib: + deployLib.deployChecks + self.deploy) + inputs.deploy-rs.lib; + }; + # TODO: lib.something for merging (asserting for no overwrites) + in configurations // deployNodes // deployChecks; }; } diff --git a/modules/flake/deploy/default.nix b/modules/flake/deploy/default.nix deleted file mode 100644 index 859a0e6..0000000 --- a/modules/flake/deploy/default.nix +++ /dev/null @@ -1,45 +0,0 @@ -{ lib, config, self, inputs, ... }: - -let - inherit (config.lib) - accumulateHosts - configuration-type-to-deploy-type; -in -{ - flake = { - deploy.nodes = - accumulateHosts - # TODO: nix-on-droid - ["nixos" "nix-darwin"] - ({ host, system, configuration-type, configuration }: - let - deploy-config-path = - "${config.flake.autoConfigurations.${configuration-type}.dir}/${system}/${host}/deploy.nix"; - deploy-config = - import deploy-config-path; - in - lib.optionalAttrs - (builtins.pathExists deploy-config-path) - { - ${host} = { - inherit (deploy-config) - hostname; - profiles.system = deploy-config // { - path = - let - deploy-type = configuration-type-to-deploy-type configuration-type; - in - inputs.deploy-rs.lib.${system}.activate.${deploy-type} configuration; - }; - }; - } - ); - - checks = - lib.mapAttrs - (system: deployLib: - deployLib.deployChecks - self.deploy) - inputs.deploy-rs.lib; - }; -} diff --git a/modules/flake/lib/default.nix b/modules/flake/lib/default.nix index 34d3084..2debd5c 100644 --- a/modules/flake/lib/default.nix +++ b/modules/flake/lib/default.nix @@ -121,43 +121,5 @@ (configuration-type: builtins.throw "Invaild configuration-type \"${configuration-type}\" for deploy-rs deployment"); - - accumulateHosts = configuration-types: host-system-configuration-type-configuration-fn: - lib.flip lib.concatMapAttrs - (lib.genAttrs - configuration-types - (configuration-type: - config.flake.autoConfigurations.${configuration-type}.resultHosts)) - (configuration-type: hosts: - lib.pipe - hosts - [ - # Filter out nondirectories - (lib.filterAttrs - (system: configurations: - builtins.isAttrs configurations)) - # Convert non-template configs into `system-and-config` pairs - (lib.concatMapAttrs - (system: configurations: - (lib.concatMapAttrs - (host: configuration: - lib.optionalAttrs - (host != "__template__") - { - ${host} = { - inherit system; - configuration = - let - configurations = configuration-type-to-outputs-configurations configuration-type; - in - self.${configurations}.${host}; - }; - }) - configurations))) - # Convert each `system-and-config` pair into a *whatever* - (lib.concatMapAttrs - (host: { system, configuration }: - host-system-configuration-type-configuration-fn { inherit host system configuration-type configuration; })) - ]); }; }