git.delta.rocks / jrsonnet / refs/commits / 7c29776aea25

difftreelog

source

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