System76 Flakes

I wouldn’t have felt comfortable getting a Darter Pro 6 from System76 without the work @stites and @khumba put into driver/module support. Thank you both so much!!

I’ve started a few repos of my own to start converting my system to flakes now that Nix Flakes, Part 3 is out and clarifies a few things.

I will warn: my understanding is a bit patchwork since I learn this on my off-time and I don’t really have a clear learning path. :sweat_smile:

So far I’ve gotten to the point of nixos-rebuild switch --flake ./my-system#hostname, but I get the following error:

building the system configuration...
error: --- ThrownError -------------------

Failed assertions:
- The 'fileSystems' option does not specify your root filesystem.
- You must set the option 'boot.loader.grub.devices' or 'boot.loader.grub.mirroredBoots' to make the system bootable.

Here are the flakes mirroring the work from @stites and @khumba (I only built out acpi-dkms and io-dkms as those were the only 2 modules loaded in a darp6 config):

I have another private repo for my actual system configuration. Here are the relevant parts of what I believe should be my computer’s flake.nix:

{
  description = "NixOS config for my laptop";

  inputs.nixpkgs.url = github:NixOS/nixpkgs/b3251e04ee470c20f81e75d5a6080ba92dc7ed3f;
  inputs.darp6.url = github:mwilsoncoding/darp6/eef2c114e8c78adb574e8637b1db480c05724fac;

  outputs = { self, nixpkgs, darp6 }: {

    nixosConfigurations.nixtop =
      darp6.nixosConfigurations.darp6 // {
        modules =
          darp6.nixosConfigurations.darp6.modules ++
          ({pkgs, lib, ...}: {
            system.configurationRevision = nixpkgs.lib.mkIf (self ? rev) self.rev;

          # I tried importing the section below from the original hardware-configuration.nix, but got the same result

          #############################
          ## HARDWARE-CONFIGURATION.NIX
            boot.initrd.availableKernelModules = [ "xhci_pci" "ahci" "nvme" "usb_storage" "sd_mod" "rtsx_pci_sdmmc" ];
            boot.initrd.kernelModules = [ ];
            boot.kernelModules = [ "kvm-intel" ];
            boot.extraModulePackages = [ ];

            fileSystems."/" =
              { device = "/dev/disk/by-uuid/blablablablabla";
                fsType = "ext4";
              };

            fileSystems."/boot" =
              { device = "/dev/disk/by-uuid/blablabla";
                fsType = "vfat";
              };

            swapDevices =
              [ { device = "/dev/disk/by-uuid/blablablablabla"; }
              ];

            nix.maxJobs = lib.mkDefault 8;
            powerManagement.cpuFreqGovernor = lib.mkDefault "powersave";
          ## HARDWARE-CONFIGURATION.NIX
          #############################

            boot.kernelPackages = pkgs.linuxPackages_latest;
            boot.loader.systemd-boot.enable = true;
            boot.loader.efi.canTouchEfiVariables = true;

            nix = {
              package = pkgs.nixFlakes;
              extraOptions = ''
                experimental-features = nix-command flakes
              '';
            };

           # fonts, networking, xmonad, kbfs, printing, yubikey, user, etc
          
      });
    };
  };
}

Any ideas on how to fix?

4 Likes

As an update, I have it mostly working, but I think I’m coming across some kernel inconsistencies that I hope others have conquered before.

Check out the consolidate branch of the darp6 repo to see that I changed it around to just centralize the modules I would need.

In the host system flake, I ended up changing the following:

nixosConfigurations.nixtop = nixpkgs.lib.nixosSystem {
  modules = [
    nixpkgs.nixosModules.notDetected
    darp6.nixosModules.system76-io-dkms
    darp6.nixosModules.system76-acpi-dkms
    ({pkgs, lib, ...}: { ... })
  ];
};

Now on build, I get the following error:

building the system configuration...
error: --- Error -------------------
builder for '/nix/store/blabla-kernel-modules.drv' failed with exit code 1; last 3 log lines:
  created 9 symlinks in user environment
  inconsistent kernel versions: 5.4.55
  5.7.6
error: --- Error -------------------
1 dependencies of derivation '/nix/store/blabla-nixos-system-nixtop-version.drv' failed to build

I’m fairly sure it’s because in the current iteration the system76 modules reference nixpkgs.linuxPackages rather than whatever kernel is specified in my nixtop flake.

I guess this is more a question of: how do I get the system76 modules to reference whatever kernel I choose in my system flake rather than a static kernel?

1 Like

Can confirm that if I set all flakes to the same commit of nixpkgs and consistently use linuxPackages_latest, I actually now have a NixOS system running off a flake. =]

I’m now merging the consolidate branch of the darp6 repo, but anyone curious can look at the git history (apologies in advance for all of the updating flakes commits).

The sad news is that this is very static.

My question still stands:
Is there a way to specify a kernel in the nixosConfiguration flake and have the dkms package flakes reference that same kernel?

1 Like

I think I got it?

Here’s the darp6 repo.

I ended up including the kernel specification at the module level alongside the ones that provide the system76 packages and configuration.

That let me remove the boot.kernelPackages line from my nixtop expression and replace it with the module in the list instead.

It also freed me up to use a more up-to-date nixpkgs for my system packages than the one that was used to build the kernel choice module.

LMKWYT!!