feat: try rework
This commit is contained in:
parent
1ddbd3b8b6
commit
ecf10628c3
51 changed files with 1941 additions and 445 deletions
40
validation/web.nix
Normal file
40
validation/web.nix
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
let
|
||||
lib = import <nixpkgs/lib>;
|
||||
|
||||
ensureStoreName = name:
|
||||
if builtins.match "^[A-Za-z_][A-Za-z0-9_-]*$" name != null then
|
||||
name
|
||||
else
|
||||
throw "config/web.nix store name '${name}' is invalid. Use letters, numbers, '_' or '-', starting with a letter or '_' .";
|
||||
|
||||
validateStore = name: store:
|
||||
let
|
||||
_ = ensureStoreName name;
|
||||
__ =
|
||||
if builtins.isAttrs store then
|
||||
null
|
||||
else
|
||||
throw "config/web.nix stores.${name} must be an attrset.";
|
||||
___ =
|
||||
if store ? root && builtins.isPath store.root then
|
||||
null
|
||||
else
|
||||
throw "config/web.nix stores.${name}.root must be a Nix path.";
|
||||
in
|
||||
store;
|
||||
|
||||
getStores = webConfig:
|
||||
let
|
||||
stores =
|
||||
if builtins.isAttrs webConfig && webConfig ? stores && builtins.isAttrs webConfig.stores then
|
||||
webConfig.stores
|
||||
else
|
||||
throw "config/web.nix must define stores as an attrset.";
|
||||
|
||||
_ = lib.mapAttrs validateStore stores;
|
||||
in
|
||||
stores;
|
||||
in
|
||||
rec {
|
||||
inherit getStores;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue