git.delta.rocks / jrsonnet / refs/commits / aeb19ed23fd5

difftreelog

source

lib/default.nix2.3 KiBsourcehistory
1{ flake-utils }: {2  fleetConfiguration = { data, nixpkgs, hosts, ... }@allConfig:3    let4      hostNames = nixpkgs.lib.attrNames hosts;5      config = builtins.removeAttrs allConfig [ "nixpkgs" "data" ];6      fleetLib = import ./fleetLib.nix {7        inherit nixpkgs hostNames;8      };9    in10    nixpkgs.lib.genAttrs flake-utils.lib.defaultSystems (system:11      let12        root = nixpkgs.lib.evalModules {13          modules = (import ../modules/fleet/_modules.nix) ++ [ config data ];14          specialArgs = {15            inherit nixpkgs fleetLib;16          };17        };18        failedAssertions = map (x: x.message) (nixpkgs.lib.filter (x: !x.assertion) root.config.assertions);19        rootAssertWarn =20          if failedAssertions != [ ]21          then throw "Failed assertions:\n${nixpkgs.lib.concatStringsSep "\n" (map (x: "- ${x}") failedAssertions)}"22          else nixpkgs.lib.showWarnings root.config.warnings root;23      in24      rec {25        configuredHosts = rootAssertWarn.config.hosts;26        configuredSecrets = rootAssertWarn.config.secrets;27        configuredSystems = nixpkgs.lib.listToAttrs (28          map29            (30              name: {31                inherit name;32                value = nixpkgs.lib.nixosSystem {33                  system = configuredHosts.${name}.system;34                  modules = configuredHosts.${name}.modules ++ (35                    if configuredHosts.${name}.system == "aarch64-linux" then [ (nixpkgs + "/nixos/modules/installer/sd-card/sd-image-aarch64-installer.nix") ]36                    else [ ]37                  ) ++ [38                    ({ ... }: {39                      nixpkgs.system = system;40                      nixpkgs.localSystem.system = system;41                      nixpkgs.crossSystem = if system == configuredHosts.${name}.system then null else {42                        system = configuredHosts.${name}.system;43                      };44                    })45                  ];46                  specialArgs = {47                    inherit fleetLib;48                    fleet = fleetLib.hostsToAttrs (host: configuredSystems.${host}.config);49                  };50                };51              }52            )53            (builtins.attrNames rootAssertWarn.config.hosts)54        ); #nixpkgs.lib.nixosSystem {}55      });56}