aboutsummaryrefslogtreecommitdiff
path: root/flake
diff options
context:
space:
mode:
authorFranck Cuny <franck@fcuny.net>2025-10-24 09:02:29 -0700
committerFranck Cuny <franck@fcuny.net>2025-10-24 09:02:29 -0700
commite55b8ee0f7073b46fb343a97ee744a95ec40d2ed (patch)
tree329c992647f1c420cbf87cec4cca206474f98b39 /flake
parentmove a few more things back as profiles (diff)
downloadinfra-e55b8ee0f7073b46fb343a97ee744a95ec40d2ed.tar.gz
simplify hosts management
Diffstat (limited to 'flake')
-rw-r--r--flake/hosts.nix41
1 files changed, 27 insertions, 14 deletions
diff --git a/flake/hosts.nix b/flake/hosts.nix
index ef2b28b..b2dac30 100644
--- a/flake/hosts.nix
+++ b/flake/hosts.nix
@@ -15,6 +15,7 @@ let
mkIf
nixosSystem
readDir
+ replaceStrings
substring
;
@@ -32,25 +33,37 @@ let
mapHosts = foldl' (
hosts: system:
hosts
- // (mapAttrs' (name: _: {
- inherit name;
- value = {
- inherit system;
- hostconf = "${self}/machines/nixos/${system}/${name}";
- };
- }) (builtins.readDir "${self}/machines/nixos/${system}"))
+ // (mapAttrs' (
+ filename: _:
+ let
+ name = replaceStrings [ ".nix" ] [ "" ] filename;
+ in
+ {
+ inherit name;
+ value = {
+ inherit system;
+ hostconf = "${self}/machines/nixos/${system}/${filename}";
+ };
+ }
+ ) (builtins.readDir "${self}/machines/nixos/${system}"))
) { };
mapMacs = foldl' (
hosts: system:
hosts
- // (mapAttrs' (name: _: {
- inherit name;
- value = {
- inherit system;
- hostconf = "${self}/machines/darwin/${system}/${name}";
- };
- }) (builtins.readDir "${self}/machines/darwin/${system}"))
+ // (mapAttrs' (
+ filename: _:
+ let
+ name = replaceStrings [ ".nix" ] [ "" ] filename;
+ in
+ {
+ inherit name;
+ value = {
+ inherit system;
+ hostconf = "${self}/machines/darwin/${system}/${filename}";
+ };
+ }
+ ) (builtins.readDir "${self}/machines/darwin/${system}"))
) { };
defaultModules = [