mirror of
https://github.com/gensokyo-zone/infrastructure.git
synced 2026-02-10 04:49:19 -08:00
project-wide: nixfmt -> nixpkgs-fmt, applied
This commit is contained in:
parent
7383fc6ba2
commit
fc1369f873
40 changed files with 698 additions and 599 deletions
|
|
@ -5,17 +5,21 @@
|
|||
let
|
||||
pairs = lib.imap0 (lib.flip lib.nameValuePair) hexChars;
|
||||
idx = builtins.listToAttrs pairs;
|
||||
in idx.${lib.toLower char};
|
||||
in
|
||||
idx.${lib.toLower char};
|
||||
hexToInt = str:
|
||||
lib.foldl (value: chr: value * 16 + hexCharToInt chr) 0
|
||||
(lib.stringToCharacters str);
|
||||
(lib.stringToCharacters str);
|
||||
hextorgba = hex:
|
||||
(let
|
||||
r_hex = lib.substring 1 2 hex;
|
||||
g_hex = lib.substring 3 2 hex;
|
||||
b_hex = lib.substring 5 2 hex;
|
||||
r_dec = hexToInt r_hex;
|
||||
g_dec = hexToInt g_hex;
|
||||
b_dec = hexToInt b_hex;
|
||||
in "rgba(${toString r_dec}, ${toString g_dec}, ${toString b_dec}, 0.75)");
|
||||
(
|
||||
let
|
||||
r_hex = lib.substring 1 2 hex;
|
||||
g_hex = lib.substring 3 2 hex;
|
||||
b_hex = lib.substring 5 2 hex;
|
||||
r_dec = hexToInt r_hex;
|
||||
g_dec = hexToInt g_hex;
|
||||
b_dec = hexToInt b_hex;
|
||||
in
|
||||
"rgba(${toString r_dec}, ${toString g_dec}, ${toString b_dec}, 0.75)"
|
||||
);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,18 +14,20 @@ let
|
|||
tf = { targetName, target }:
|
||||
tfEval ({ config, ... }: {
|
||||
imports = optional (builtins.pathExists ../trusted/tf) (import ../trusted/tf/meta.nix)
|
||||
++ map (hostName: ../hosts + "/${hostName}/meta.nix") target ++ [{
|
||||
config = mkMerge (map (hostName:
|
||||
mapAttrs (_: mkMerge) hosts.${hostName}.config.deploy.tf.out.set)
|
||||
++ map (hostName: ../hosts + "/${hostName}/meta.nix") target ++ [{
|
||||
config = mkMerge (map
|
||||
(hostName:
|
||||
mapAttrs (_: mkMerge) hosts.${hostName}.config.deploy.tf.out.set)
|
||||
target);
|
||||
}] ++ optional
|
||||
(builtins.pathExists (../trusted/targets + "/${targetName}"))
|
||||
(../trusted/targets + "/${targetName}")
|
||||
++ optional (builtins.pathExists (../targets + "/${targetName}"))
|
||||
(../targets + "/${targetName}") ++ concatMap (hostName:
|
||||
(../targets + "/${targetName}") ++ concatMap
|
||||
(hostName:
|
||||
filter builtins.pathExists
|
||||
(map (profile: ../profiles + "/${profile}/meta.nix") (attrNames
|
||||
(filterAttrs (_: id) hosts.${hostName}.config.deploy.profile))))
|
||||
(map (profile: ../profiles + "/${profile}/meta.nix") (attrNames
|
||||
(filterAttrs (_: id) hosts.${hostName}.config.deploy.profile))))
|
||||
target;
|
||||
|
||||
deps = {
|
||||
|
|
@ -73,7 +75,8 @@ let
|
|||
inherit targetName;
|
||||
};
|
||||
});
|
||||
in {
|
||||
in
|
||||
{
|
||||
inherit tf;
|
||||
target =
|
||||
mapAttrs (targetName: target: tf { inherit target targetName; }) targets;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,11 @@
|
|||
{ pkgs, target, users, hostsDir ? ../hosts, profiles, pkgsPath ? ../pkgs
|
||||
, sources ? { } }:
|
||||
{ pkgs
|
||||
, target
|
||||
, users
|
||||
, hostsDir ? ../hosts
|
||||
, profiles
|
||||
, pkgsPath ? ../pkgs
|
||||
, sources ? { }
|
||||
}:
|
||||
|
||||
with pkgs.lib;
|
||||
|
||||
|
|
@ -18,18 +24,21 @@ rec {
|
|||
};
|
||||
};
|
||||
|
||||
hosts = listToAttrs (map (hostName:
|
||||
nameValuePair hostName (import (pkgs.path + "/nixos/lib/eval-config.nix") {
|
||||
modules = [
|
||||
(hostConfig hostName)
|
||||
(if sources ? home-manager then
|
||||
sources.home-manager + "/nixos"
|
||||
else
|
||||
{ })
|
||||
];
|
||||
specialArgs = { inherit sources target profiles hostName users; };
|
||||
})) hostNames);
|
||||
hosts = listToAttrs (map
|
||||
(hostName:
|
||||
nameValuePair hostName (import (pkgs.path + "/nixos/lib/eval-config.nix") {
|
||||
modules = [
|
||||
(hostConfig hostName)
|
||||
(if sources ? home-manager then
|
||||
sources.home-manager + "/nixos"
|
||||
else
|
||||
{ })
|
||||
];
|
||||
specialArgs = { inherit sources target profiles hostName users; };
|
||||
}))
|
||||
hostNames);
|
||||
|
||||
targets = foldAttrs (host: hosts: [ host ] ++ hosts) [ ] (mapAttrsToList
|
||||
(hostName: host: { ${host.config.deploy.target} = hostName; }) hosts);
|
||||
(hostName: host: { ${host.config.deploy.target} = hostName; })
|
||||
hosts);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,19 +5,23 @@ with builtins;
|
|||
let
|
||||
filterAttrNamesToList = filter: set:
|
||||
foldl' (a: b: a ++ b) [ ]
|
||||
(map (e: if (filter e set.${e}) then [ e ] else [ ]) (attrNames set));
|
||||
(map (e: if (filter e set.${e}) then [ e ] else [ ]) (attrNames set));
|
||||
nameValuePair = name: value: { inherit name value; };
|
||||
listToAttrs = foldl' (acc: val: acc // { ${val.name} = val.value; }) { };
|
||||
directories =
|
||||
filterAttrNamesToList (_: type: type == "directory") (readDir modulesDir);
|
||||
files = map (dir: nameValuePair dir (modulesDir + "/${dir}/${defaultFile}"))
|
||||
directories;
|
||||
modules = map ({ name, value }:
|
||||
# if the file contains a function, assume it to be a module and pass the path
|
||||
# (for dedup and such). if it contains anything else, pass that.
|
||||
let m = import value;
|
||||
in {
|
||||
inherit name;
|
||||
value = if (isFunction m) && !importAll then value else m;
|
||||
}) files;
|
||||
in (listToAttrs modules)
|
||||
modules = map
|
||||
({ name, value }:
|
||||
# if the file contains a function, assume it to be a module and pass the path
|
||||
# (for dedup and such). if it contains anything else, pass that.
|
||||
let m = import value;
|
||||
in
|
||||
{
|
||||
inherit name;
|
||||
value = if (isFunction m) && !importAll then value else m;
|
||||
})
|
||||
files;
|
||||
in
|
||||
(listToAttrs modules)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue