nixos-generators icon indicating copy to clipboard operation
nixos-generators copied to clipboard

error: attribute 'formats' missing

Open malik-n opened this issue 10 months ago • 4 comments

Trying to create an lxc image with a flake.nix

{
  description = "Flake to create vs-code-server-container image";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs";
    nixos-generators = {
      url = "github:nix-community/nixos-generators";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    vscode-server.url = "github:nix-community/nixos-vscode-server";
  };

  outputs = { nixpkgs, self, nixos-generators, ... }:
  let
  inputs = self.inputs;
    forAllSystems = nixpkgs.lib.genAttrs [
      "x86_64-linux"
      "aarch64-linux"
    ];
    pkgs = forAllSystems (system: import nixpkgs { inherit system; });
    specialArgs = {
      inherit pkgs inputs;
    };
  in {
    packages = forAllSystems( system: rec {
      default = vs-code-server-container;
      vs-code-server-container = nixos-generators.nixosGenerate {
        inherit system specialArgs;
        format = "lxc";
        modules = [
          {
            nix.registry.nixpkgs.flake = nixpkgs;
            boot.isContainer = true;
            nixpkgs.pkgs = pkgs;
          }
          ./configuration.nix
          inputs.vscode-server.nixosModules.default
        ];
      };
    });
  };
}

And a minimal configuration.nix

{ modulesPath, ... }:

{
  imports = [
    (modulesPath + "/profiles/minimal.nix")
    (modulesPath + "/misc/nixpkgs/read-only.nix")
  ];

  services.vscode-server.enable = true;
  hardware.bluetooth.enable = false;
}

But getting the following error

error:
       … while evaluating the attribute 'config.system.build."${(image).config.formatAttr}"'
         at /nix/store/0vzw30bmdik5zd1mj6cr88z9773a5ra3-source/lib/modules.nix:334:9:
          333|         options = checked options;
          334|         config = checked (removeAttrs config [ "_module" ]);
             |         ^
          335|         _module = checked (config._module);

       … while calling the 'seq' builtin
         at /nix/store/0vzw30bmdik5zd1mj6cr88z9773a5ra3-source/lib/modules.nix:334:18:
          333|         options = checked options;
          334|         config = checked (removeAttrs config [ "_module" ]);
             |                  ^
          335|         _module = checked (config._module);

       (stack trace truncated; use '--show-trace' to show the full, detailed trace)

       error: attribute 'formats' missing
       at /nix/store/0vzw30bmdik5zd1mj6cr88z9773a5ra3-source/nixos/modules/services/hardware/bluetooth.nix:29:12:
           28|
           29|   cfgFmt = pkgs.formats.ini { };
             |            ^
           30|

malik-n avatar Jan 16 '25 11:01 malik-n

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/how-does-one-build-lxc-images-with-nixos-generators/58903/1

nixos-discourse avatar Jan 16 '25 14:01 nixos-discourse

This error comes from nixpkgs/nixos. Nothing we can fix in nixos-generators.

Mic92 avatar Jan 17 '25 12:01 Mic92

Also you can now generate this from nixos directly:

nixos-rebuild build-image --flake .#turingmachine --image-variant lxc

Mic92 avatar Jan 17 '25 12:01 Mic92

Also you can now generate this from nixos directly:

nixos-rebuild build-image --flake .#turingmachine --image-variant lxc

Sounds promising Do I need nixos-rebuild from the unstable branch because currently I am getting /run/current-system/sw/bin/nixos-rebuild: unknown option build-image'`

malik-n avatar Jan 23 '25 07:01 malik-n