git.delta.rocks / jrsonnet / refs/commits / 754b45cdacd0

difftreelog

source

lib/default.nix1.6 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 overlays;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      config = root.config;43    };44    defaultData = withData {45      inherit data;46      root = checkedRoot;47    };48    uncheckedData = withData {inherit data root;};49  in {50    inherit nixpkgs overlays;51    inherit (defaultData) config;52    unchecked = {53      inherit (uncheckedData) config;54    };55  };56}