Conversation

Jarkko Sakkinen

Edited yesterday

This is how you build a test kernel with NixOS shenanigans:

podman pull nixos/nix   
podman run -it --rm -v "$(pwd):/kekkonen:Z" nixos/nix bash
cd kekkonen
nix-build '<nixpkgs/nixos>' -A config.system.build.qcow2 -I nixos-config=./configuration.nix

I’m planning to use this for Rust Linux instead of tweaking my BuildRoot environment at least at first.

Here’s an example on how to enable a custom kernel, albeit not yet with anything Rust. I just tested it with my in progress driver:

   boot.kernelPackages = let
    linux_tpmdd_pkg = { fetchgit, buildLinux, ... } @ args:

    buildLinux (args // rec {
      extraConfig = ''
        64BIT y
        ACPI y
        CRYPTO y
        IKHEADERS y
        LOCKDEP y
        MEMORY_FAILURE y
        MODULES n
        PROVE_LOCKING y
        RETPOLINE y
        TCG_TPM y
        TCG_TIS y
        TCG_CRB y
      '';
      ignoreConfigErrors = true;
      kernelPatches = [];
      src = pkgs.fetchgit {
        url = "https://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd.git";
        rev = "master";
        sha256 = lib.fakeSha256;
      };
      version = "5.10";
    } // (args.argsOverride or {}));
    linux_tpmdd = pkgs.callPackage linux_tpmdd_pkg{};
  in
    pkgs.recurseIntoAttrs (pkgs.linuxPackagesFor linux_tpmdd); 

EDIT: That did not play out so well but I then I looked at my old gists and recalled how this should be actually done: https://gist.github.com/jarkkojs/86bda141204e792122ef0c94b8b083b1. Has been three years since I bootstrapped a kernel tree in NixOS.

#linux #kernel #nix #nixos

1
2
6
That said for video-loop.ko I rely on BuildRoot as my QA for that driver is wired already :-) I'll refine this example to compile Rust-enabled Linux kernel later on. I just needed a random payload.
1
0
0
This does not compete really in my world with Fedora on my desktop nor BuildRoot for my basic kernel QA.

Where I would seriously consider NixOS would be situations where the other option would be Yocto, i.e. very productized embedded software. Yocto is quite complex and has a steep learning curve too...
1
0
0
Fun historical fact.

NixOS wiki uses my deprecated in-progress SGX driver as an example. Kudos to NixOS community for that :-) Just spotted this yesterday.

https://nixos.wiki/wiki/Linux_kernel
0
0
1