Skip to content
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

error: attribute 'formats' missing #423

Open
malik-n opened this issue Jan 16, 2025 · 4 comments
Open

error: attribute 'formats' missing #423

malik-n opened this issue Jan 16, 2025 · 4 comments

Comments

@malik-n
Copy link

malik-n commented Jan 16, 2025

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|
@nixos-discourse
Copy link

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

@Mic92
Copy link
Member

Mic92 commented Jan 17, 2025

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

@Mic92
Copy link
Member

Mic92 commented Jan 17, 2025

Also you can now generate this from nixos directly:

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

@malik-n
Copy link
Author

malik-n commented Jan 23, 2025

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'`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants