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

Stuck at random: crng init done

Open SpiderUnderUrBed opened this issue 4 months ago • 4 comments

[spiderunderurbed@daspidercave:~/nixnuc/nixmoxer]$ ./commands.sh 
[INFO] Building VM...
warning: Git tree '/home/spiderunderurbed/nixnuc/nixmoxer' is dirty
evaluation warning: system.stateVersion is not set, defaulting to 25.11. Read why this matters on https://nixos.org/manual/nixos/stable/options.html#opt-system.stateVersion.
[1/0/1 built, 0.0 MiB DL] building nixos-disk-image: [  200.051545] random: crng init done

Why for the last hour or so has it been stuck at "random: crng init done" this is a qcow2 image with nixos on it, using nixos-generators, I had previous issues with nixos-generators telling my disk size was too small for a closure, something along the lines, so i upscaled it significantly until it worked. However, now I think, this is a assumtion, that the "random: crng init done" is taking longer now, or it could be taking just as long as before, when it did work without the error, here is the flake, I think I am looking for a equivalent option to this: squashfsCompression = "zstd -Xcompression-level 10"; or maybe is this a bug for nixos-generators Flake:

{
  description = "My project using personal NUR repository";
  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    nixos-generators = {
      url = "github:nix-community/nixos-generators";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    netsecrets = {
      url = "github:SpiderUnderUrBed/net-secrets";
      inputs.nixpkgs.follows = "nixpkgs";  # Ensure consistent nixpkgs
    };
    proxmox-nixos.url = "github:SaumonNet/proxmox-nixos";
  };

  outputs = { self, netsecrets, proxmox-nixos, nixos-generators, nixpkgs, ... } @ inputs: 
  let
    system = "x86_64-linux";
    pkgs = nixpkgs.legacyPackages.${system};
  in {
    nixosConfigurations.myvm = nixpkgs.lib.nixosSystem {
      inherit system;
      modules = [ 
        proxmox-nixos.nixosModules.declarative-vms 
        ./node/configuration.nix 
      ];
    };

    packages.${system} = {
      vm = nixos-generators.nixosGenerate {
        inherit system pkgs;
        #diskSize = 200 * 1024;
        modules = [
          netsecrets.nixosModules.default
          {
            #virtualisation.memorySize = 12000;
            #virtualisation.diskSize = 60 * 1024 * 1024;
           virtualisation.diskSize = 100 * 1024;
            #formatConfigs.qcow.qemuOptions = [ "-device" "virtio-rng-pci" ];
            #virtualisation.qemu.options = [ "-device" "virtio-rng-pci" ];
            # Ensure the module can find its files
            nixpkgs.overlays = [ netsecrets.overlays.default ];
          }
          ./vm/configuration.nix
        ];
        format = "qcow";
        specialArgs = { inherit netsecrets; };
      };
    };
  };
}

EDIT: Originally i accidentally sent the disk size to too big, however it still takes ages on that one step.. any improvements that can be made or any way I can reduce it, like with a option or something, please mention it. (originally i multiplied (60 * 1024) with 1024, but with the fix and removing the second 1024 it still takes a long time, maybe my expectations are just wrong, for a 50+gb disk, but surely there is a way to optimize? for isos on nixos there is a option to improve this.

SpiderUnderUrBed avatar Aug 04 '25 10:08 SpiderUnderUrBed