snowfield/lib/default.nix

75 lines
1.8 KiB
Nix
Raw Permalink Normal View History

2024-08-24 22:27:29 +02:00
inputs: profiles: dnsLib: final: _prev:
2021-12-29 16:41:31 +01:00
with builtins;
2024-08-12 18:15:30 +02:00
let
evalMeta =
raw:
(_prev.evalModules {
modules = [
(import ../modules/meta/default.nix)
{ machine.meta = raw; }
];
2024-08-14 20:23:21 +02:00
specialArgs = {
inherit profiles;
};
2024-08-12 18:15:30 +02:00
}).config.machine.meta;
non_local_machines = (import ./snowfield.nix).machines;
2024-08-12 18:15:30 +02:00
in
2024-08-10 17:57:46 +02:00
rec {
importConfig =
path:
(mapAttrs (name: _value: import (path + "/${name}/default.nix")) (
final.filterAttrs (_: v: v == "directory") (readDir path)
));
2021-12-29 11:34:55 +01:00
2021-12-29 17:40:57 +01:00
mkSubdomain = name: port: {
luj.nginx.enable = true;
services.nginx.virtualHosts."${name}.julienmalka.me" = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://localhost:${toString port}";
};
};
};
mkVPNSubdomain = name: port: {
luj.nginx.enable = true;
2022-04-02 19:57:47 +02:00
services.nginx.virtualHosts."${name}.luj" = {
forceSSL = true;
enableACME = true;
locations."/" = {
proxyPass = "http://localhost:${toString port}";
};
};
};
2024-08-12 18:15:30 +02:00
listToAttrsWithMerge =
l:
mapAttrs (_: v: _prev.fold (elem: acc: elem.value // acc) { } v) (builtins.groupBy (e: e.name) l);
mapAttrsWithMerge = f: set: listToAttrsWithMerge (map (attr: f attr set.${attr}) (attrNames set));
2024-08-10 17:57:46 +02:00
snowfield =
(mapAttrs (
name: _value:
let
machineF = import (../machines + "/${name}/default.nix");
in
evalMeta
2024-08-14 22:13:13 +02:00
(machineF (
(mapAttrs (_: _: null) (builtins.functionArgs machineF)) // { inherit inputs profiles; }
)).machine.meta
) (final.filterAttrs (_: v: v == "directory") (readDir ../machines)))
// mapAttrs (_: evalMeta) non_local_machines;
2022-02-19 22:05:59 +01:00
2024-08-12 18:12:37 +02:00
dns = import ./dns.nix {
lib = final;
2024-08-24 22:27:29 +02:00
inherit dnsLib;
2024-08-12 18:12:37 +02:00
};
2024-08-12 18:15:30 +02:00
2024-08-24 22:45:30 +02:00
mkMachine = import ./mkmachine.nix inputs final;
2021-12-29 11:34:55 +01:00
}