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

difftreelog

source

lib/default.nix1.8 KiBsourcehistory
1{fleetPkgsForPkgs}: {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    fleetModules,12    nixosModules ? [],13    extraFleetLib ? {},14  }: let15    hostNames = nixpkgs.lib.attrNames hosts;16    fleetLib =17      (import ./fleetLib.nix {18        inherit nixpkgs hostNames;19      })20      // extraFleetLib;21  in let22    root = nixpkgs.lib.evalModules {23      modules =24        (import ../modules/fleet/_modules.nix)25        ++ [26          data27          ({...}: {28            inherit nixosModules hosts;29            overlays = [(final: prev: (fleetPkgsForPkgs final))] ++ overlays;30          })31        ]32        ++ fleetModules;33      specialArgs = {34        inherit nixpkgs fleetLib;35      };36    };37    failedAssertions = map (x: x.message) (nixpkgs.lib.filter (x: !x.assertion) root.config.assertions);38    checkedRoot =39      if failedAssertions != []40      then throw "Fleet failed assertions:\n${nixpkgs.lib.concatStringsSep "\n" (map (x: "- ${x}") failedAssertions)}"41      else nixpkgs.lib.showWarnings root.config.warnings root;42    withData = {43      root,44      data,45    }: {46      config = root.config;47    };48    defaultData = withData {49      inherit data;50      root = checkedRoot;51    };52    uncheckedData = withData {inherit data root;};53  in {54    inherit nixpkgs overlays;55    inherit (defaultData) config;56    unchecked = {57      inherit (uncheckedData) config;58    };59  };60}