avoid the with keyword
This commit is contained in:
parent
4c69ed4407
commit
a82ce313a5
1 changed files with 126 additions and 127 deletions
27
flake.nix
27
flake.nix
|
|
@ -35,18 +35,15 @@
|
||||||
nib,
|
nib,
|
||||||
deploy-rs,
|
deploy-rs,
|
||||||
...
|
...
|
||||||
} @ inputs:
|
} @ inputs: let
|
||||||
with builtins;
|
|
||||||
with nib.types; let
|
|
||||||
lib = nixpkgs.lib;
|
lib = nixpkgs.lib;
|
||||||
|
|
||||||
sys = with nib;
|
sys = nib.mkUSys {
|
||||||
mkUSys {
|
pkgs = nib.withPkgs nixpkgs {
|
||||||
pkgs = withPkgs nixpkgs {
|
|
||||||
config.allowUnfree = false;
|
config.allowUnfree = false;
|
||||||
overlays = attrValues self.overlays;
|
overlays = builtins.attrValues self.overlays;
|
||||||
};
|
};
|
||||||
upkgs = withPkgs nixpkgs-unstable {
|
upkgs = nib.withPkgs nixpkgs-unstable {
|
||||||
config.allowUnfree = false;
|
config.allowUnfree = false;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -67,6 +64,8 @@
|
||||||
mkNexusConfig = config: let
|
mkNexusConfig = config: let
|
||||||
# abstract node instance that stores all default values
|
# abstract node instance that stores all default values
|
||||||
templateNode = name: system: let
|
templateNode = name: system: let
|
||||||
|
Terminal = nib.types.Terminal;
|
||||||
|
|
||||||
missing = msg: path:
|
missing = msg: path:
|
||||||
Terminal (abort ''
|
Terminal (abort ''
|
||||||
Each Cerulean Nexus node is required to specify ${msg}!
|
Each Cerulean Nexus node is required to specify ${msg}!
|
||||||
|
|
@ -104,11 +103,11 @@
|
||||||
};
|
};
|
||||||
|
|
||||||
parseNode = name: nodeAttrs:
|
parseNode = name: nodeAttrs:
|
||||||
if !(isAttrs nodeAttrs)
|
if !(builtins.isAttrs nodeAttrs)
|
||||||
then
|
then
|
||||||
# fail if node is not an attribute set
|
# fail if node is not an attribute set
|
||||||
abort ''
|
abort ''
|
||||||
Cerulean Nexus nodes must be provided as an attribute set, got "${typeOf nodeAttrs}" instead!
|
Cerulean Nexus nodes must be provided as an attribute set, got "${builtins.typeOf nodeAttrs}" instead!
|
||||||
Ensure all `cerulean.nexus.nodes.${name}` declarations are attribute sets under your call to `cerulean.mkNexus`.
|
Ensure all `cerulean.nexus.nodes.${name}` declarations are attribute sets under your call to `cerulean.mkNexus`.
|
||||||
''
|
''
|
||||||
# TODO: nodeAttrs.system won't display any nice error messages!!
|
# TODO: nodeAttrs.system won't display any nice error messages!!
|
||||||
|
|
@ -117,7 +116,7 @@
|
||||||
templateAttrs = templateNode name nodeAttrs.system;
|
templateAttrs = templateNode name nodeAttrs.system;
|
||||||
S = nib.parse.parseStructFor templateAttrs nodeAttrs;
|
S = nib.parse.parseStructFor templateAttrs nodeAttrs;
|
||||||
in
|
in
|
||||||
unwrapRes (_:
|
nib.types.unwrapRes (_:
|
||||||
abort ''
|
abort ''
|
||||||
Cerulean failed to parse `cerulean.nexus.nodes.${name}`!
|
Cerulean failed to parse `cerulean.nexus.nodes.${name}`!
|
||||||
mergeStruct should never return `result.Err`... How are you here?!?
|
mergeStruct should never return `result.Err`... How are you here?!?
|
||||||
|
|
@ -125,7 +124,7 @@
|
||||||
S;
|
S;
|
||||||
|
|
||||||
# TODO: mapNodes = f: mapAttrs (name: nodeAttrs: f name (parseNode name nodeAttrs)) config.nexus.nodes
|
# TODO: mapNodes = f: mapAttrs (name: nodeAttrs: f name (parseNode name nodeAttrs)) config.nexus.nodes
|
||||||
mapNodes = f: mapAttrs f (mapAttrs parseNode config.nexus.nodes);
|
mapNodes = f: builtins.mapAttrs f (builtins.mapAttrs parseNode config.nexus.nodes);
|
||||||
in rec {
|
in rec {
|
||||||
nixosConfigurations = mapNodes (
|
nixosConfigurations = mapNodes (
|
||||||
_: node:
|
_: node:
|
||||||
|
|
@ -161,14 +160,14 @@
|
||||||
sshOpts =
|
sshOpts =
|
||||||
node.deploy.ssh.opts
|
node.deploy.ssh.opts
|
||||||
++ (
|
++ (
|
||||||
if elem "-p" node.deploy.ssh.opts
|
if builtins.elem "-p" node.deploy.ssh.opts
|
||||||
then []
|
then []
|
||||||
else ["-p" (toString node.deploy.ssh.port)]
|
else ["-p" (toString node.deploy.ssh.port)]
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
||||||
checks = mapAttrs (system: deployLib: deployLib.deployChecks deploy) deploy-rs.lib;
|
checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks deploy) deploy-rs.lib;
|
||||||
};
|
};
|
||||||
|
|
||||||
mkNexus = outputs: let
|
mkNexus = outputs: let
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue