warn if reserved inputs provided
This commit is contained in:
parent
3e29615db9
commit
b1b1743414
1 changed files with 43 additions and 11 deletions
|
|
@ -4,23 +4,55 @@
|
||||||
systems,
|
systems,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
|
inherit
|
||||||
|
(builtins)
|
||||||
|
attrNames
|
||||||
|
concatStringsSep
|
||||||
|
filter
|
||||||
|
length
|
||||||
|
removeAttrs
|
||||||
|
warn
|
||||||
|
;
|
||||||
|
|
||||||
inherit (inputs.nixpkgs) lib;
|
inherit (inputs.nixpkgs) lib;
|
||||||
in {
|
in {
|
||||||
# snow.flake
|
# snow.flake
|
||||||
flake = flakeInputs: root: let
|
flake = flakeInputs: root: let
|
||||||
snowflake = lib.evalModules {
|
snowflake = lib.evalModules {
|
||||||
class = "snowflake";
|
class = "snowflake";
|
||||||
# XXX: TODO: abort if inputs contains reserved names
|
specialArgs = let
|
||||||
specialArgs =
|
reservedInputs = {
|
||||||
(flakeInputs
|
inherit (this) snow;
|
||||||
// {
|
inherit systems root;
|
||||||
inherit (this) snow;
|
inputs = flakeInputs;
|
||||||
inherit systems root;
|
};
|
||||||
inputs = flakeInputs;
|
|
||||||
})
|
warnIfReserved = let
|
||||||
# XXX: TODO:
|
getReservedNames = names:
|
||||||
# |> (x: builtins.removeAttrs x ["self" "nodes"]);
|
reservedInputs
|
||||||
|> (x: builtins.removeAttrs x ["self"]);
|
|> attrNames
|
||||||
|
|> filter (name: names?${name});
|
||||||
|
|
||||||
|
reservedNames =
|
||||||
|
flakeInputs
|
||||||
|
|> attrNames
|
||||||
|
|> getReservedNames;
|
||||||
|
in
|
||||||
|
(length reservedNames == 0)
|
||||||
|
|| warn ''
|
||||||
|
[snow] Your `flake.nix` declares inputs using reserved names!
|
||||||
|
[snow] These will be accessible only via `inputs.''${NAME}`
|
||||||
|
[snow] Please rename the following:
|
||||||
|
[snow] ${concatStringsSep reservedNames ", "}
|
||||||
|
''
|
||||||
|
true;
|
||||||
|
in
|
||||||
|
assert warnIfReserved;
|
||||||
|
flakeInputs
|
||||||
|
// reservedInputs
|
||||||
|
# XXX: TODO:
|
||||||
|
# |> (x: builtins.removeAttrs x ["self" "nodes"]);
|
||||||
|
|> (x: removeAttrs x ["self"]);
|
||||||
|
|
||||||
modules = [
|
modules = [
|
||||||
./module.nix
|
./module.nix
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue