Skip to content

Can't build on Ubuntu? #328

@a-h

Description

@a-h

The README.md has this example:

{
  inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";

  outputs = { nixpkgs, ... }: {
    nixosConfigurations.my-system = nixpkgs.lib.nixosSystem {
      modules = [
        "${nixpkgs}/nixos/maintainers/scripts/ec2/amazon-image.nix"
        {
          virtualisation.diskSize = "auto"; # or gigabytes. default is 3 * 1024
          nixpkgs.hostPlatform = "x86_64-linux";
          services.nginx.enable = true;
        }
      ];
    };
  };
}

So, I try it on my Ubuntu system, with Nix installed:

nix build .#nixosConfigurations.my-system.config.system.build.amazonImage

But I get a hash mismatch error:

warning: creating lock file '"/home/adrian-hesketh/github.com/NixOS/test/flake.lock"': 
• Added input 'nixpkgs':
    'github:NixOS/nixpkgs/2d293cbfa5a793b4c50d17c05ef9e385b90edf6c?narHash=sha256-pp3uT4hHijIC8JUK5MEqeAWmParJrgBVzHLNfJDZxg4%3D' (2025-11-30)
evaluation warning: system.stateVersion is not set, defaulting to 26.05. Read why this matters on https://nixos.org/manual/nixos/stable/options.html#opt-system.stateVersion.
warning: Ignoring setting 'auto-allocate-uids' because experimental feature 'auto-allocate-uids' is not enabled
warning: Ignoring setting 'impure-env' because experimental feature 'configurable-impure-env' is not enabled
error: builder for '/nix/store/8srzxbmfmzid7ywd90bvbyika0rnpaiz-nixos-image-amazon-26.05.20251130.2d293cb-x86_64-linux.drv' failed with exit code 1;
       last 25 log lines:
       > copying path '/nix/store/pq7kfn7csd5mraabqqd04r05lr1ys20p-nix.conf' to 'local'...
       > copying path '/nix/store/d8vgpa0xrzn7cs5b2cjps3l7j658l4kg-nixos-configuration-reference-manpage' to 'local'...
       > copying path '/nix/store/gqp0lmydjwxvzh4sz2wxav0bx4kvqmy1-X-Restart-Triggers-nix-daemon' to 'local'...
       > copying path '/nix/store/1fgly246vib7x8lcn75y7wvw3lv2n974-nix-2.31.2-man' to 'local'...
       > copying path '/nix/store/lbhpa2769ibbhq3skcjz17ww0j7r00ns-nixos-manual-html' to 'local'...
       > error: hash mismatch importing path '/nix/store/1fgly246vib7x8lcn75y7wvw3lv2n974-nix-2.31.2-man';
       >          specified: sha256:0av3yx7j9pifilcc8053q544b5zqahclqw6gpq9yz7cysirli66b
       >          got:       sha256:1j4jk200qg2wj4d7dws12zcsph0hd0wj69mh4dz9mr5wl3623b77
       > copying path '/nix/store/ncdy64g32scrjkqmbklsdp08aj9n7p4b-nixos.conf' to 'local'...
       > copying path '/nix/store/m65dckzfgr1lr90g5v6jx0iynnz38nsk-nss-cacert-3.115' to 'local'...
       > copying path '/nix/store/j3kvsaal1g5hk9afc3l1s23abm9mb23q-nss-cacert-3.115-p11kit' to 'local'...
       > copying path '/nix/store/17n5sx566xy7q5rqn1q2v8w1g2kpjajk-other.pam' to 'local'...
       > copying path '/nix/store/0g1mha3mrqspxvxgag3fij2w2jk4m35i-perl-5.40.0-man' to 'local'...
       > copying path '/nix/store/xgr0gawyyjv6jmk25022b1z53zxqhi4j-perl5.40.0-Digest-HMAC-1.05' to 'local'...
       > copying path '/nix/store/lhicc1840hbljj7mjly69xfjpf8a4ga5-perl5.40.0-Encode-Locale-1.05' to 'local'...
       > copying path '/nix/store/6p281mkvcl13fsxwvjrmnn0wldk0ksdc-perl5.40.0-FCGI-ProcManager-0.28' to 'local'...
       > copying path '/nix/store/m6q0acx8mz8gk33lqm0sgadbbqc6jb14-perl5.40.0-File-Copy-Recursive-0.45' to 'local'...
       > copying path '/nix/store/gbsvbq172qrcqrzd2j0rwapf3rrmlg0i-perl5.40.0-File-Slurp-9999.32' to 'local'...
       > copying path '/nix/store/gsz08hb519jijq84r36jagj1a6drirvw-system-shutdown' to 'local'...
       > copying path '/nix/store/xaa75rd44q62nc9mrbvym9d1m6gy0fj8-tzdata-2025b' to 'local'...
       > copying path '/nix/store/lak7173vnnyxxkf9bysyk99gndp1lr7n-udev-rules' to 'local'...
       > copying path '/nix/store/nl8601ic4drz80s2rpdg6w3msw6l2j6f-unit--.slice' to 'local'...
       > copying path '/nix/store/760s2vdy9zcgrhli53rmxklbxr9b1vfm-unit-dbus.socket' to 'local'...
       > copying path '/nix/store/mmby6dldf289kixpb6bnp5vkbw9rqyq1-unit-fs.target' to 'local'...
       > error: build of '/nix/store/c0w392bbhvccg48f5sghsdj2rq4p9w7w-nixos-system-unnamed-amazon-26.05.20251130.2d293cb' failed
       For full logs, run 'nix log /nix/store/8srzxbmfmzid7ywd90bvbyika0rnpaiz-nixos-image-amazon-26.05.20251130.2d293cb-x86_64-linux.drv'.

I can build a normal (non AWS AMI, e.g. QEMU) virtual machine image on Ubuntu without issue.

I can also build the AWS AMI virtual machine image from a NixOS machine.

Is it expected that AMI building only works on NixOS hosts? The problem seems to be somewhere in whatever "${nixpkgs}/nixos/maintainers/scripts/ec2/amazon-image.nix" does.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions