summaryrefslogtreecommitdiffstats
path: root/nixos/tests/kernel-rust.nix
blob: 0b8ea5505ecd5816bd291b6880d4f131a704a0df (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
{
  system ? builtins.currentSystem,
  config ? { },
  pkgs ? import ../.. { inherit system config; },
}:

let
  inherit (pkgs.lib)
    const
    filterAttrs
    mapAttrs
    meta
    ;

  kernelRustTest =
    kernelPackages:
    import ./make-test-python.nix (
      { lib, ... }:
      {
        name = "kernel-rust";
        meta.maintainers = with lib.maintainers; [
          blitz
          ma27
        ];
        nodes.machine =
          { config, ... }:
          {
            boot = {
              inherit kernelPackages;
              extraModulePackages = [ config.boot.kernelPackages.rust-out-of-tree-module ];
              kernelPatches = [
                {
                  name = "Rust Support";
                  patch = null;
                  features = {
                    rust = true;
                  };
                }
              ];
            };
          };
        testScript = ''
          machine.wait_for_unit("default.target")
          machine.succeed("modprobe rust_out_of_tree")
        '';
      }
    );

  kernels = {
    inherit (pkgs.linuxKernel.packages) linux_testing;
  }
  // filterAttrs (const (
    x:
    let
      inherit (builtins.tryEval (x.rust-out-of-tree-module or null != null))
        success
        value
        ;
      available = meta.availableOn pkgs.stdenv.hostPlatform x.rust-out-of-tree-module;
    in
    success && value && available
  )) pkgs.linuxKernel.vanillaPackages;
in
mapAttrs (const kernelRustTest) kernels