Base minor restructure

This commit is contained in:
kat witch 2021-08-18 02:36:40 +01:00
parent b383c70492
commit 83fb02ddc6
No known key found for this signature in database
GPG key ID: 1B477797DCA5EC72
4 changed files with 30 additions and 34 deletions

View file

@ -2,47 +2,56 @@ let
# Sources are from niv. # Sources are from niv.
sources = import ./nix/sources.nix; sources = import ./nix/sources.nix;
# We pass sources through to pkgs and get our nixpkgs + overlays. # We pass sources through to pkgs and get our nixpkgs + overlays.
pkgs = import ./pkgs.nix { inherit sources; }; pkgs = import ./overlay.nix { inherit sources; };
# We want our overlaid lib. # We want our overlaid lib.
inherit (pkgs) lib; inherit (pkgs) lib;
# This is used for caching niv sources in CI. # This is used for caching niv sources in CI.
sourceCache = import ./cache.nix { inherit sources lib; }; sourceCache = import ./cache.nix { inherit sources lib; };
# This is used for the base path for hostImport. # This is used for the base path for nodeImport.
root = ./.; root = ./.;
/* /*
This is used to generate specialArgs + the like. It works as such: This is used to generate specialArgs + the like. It works as such:
* A <subconfigName> can exist at config/<subconfigName>. * A <xargName> can exist at config/<subconfigName>.
* A <subconfigName> can exist at config/trusted/<subconfigName>. * A <xargName> can exist at config/trusted/<subconfigName>.
If only one exists, the path for that one is returned. If only one exists, the path for that one is returned.
Otherwise a module is generated which contains both import paths. Otherwise a module is generated which contains both import paths.
*/ */
subconfigNames = lib.unique (lib.folderList ./config ["trusted"] ++ lib.folderList ./config/trusted ["pkgs" "tf"]); xargNames = lib.unique (lib.folderList ./config ["trusted"] ++ lib.folderList ./config/trusted ["pkgs" "tf"]);
subconfig = lib.mapListToAttrs (folder: lib.nameValuePair folder (lib.domainMerge { xarg = lib.mapListToAttrs (folder: lib.nameValuePair folder (lib.domainMerge {
inherit folder; inherit folder;
folderPaths = [ (./config + "/${folder}") (./config/trusted + "/${folder}") ]; folderPaths = [ (./config + "/${folder}") (./config/trusted + "/${folder}") ];
})) subconfigNames; })) xargNames;
/* /*
We use this to make the meta runner use this file and to use `--show-trace` on nix-builds. We provide the runners with this file this way. We also provide our nix args here.
We also pass through pkgs to meta this way. This is also where pkgs are passed through to the meta config.
*/ */
metaConfig = import ./meta.nix { metaConfig = {
inherit pkgs lib; config = {
runners = {
lazy = {
file = root;
args = [ "--show-trace" ];
};
};
_module.args = {
pkgs = lib.mkDefault pkgs;
};
};
}; };
# This is where the meta config is evaluated. # This is where the meta config is evaluated.
eval = lib.evalModules { eval = lib.evalModules {
modules = lib.singleton metaConfig modules = lib.singleton metaConfig
++ lib.attrValues (removeAttrs subconfig.targets ["common"]) ++ lib.attrValues (removeAttrs xarg.targets ["common"])
++ lib.attrValues subconfig.hosts ++ lib.attrValues xarg.hosts
++ lib.optional (builtins.pathExists ./config/trusted/meta.nix) ./config/trusted/meta.nix
++ lib.singleton ./config/modules/meta/default.nix; ++ lib.singleton ./config/modules/meta/default.nix;
specialArgs = { specialArgs = {
inherit sources root; inherit sources root;
meta = self; meta = self;
} // subconfig; } // xarg;
}; };
# The evaluated meta config. # The evaluated meta config.
@ -50,7 +59,7 @@ let
/* /*
Please note all specialArg generated specifications use the folder common to both import paths. Please note all specialArg generated specifications use the folder common to both import paths.
Those import paths are as mentioned above next to `subconfigNames`. Those import paths are as mentioned above next to `xargNames`.
This provides us with a ./. that contains (most relevantly): This provides us with a ./. that contains (most relevantly):
* deploy.targets -> a mapping of target name to host names * deploy.targets -> a mapping of target name to host names
@ -61,5 +70,5 @@ let
* do not use common, it is tf-nix specific config ingested at line 66 of config/modules/meta/deploy.nix for every target. * do not use common, it is tf-nix specific config ingested at line 66 of config/modules/meta/deploy.nix for every target.
* services -> the specialArg generated from services/ * services -> the specialArg generated from services/
*/ */
self = config // { inherit pkgs lib sourceCache sources; } // subconfig; self = config // { inherit pkgs lib sourceCache sources; } // xarg;
in self in self

View file

@ -1,13 +0,0 @@
{ pkgs, lib, ... }: {
config = {
runners = {
lazy = {
file = ./.;
args = [ "--show-trace" ];
};
};
_module.args = {
pkgs = lib.mkDefault pkgs;
};
};
}

View file

@ -31,8 +31,8 @@
echo $f echo $f
nix run --arg config $f ci.run.gh-actions-generate nix run --arg config $f ci.run.gh-actions-generate
done done
cd ${toString ./depot/trusted} cd ${toString ./config/trusted}
export TRUSTED_CONFIG_ROOT=${toString ./depot/trusted}/ci export TRUSTED_CONFIG_ROOT=${toString ./config/trusted}/ci
TRUSTED_CONFIG_FILES=($TRUSTED_CONFIG_ROOT/nodes.nix) TRUSTED_CONFIG_FILES=($TRUSTED_CONFIG_ROOT/nodes.nix)
for f in "''${TRUSTED_CONFIG_FILES[@]}"; do for f in "''${TRUSTED_CONFIG_FILES[@]}"; do
echo $f echo $f
@ -49,8 +49,8 @@
echo $f echo $f
nix run --arg config $f ci.test nix run --arg config $f ci.test
done done
cd ${toString ./depot/trusted} cd ${toString ./config/trusted}
export TRUSTED_CONFIG_ROOT=${toString ./depot/trusted}/ci export TRUSTED_CONFIG_ROOT=${toString ./config/trusted}/ci
TRUSTED_CONFIG_FILES=($TRUSTED_CONFIG_ROOT/nodes.nix) TRUSTED_CONFIG_FILES=($TRUSTED_CONFIG_ROOT/nodes.nix)
for f in "''${TRUSTED_CONFIG_FILES[@]}"; do for f in "''${TRUSTED_CONFIG_FILES[@]}"; do
echo $f echo $f