Conversation

Jarkko Sakkinen

Edited 12 hours ago

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

#nixos #linux #kernel #rust #rustlang

0
1
0