-
-
Notifications
You must be signed in to change notification settings - Fork 13.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot use runTest
if a different specialArgs
is required per node
#218006
Comments
We could get the name from a new attrsOf, and then have nodes be like nodes = mkOption {
type = dependentAttrsOf (name: submoduleWith { specialArgs = config.node.makeSpecialArgs name; /*...*/ }); dependentAttrsOf = elemTypeFn:
let
# Only suitable for documentation
staticElemType = elemTypeFn "<name>";
in mkOptionType rec {
name = "lazyAttrsOf";
description = "lazy attribute set of ${optionDescriptionPhrase (class: class == "noun" || class == "composite") staticElemType}";
descriptionClass = "composite";
check = isAttrs;
merge = loc: defs:
zipAttrsWith (name: defs:
let merged = mergeDefinitions (loc ++ [name]) (elemTypeFn name) defs;
# mergedValue will trigger an appropriate error when accessed
in merged.optionalValue.value or (elemTypeFn name).emptyValue.value or merged.mergedValue
)
# Push down position info.
(map (def: mapAttrs (n: v: { inherit (def) file; value = v; }) def.value) defs);
emptyValue = { value = {}; };
getSubOptions = prefix: staticElemType.getSubOptions (prefix ++ ["<name>"]);
getSubModules = staticElemType.getSubModules;
substSubModules = m: dependentAttrsOf (name: (elemTypeFn name).substSubModules m);
functor = (defaultFunctor name) // { wrapped = elemTypeFn; };
nestedTypes.elemType = staticElemType;
}; |
@infinisil What do you think of I think it might also solve the problem with |
I am not convinced we need to invent a new solution to this problem. Looking at the original post using pinnedConfigs.${host.provider_name}.${host.deployment_version}
// {
boot.loader.grub.device = disk;
} Use {
fileSystems."/" = lib.mkIf is_this_the_right_host_and_version {
device = disk;
fsType = "ext4";
};
boot.loader.grub.device = disk;
} |
While the element type is significantly different for this variation of Axes of variation
The latter two are fun; specifying a type should allow the type to convert the string attrName to a better type, such as |
Describe the bug
Using
nixos-lib.runTest
doesn't allow to pass differentnode.specialArgs
per node when using variousnodes
.Steps To Reproduce
N/A (feature request)
Expected behavior
Since it supports using various nodes,
runTest
should also support passing differentspecialArgs
per node.Screenshots
N/A
Additional context
I deploy machines using terraform. Those deployments output a lock file that I use to generate
nixosConfigurations
. Each machine is different. I want to test that usingrunTest
. These machines produce a k8s cluster, so they need to be tested together.The machines get an
inventory
argument that allows them to know about themselves and about each other. As explained in the forum, using_module.args
produces an infinite recursion, so the only valid solution is to pass the inventory asspecialArgs
.If I cannot pass a
specialArgs
per node, nodes cannot know about themselves and about each other, and thus the cluster cannot be tested with VMs as closely to production configuration as I'd want to.This is where you can define multiple nodes for a test:
nixpkgs/nixos/lib/testing/nodes.nix
Lines 41 to 53 in 7d0ed7f
This is where you can define only one single
specialArgs
shared across all nodes:nixpkgs/nixos/lib/testing/nodes.nix
Lines 71 to 79 in 7d0ed7f
To fix the problem, a possible solution would be to support the case when
node.specialArgs
is a function. In that case, the function could be called with the machine name as the 1st argument, and thespecialArgs
would be the attrset obtained from that function. Example:Notify maintainers
@roberth
Metadata
Please run
nix-shell -p nix-info --run "nix-info -m"
and paste the result.@moduon MT-1075
The text was updated successfully, but these errors were encountered: