Finally sorted out how to have changing Git tip and keeping it “pure” in NixOS build. Here’s flake.nix:
{
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
outputs = { self, nixpkgs }: let
tpmddSrc = if builtins.pathExists ./linux-tpmdd.json then
builtins.removeAttrs (builtins.fromJSON (builtins.readFile ./linux-tpmdd.json)) [ "hash" "path" "date" ]
else {};
in {
nixosConfigurations = {
tpmdd = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
({ config, lib, pkgs, modulesPath, ... }:
import ./configuration.nix {
inherit config lib pkgs modulesPath tpmddSrc;
}
)
];
};
};
};
}
After this I can refer to the Git tip with tpmddSrc in configuration.nix, or any other module.
The JSON itself is generated in Dockerfile, pod or Dockerfile as:
nix-prefetch-git --url https://git.kernel.org/pub/scm/linux/kernel/git/jarkko/linux-tpmdd.git > linux-tpmdd.json
Two days went figuring this out. I switched from Podman to Packer but in the end of the day I could have just well used Podman now that I figured out how to pass the data (I had some terrible moments with builtins.readFile and builtins.getEnv with no luck).
Oh well, I use Packer for now and add a Dockerfile in some point in future.
As said, this effort was done for the sake engineering some kind edit-compile-run cycle for Rust enabled Linux kernel (even tho my configuration.nix at this point has none of that but it is now downhill ;-) knock knock
The EU stands in partnership with Moldova and the Moldovan people.
And we want to bring the country closer to our Union as fast as possible.
We welcome the political agreement between the European Parliament and the Council of the European Union on the Reform and Growth Facility for Moldova.
The agreed €1.9 billion Facility – the largest EU financial support package since Moldova's independence – is a key step in our partnership.
For a shared Europe of freedom, prosperity and stability.
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.