nixos-generators
nixos-generators copied to clipboard
Module usage: Compatibility with NixOS stable broken
Since https://github.com/nix-community/nixos-generators/pull/375, it's not possible to use the modules such as nixos-generators.nixosModules.linode while building images based on the latest stable nixos (24.05) .
e.g. an example flake like the below fails:
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-24.05";
nixos-generators = {
url = "github:nix-community/nixos-generators";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs = {
self,
nixpkgs,
nixos-generators
}: {
nixosConfigurations.example = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
nixos-generators.nixosModules.linode
./configuration.nix
];
};
};
}
You get the following error:
error:
… while calling the 'seq' builtin
at /nix/store/9g88fck8ggiah5znz5xn2kxzfr6l7cdq-source/lib/modules.nix:322:18:
321| options = checked options;
322| config = checked (removeAttrs config [ "_module" ]);
| ^
323| _module = checked (config._module);
… while evaluating a branch condition
at /nix/store/9g88fck8ggiah5znz5xn2kxzfr6l7cdq-source/lib/modules.nix:261:9:
260| checkUnmatched =
261| if config._module.check && config._module.freeformType == null && merged.unmatchedDefns != [] then
| ^
262| let
… in the left operand of the AND (&&) operator
at /nix/store/9g88fck8ggiah5znz5xn2kxzfr6l7cdq-source/lib/modules.nix:261:72:
260| checkUnmatched =
261| if config._module.check && config._module.freeformType == null && merged.unmatchedDefns != [] then
| ^
262| let
… in the left operand of the AND (&&) operator
at /nix/store/9g88fck8ggiah5znz5xn2kxzfr6l7cdq-source/lib/modules.nix:261:33:
260| checkUnmatched =
261| if config._module.check && config._module.freeformType == null && merged.unmatchedDefns != [] then
| ^
262| let
… while evaluating a branch condition
at /nix/store/9g88fck8ggiah5znz5xn2kxzfr6l7cdq-source/lib/modules.nix:254:12:
253|
254| in if declaredConfig._module.freeformType == null then declaredConfig
| ^
255| # Because all definitions that had an associated option ended in
… from call site
at /nix/store/9g88fck8ggiah5znz5xn2kxzfr6l7cdq-source/lib/modules.nix:242:28:
241| # For definitions that have an associated option
242| declaredConfig = mapAttrsRecursiveCond (v: ! isOption v) (_: v: v.value) options;
| ^
243|
… while calling 'mapAttrsRecursiveCond'
at /nix/store/9g88fck8ggiah5znz5xn2kxzfr6l7cdq-source/lib/attrsets.nix:1201:5:
1200| f:
1201| set:
| ^
1202| let
… from call site
at /nix/store/9g88fck8ggiah5znz5xn2kxzfr6l7cdq-source/lib/modules.nix:234:33:
233| ({ inherit lib options config specialArgs; } // specialArgs);
234| in mergeModules prefix (reverseList collected);
| ^
235|
… while calling 'reverseList'
at /nix/store/9g88fck8ggiah5znz5xn2kxzfr6l7cdq-source/lib/lists.nix:1116:17:
1115| */
1116| reverseList = xs:
| ^
1117| let l = length xs; in genList (n: elemAt xs (l - n - 1)) l;
… from call site
at /nix/store/9g88fck8ggiah5znz5xn2kxzfr6l7cdq-source/lib/modules.nix:229:25:
228| merged =
229| let collected = collectModules
| ^
230| class
… while calling anonymous lambda
at /nix/store/9g88fck8ggiah5znz5xn2kxzfr6l7cdq-source/lib/modules.nix:445:37:
444|
445| in modulesPath: initialModules: args:
| ^
446| filterModules modulesPath (collectStructuredModules unknownModule "" initialModules args);
… from call site
at /nix/store/9g88fck8ggiah5znz5xn2kxzfr6l7cdq-source/lib/modules.nix:446:7:
445| in modulesPath: initialModules: args:
446| filterModules modulesPath (collectStructuredModules unknownModule "" initialModules args);
| ^
447|
… while calling 'filterModules'
at /nix/store/9g88fck8ggiah5znz5xn2kxzfr6l7cdq-source/lib/modules.nix:413:36:
412| # modules recursively. It returns the final list of unique-by-key modules
413| filterModules = modulesPath: { disabled, modules }:
| ^
414| let
… while calling anonymous lambda
at /nix/store/9g88fck8ggiah5znz5xn2kxzfr6l7cdq-source/lib/modules.nix:439:31:
438| disabledKeys = concatMap ({ file, disabled }: map (moduleKey file) disabled) disabled;
439| keyFilter = filter (attrs: ! elem attrs.key disabledKeys);
| ^
440| in map (attrs: attrs.module) (builtins.genericClosure {
… from call site
at /nix/store/9g88fck8ggiah5znz5xn2kxzfr6l7cdq-source/lib/modules.nix:400:22:
399| let
400| module = checkModule (loadModule args parentFile "${parentKey}:anon-${toString n}" x);
| ^
401| collectedImports = collectStructuredModules module._file module.key module.imports args;
… while calling anonymous lambda
at /nix/store/9g88fck8ggiah5znz5xn2kxzfr6l7cdq-source/lib/modules.nix:359:11:
358| then
359| m:
| ^
360| if m._class != null -> m._class == class
… from call site
at /nix/store/9g88fck8ggiah5znz5xn2kxzfr6l7cdq-source/lib/modules.nix:400:35:
399| let
400| module = checkModule (loadModule args parentFile "${parentKey}:anon-${toString n}" x);
| ^
401| collectedImports = collectStructuredModules module._file module.key module.imports args;
… while calling 'loadModule'
at /nix/store/9g88fck8ggiah5znz5xn2kxzfr6l7cdq-source/lib/modules.nix:336:53:
335| # Like unifyModuleSyntax, but also imports paths and calls functions if necessary
336| loadModule = args: fallbackFile: fallbackKey: m:
| ^
337| if isFunction m then
… from call site
at /nix/store/9g88fck8ggiah5znz5xn2kxzfr6l7cdq-source/lib/modules.nix:354:14:
353| throw "Module imports can't be nested lists. Perhaps you meant to remove one level of lists? Definitions: ${showDefs defs}"
354| else unifyModuleSyntax (toString m) (toString m) (applyModuleArgsIfFunction (toString m) (import m) args);
| ^
355|
… while calling 'unifyModuleSyntax'
at /nix/store/9g88fck8ggiah5znz5xn2kxzfr6l7cdq-source/lib/modules.nix:454:34:
453| of ‘options’, ‘config’ and ‘imports’ attributes. */
454| unifyModuleSyntax = file: key: m:
| ^
455| let
… from call site
at /nix/store/9g88fck8ggiah5znz5xn2kxzfr6l7cdq-source/lib/modules.nix:354:59:
353| throw "Module imports can't be nested lists. Perhaps you meant to remove one level of lists? Definitions: ${showDefs defs}"
354| else unifyModuleSyntax (toString m) (toString m) (applyModuleArgsIfFunction (toString m) (import m) args);
| ^
355|
… while calling 'applyModuleArgsIfFunction'
at /nix/store/9g88fck8ggiah5znz5xn2kxzfr6l7cdq-source/lib/modules.nix:488:39:
487|
488| applyModuleArgsIfFunction = key: f: args@{ config, options, lib, ... }:
| ^
489| if isFunction f then applyModuleArgs key f args else f;
… from call site
at /nix/store/9g88fck8ggiah5znz5xn2kxzfr6l7cdq-source/lib/modules.nix:489:8:
488| applyModuleArgsIfFunction = key: f: args@{ config, options, lib, ... }:
489| if isFunction f then applyModuleArgs key f args else f;
| ^
490|
… while calling 'isFunction'
at /nix/store/9g88fck8ggiah5znz5xn2kxzfr6l7cdq-source/lib/trivial.nix:929:16:
928| */
929| isFunction = f: builtins.isFunction f ||
| ^
930| (f ? __functor && isFunction (f.__functor f));
error: getting status of '/nix/store/9g88fck8ggiah5znz5xn2kxzfr6l7cdq-source/nixos/modules/virtualisation/disk-size-option.nix': No such file or directory
Given the readme shows an example of using nixos-generators with nixos-23.11, I expected that the current version of nixos-generators would support the current stable version of NixOS.
hmm that is indeed a bit unfortunate. we wanted to deprecate this repo soon as we are working to migrating in into nixpkgs. Not sure if @phaer has time and energy to make this repo compatible with 24.05 in the meantime? :)
Ups, a bit of an oversight indeed - with the 24.11 branch-off so close, I didn't really think about 24.05 compat for the upstreaming thing.
There's no back port of the options, so we'd probably have to add conditionals on the Nixos release to pretty much all formats, I believe?
Given that there weren't an afwul lot of changes here recently, maybe its sufficient to branch of before today's PRs got merged for 24.05?
I ran in the same problem! A NixOS compatibility branch would be great to avoid such annoying compatibility issues.
Manually setting inputs.nixos-generators.url to github:nix-community/nixos-generators/7c60ba4bc8d6aa2ba3e5b0f6ceb9fc07bc261565 seems to be a valid workaround for the time being until a tag/branch is added.