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

difftreelog

source

lib/default.nix1.8 KiBsourcehistory
1{flake-utils}: {2  fleetConfiguration = {3    # TODO: Provide by fleet, instead of requesting user to provide it.4    # This is not good that user needs to provide it, as it becomes a flake data, and fleet arbitrarily rewriting it5    # always dirnets the flake. Instead, fleetConfiguration should return function, parameters of which should be filled6    # by fleet itself, which is possible since fleet moving to nix repl execution.7    data,8    nixpkgs,9    overlays ? [],10    hosts,11    modules,12    globalModules ? [],13  }: let14    hostNames = nixpkgs.lib.attrNames hosts;15    fleetLib = import ./fleetLib.nix {16      inherit nixpkgs hostNames;17    };18  in let19    root = nixpkgs.lib.evalModules {20      modules =21        (import ../modules/fleet/_modules.nix)22        ++ [23          data24          ({...}: {25            inherit globalModules hosts;26          })27        ]28        ++ modules;29      specialArgs = {30        inherit nixpkgs fleetLib;31      };32    };33    failedAssertions = map (x: x.message) (nixpkgs.lib.filter (x: !x.assertion) root.config.assertions);34    checkedRoot =35      if failedAssertions != []36      then throw "Fleet failed assertions:\n${nixpkgs.lib.concatStringsSep "\n" (map (x: "- ${x}") failedAssertions)}"37      else nixpkgs.lib.showWarnings root.config.warnings root;38    withData = {39      root,40      data,41    }: {42      configuredHosts = root.config.hosts;43      config = root.config;44    };45    defaultData = withData {46      inherit data;47      root = checkedRoot;48    };49    uncheckedData = withData {inherit data root;};50  in {51    inherit nixpkgs overlays;52    inherit (defaultData) configuredHosts configuredSystems config buildableSystems;53    unchecked = {54      inherit (uncheckedData) configuredHosts configuredSystems config buildableSystems;55    };56  };57}