cerulean/nix/snow/flake/default.nix

69 lines
1.5 KiB
Nix
Raw Normal View History

{
2026-03-17 20:37:59 +10:00
self,
this,
inputs,
systems,
...
}: let
2026-03-14 21:01:02 +10:00
inherit
(builtins)
attrNames
concatStringsSep
filter
length
warn
;
inherit (inputs.nixpkgs) lib;
in {
# snow.flake
2026-03-17 20:37:59 +10:00
# XXX: TODO: stop taking in root as parameter (maybe take self instead?)
flake = flakeInputs: root: let
snowflake = lib.evalModules {
class = "snowflake";
2026-03-14 21:01:02 +10:00
specialArgs = let
2026-03-14 22:18:28 +10:00
reservedSpecialArgs = {
2026-03-17 20:37:59 +10:00
# inherit (this) snow;
snow = this;
2026-03-14 21:01:02 +10:00
inherit systems root;
inputs = flakeInputs;
2026-03-17 20:37:59 +10:00
_snowFlake = {
inherit self inputs;
};
2026-03-14 21:01:02 +10:00
};
warnIfReserved = let
getReservedNames = names:
2026-03-14 22:18:28 +10:00
reservedSpecialArgs
2026-03-14 21:01:02 +10:00
|> attrNames
|> filter (name: names?${name});
reservedNames =
flakeInputs
|> attrNames
|> getReservedNames;
in
(length reservedNames == 0)
|| warn ''
2026-03-14 22:18:28 +10:00
[snow] Your `flake.nix` declares inputs with reserved names!
2026-03-14 21:01:02 +10:00
[snow] These will be accessible only via `inputs.''${NAME}`
[snow] Please rename the following:
[snow] ${concatStringsSep reservedNames ", "}
''
true;
in
assert warnIfReserved;
2026-03-14 22:18:28 +10:00
flakeInputs // reservedSpecialArgs;
modules = [
2026-03-17 20:37:59 +10:00
./nodes
./modules
./outputs
(this.lib.findImport /${root}/snow)
];
};
in
snowflake.config.outputs;
}