Skip to content

Commit 5182ff4

Browse files
committed
eval-machine-info: a bit of cleanup
1 parent 7eba0d0 commit 5182ff4

File tree

1 file changed

+20
-35
lines changed

1 file changed

+20
-35
lines changed

nix/eval-machine-info.nix

+20-35
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,6 @@
1010
}:
1111

1212
let
13-
call = x: if builtins.isFunction x then x args else x;
14-
15-
zipAttrs = set: builtins.listToAttrs (
16-
map (name: { inherit name; value = builtins.catAttrs name set; }) (builtins.concatMap builtins.attrNames set));
17-
1813
flakeExpr = flake.outputs.nixopsConfigurations.default or { };
1914

2015
nixpkgsBoot = toString <nixpkgs> ; # this will be replaced on install by nixops' nixpkgs input
@@ -49,12 +44,10 @@ in rec {
4944
./net.nix
5045
({ config, ... }: {
5146
resources.imports = pluginResourceModules ++ [ deploymentInfoModule ];
52-
network.resourcesDefaults.imports = [
53-
(resourceModuleArgs_ rec{
54-
inherit (config) nodes resources;
55-
machines = nodes;
56-
})
57-
];
47+
network.resourcesDefaults = resourceModuleArgs_ rec{
48+
inherit (config) nodes resources;
49+
machines = nodes;
50+
};
5851
network.nodeExtraArgs = { inherit uuid deploymentName; };
5952
defaults.environment.checkConfigurationOptions = lib.mkOverride 900 checkConfigurationOptions;
6053
# Make NixOps's deployment.* options available.
@@ -67,7 +60,7 @@ in rec {
6760
networks = [ net.config ];
6861

6962
# skip problematic resources entries
70-
resources = lib.attrsets.filterAttrs(n: v: lib.lists.all(e: e!=n)["deployment" "_name" "_type"]) net.config.resources;
63+
resources = removeAttrs net.config.resources ["deployment" "_name" "_type"];
7164
defaults = [ net.config.defaults ];
7265
nodes = #TODO: take options and other modules outputs for each node
7366
lib.mapAttrs (n: v: {
@@ -76,36 +69,28 @@ in rec {
7669
inherit (v.nixpkgs) pkgs;
7770
}) net.config.nodes;
7871

79-
importedPluginNixExprs = map
80-
(expr: import expr)
81-
pluginNixExprs;
82-
pluginOptions = lib.foldl (a: e: a ++ e.options) [ ] importedPluginNixExprs;
72+
importedPluginNixExprs = map import pluginNixExprs;
73+
pluginOptions = lib.lists.concatMap (e: e.options) importedPluginNixExprs;
8374
pluginResources = map (e: e.resources) importedPluginNixExprs;
84-
pluginDeploymentConfigExporters = (lib.foldl
85-
(a: e: a ++ (e.config_exporters {
86-
inherit pkgs;
87-
inherit (lib) optionalAttrs;
88-
})) [ ]
89-
importedPluginNixExprs);
75+
pluginDeploymentConfigExporters = lib.lists.concatMap (e: e.config_exporters {
76+
inherit pkgs;
77+
inherit (lib) optionalAttrs;
78+
}) importedPluginNixExprs;
9079

9180
# Compute the definitions of the non-machine resources.
9281
resourcesByType = lib.zipAttrs (network.resources or []);
9382

94-
deploymentInfoModule = {
95-
deployment = {
96-
name = deploymentName;
97-
arguments = args;
98-
inherit uuid;
99-
};
83+
deploymentInfoModule.deployment = {
84+
name = deploymentName;
85+
arguments = args;
86+
inherit uuid;
10087
};
10188

102-
defaultResourceModule = {
103-
imports = [
104-
./resource.nix
105-
resourceModuleArgs
106-
deploymentInfoModule
107-
];
108-
};
89+
defaultResourceModule.imports = [
90+
./resource.nix
91+
resourceModuleArgs
92+
deploymentInfoModule
93+
];
10994

11095
pluginResourceModules = lib.lists.concatMap (lib.mapAttrsToList toResourceModule) pluginResourceLegacyReprs;
11196

0 commit comments

Comments
 (0)