hercules-ci / flake-parts

❄️ Simplify Nix Flakes with the module system
https://flake.parts
MIT License
699 stars 38 forks source link

Generate nixosConfigurations #203

Open poelzi opened 7 months ago

poelzi commented 7 months ago

I try to generate the flake.nixosConfiguration attrset programatically but run into the same error every time.

Roughly speaking I try to do something like:

{ withSystem, inputs, lib, config, ... }:
{
  flake.nixosConfigurations = lib.mkMerge [
  (builtins.map (name:
    {
      "test.${name}" = inputs.nixpkgs.lib.nixosSystem {
        modules = [];
      };
    }
  ) ["foo"])
  ];
}

I tried a view dozens other methods so far, but always get this or some other error:

error: A definition for option `flake.nixosConfigurations' is not of type `lazy attribute set of raw value'. Definition values:
       - In `/nix/store/dz4vjwq2q95q94a25gmccx9na0r5x5jf-source/flake-module2.nix'

Which is odd because according to modules/nixosConfiguration.nix:

options = {
    flake = mkSubmoduleOptions {
      nixosConfigurations = mkOption {
        type = types.lazyAttrsOf types.raw;

it has the correct type.

I try to generate the flake.nixosConfiguration attrset programatically through a generator that looks at another datastructure.

roberth commented 7 months ago

Could you try without the [ ] around the mkMerge argument?