I tried a lot of stdenv, ccWrap, and similar techniques, but none of them worked out well. Eventually, I found this post here, and I took some reference and wrote the following Nix configuration:

{ lib, ... }:
{
  nix.settings.system-features = lib.mkForce [
    "gccarch-x86-64-v3"
    "benchmark"
    "big-parallel"
    "kvm"
    "nixos-test"
  ];
  nixpkgs.hostPlatform.system = "x86_64-linux";
  nixpkgs.hostPlatform.gcc.arch = "x86-64-v3";
  nix.buildMachines = [{
    hostName = "localhost";
    systems = [ "x86_64-linux" ];
    supportedFeatures =
      [ "gccarch-x86-64-v3" "benchmark" "big-parallel" "kvm" "nixos-test" ];
    maxJobs = 20;
  }];
  nix.distributedBuilds = true;
}

But every time I run nixos-rebuild switch, the following error is observed, despite I specified the system as having gccarch-x86-64-v3.

error: a 'x86_64-linux' with features {gccarch-x86-64-v3} is required to build '/nix/store/82sfaiz7vijssydjh5rfjazxqv4gb23n-bootstrap-stage0-glibc-bootstrapFiles.drv', but I am a 'x86_64-linux' with features {benchmark, big-parallel, kvm, nixos-test}

So how can I potentially enable such feature on the local machine?

  • XiaoKeAi1OPB
    link
    fedilink
    English
    arrow-up
    1
    ·
    1 year ago

    You are so right! After that, my packages went to build, and I shall pray (finger-crossed-ing). But then a quick `ps -aux` shows that this actually does nothing, the command line is still `-mtune=generic -march=x86-64`