Surface Pro 4 nixos-hardware nixos-rebuild error

Firstly I apologize. I have read the documentation but am still a noob and I hope this isn’t a dumb issue.

I have been planning to make the jump to NixOS on my Surface Pro 4. Since my hardware is unusual I had been planning to use the nixos-hardware GitHub repository. I recently began my attempt at using the nixos-hardware channel and importing the surface common module in my configuration.nix as presented on the page. Despite my research I have managed to run into an error when I try to use nixos-rebuild and I am still running into trouble.

I searched around on various websites about potential causes of this issue but found none and racked my brain so either its not been encountered previously or I really dropped the ball. The only suspicion I have is that maybe I need to implement this pre-installation instead of post installation but honestly I am stumped.

Edit: Upgraded my kernel to latest version and that did no favors either. The same error occurred.

Any with this is greatly appreciated.

My attempt with nixos-rebuild:

[radocruz@nixos:~]$ sudo nixos-rebuild test
[sudo] password for radocruz: 
building Nix...
building the system configuration...
these 8 derivations will be built:
  /nix/store/gpsrz7zpm8vk4zyffja4lfbywd63iyp8-linux-config-6.0.17.drv
  /nix/store/287sgispsg2wl7w1bgaav4gf4hkjhly9-linux-6.0.17.drv
  /nix/store/c8v25ckni5qlims9aayjmw0ynwnhz05p-kernel-modules.drv
  /nix/store/pik6c4w9k55qb52w22fiyc8gns96zrdh-linux-6.0.17-modules.drv
  /nix/store/hkl8l22fs0znhb4qmhiy3gxmp4kda0gb-linux-6.0.17-modules-shrunk.drv
  /nix/store/i2kmcb2wip69x2r8qrq6qs6qzfnyrvjb-stage-1-init.sh.drv
  /nix/store/gj78a0251li427r9zjq5vr8gh214q17p-initrd-linux-6.0.17.drv
  /nix/store/rsp3l62g08n8gjrjrlrjr7w2hhk9g9j9-nixos-system-nixos-22.11.3567.0040164e473.drv
building '/nix/store/gpsrz7zpm8vk4zyffja4lfbywd63iyp8-linux-config-6.0.17.drv'...
unpacking sources
unpacking source archive /nix/store/3wws6yppyww6fxdl1sdnnchq9pr7apvn-linux-6.0.17.tar.xz
source root is linux-6.0.17
setting SOURCE_DATE_EPOCH to timestamp 1672827992 of file linux-6.0.17/virt/lib/irqbypass.c
patching sources
applying patch /nix/store/mibwk9p63p9pv0ps54s93ycyav20g1k2-source/patches/6.0/0001-surface3-oemb.patch
/nix/store/ifiygfv17dzpbssxwrld6a57iclzrb09-stdenv-linux/setup: line 1002: /nix/store/mibwk9p63p9pv0ps54s93ycyav20g1k2-source/patches/6.0/0001-surface3-oemb.patch: No such file or directory
error: builder for '/nix/store/gpsrz7zpm8vk4zyffja4lfbywd63iyp8-linux-config-6.0.17.drv' failed with exit code 1
error: 1 dependencies of derivation '/nix/store/287sgispsg2wl7w1bgaav4gf4hkjhly9-linux-6.0.17.drv' failed to build
error: 1 dependencies of derivation '/nix/store/c8v25ckni5qlims9aayjmw0ynwnhz05p-kernel-modules.drv' failed to build
error: 1 dependencies of derivation '/nix/store/pik6c4w9k55qb52w22fiyc8gns96zrdh-linux-6.0.17-modules.drv' failed to build
error: 1 dependencies of derivation '/nix/store/hkl8l22fs0znhb4qmhiy3gxmp4kda0gb-linux-6.0.17-modules-shrunk.drv' failed to build
error: 1 dependencies of derivation '/nix/store/i2kmcb2wip69x2r8qrq6qs6qzfnyrvjb-stage-1-init.sh.drv' failed to build
error: 1 dependencies of derivation '/nix/store/gj78a0251li427r9zjq5vr8gh214q17p-initrd-linux-6.0.17.drv' failed to build
error: 3 dependencies of derivation '/nix/store/rsp3l62g08n8gjrjrlrjr7w2hhk9g9j9-nixos-system-nixos-22.11.3567.0040164e473.drv' failed to build

My barebones configuration.nix:

# Edit this configuration file to define what should be installed on
# your system.  Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running ‘nixos-help’).

{ config, pkgs, ... }:

{
  imports =
    [ # Include the results of the hardware scan.


      <nixos-hardware/microsoft/surface/common>
      ./hardware-configuration.nix

     # "${builtins.fetchGit { url = "https://github.com/NixOS/nixos-hardware.git"; }}/microsoft/surface/common"
    ];

  # Bootloader.
  boot.loader.systemd-boot.enable = true;
  boot.loader.efi.canTouchEfiVariables = true;
  boot.loader.efi.efiSysMountPoint = "/boot/efi";

  networking.hostName = "nixos"; # Define your hostname.
  # networking.wireless.enable = true;  # Enables wireless support via wpa_supplicant.

  # Configure network proxy if necessary
  # networking.proxy.default = "http://user:password@proxy:port/";
  # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";

  # Enable networking
  networking.networkmanager.enable = true;

  # Set your time zone.
  time.timeZone = "America/Denver";

  # Select internationalisation properties.
  i18n.defaultLocale = "en_US.UTF-8";

  i18n.extraLocaleSettings = {
    LC_ADDRESS = "en_US.UTF-8";
    LC_IDENTIFICATION = "en_US.UTF-8";
    LC_MEASUREMENT = "en_US.UTF-8";
    LC_MONETARY = "en_US.UTF-8";
    LC_NAME = "en_US.UTF-8";
    LC_NUMERIC = "en_US.UTF-8";
    LC_PAPER = "en_US.UTF-8";
    LC_TELEPHONE = "en_US.UTF-8";
    LC_TIME = "en_US.UTF-8";
  };

  # Enable the X11 windowing system.
  services.xserver.enable = true;

  # Enable the GNOME Desktop Environment.
  services.xserver.displayManager.gdm.enable = true;
  services.xserver.desktopManager.gnome.enable = true;

  # Configure keymap in X11
  services.xserver = {
    layout = "us";
    xkbVariant = "";
  };

  # Enable CUPS to print documents.
  services.printing.enable = true;

  # Enable sound with pipewire.
  sound.enable = true;
  hardware.pulseaudio.enable = false;
  security.rtkit.enable = true;
  services.pipewire = {
    enable = true;
    alsa.enable = true;
    alsa.support32Bit = true;
    pulse.enable = true;
    # If you want to use JACK applications, uncomment this
    #jack.enable = true;

    # use the example session manager (no others are packaged yet so this is enabled by default,
    # no need to redefine it in your config for now)
    #media-session.enable = true;
  };

  # Enable touchpad support (enabled default in most desktopManager).
  # services.xserver.libinput.enable = true;

  # Define a user account. Don't forget to set a password with ‘passwd’.
  users.users.radocruz = {
    isNormalUser = true;
    description = "**** ****";
    extraGroups = [ "networkmanager" "wheel" ];
    packages = with pkgs; [
      firefox
      git
    #  thunderbird
    ];
  };

  # Allow unfree packages
  nixpkgs.config.allowUnfree = true;

  # List packages installed in system profile. To search, run:
  # $ nix search wget
  environment.systemPackages = with pkgs; [
  #  vim # Do not forget to add an editor to edit configuration.nix! The Nano editor is also installed by default.
  #  wget
  ];

  # Some programs need SUID wrappers, can be configured further or are
  # started in user sessions.
  # programs.mtr.enable = true;
  # programs.gnupg.agent = {
  #   enable = true;
  #   enableSSHSupport = true;
  # };

  # List services that you want to enable:

  # Enable the OpenSSH daemon.
  # services.openssh.enable = true;

  # Open ports in the firewall.
  # networking.firewall.allowedTCPPorts = [ ... ];
  # networking.firewall.allowedUDPPorts = [ ... ];
  # Or disable the firewall altogether.
  # networking.firewall.enable = false;

  # This value determines the NixOS release from which the default
  # settings for stateful data, like file locations and database versions
  # on your system were taken. It‘s perfectly fine and recommended to leave
  # this value at the release version of the first install of this system.
  # Before changing this value read the documentation for this option
  # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html).
  system.stateVersion = "22.11"; # Did you read the comment?

}

So this can’t work as is if I’m reading correctly.

nixos-hardware is using 6.0.17

And is using the patches from this commit

Which does not have patches for 6.0

Have you tried using 6.1.18?

Probably the 6.0 should be removed as upstream removed it and it is an EOL kernel version.

Thank you for this enlightening info.

In the time since the posting of this I had tinkered around with this but must have failed to properly implement it which led me to the incorrect conclusion was doing the wrong thing. I then had tried other avenues which were wrong but helped me learn the system considerably more.

I apologize since I am fairly new to the Nix language. I tried by using the overview of the nix language and the NixOS wiki page for the Linux kernel. I came to nix-hardware expecting it to be automated like the other surface kernel implementations but that is not what NixOS expects of me which is my bad.

Are there any resources or target concepts on the ‘Linux kernel’ or ‘Overview of the Nix Language’ page I should set my focus on so I can properly implement kernel 6.1.18 from the default.nix and patches.nix file?