summaryrefslogtreecommitdiff
path: root/boards/default.nix
blob: de0eb34f944a793a676fc9fddcc331687d48469a (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
{
  arches,
  libkernel,
  nixpkgs,
  pkgs,
  python,
  system,
}:

let
  mkKernel =
    path:
    let
      args = import path;
      arch = arches.${args.vernos-arch};
      libkernel-arch = libkernel.${args.vernos-arch};
      pkgs-arch = import nixpkgs {
        inherit system;
        crossSystem.config = arch.crossSystem;
      };
    in

    pkgs-arch.stdenvNoCC.mkDerivation (
      {
        pname = "vernos-kernel-${args.vernos-board}";
        version = libkernel-arch.version;

        nativeBuildInputs = [
          pkgs.ninja
          pkgs-arch.stdenv.cc.bintools.bintools
          python
        ];

        dontUnpack = true;
        configurePhase = ''
          runHook preConfigure
          python3 ${./configure.py} ${args.vernos-arch} ${args.vernos-board} \
            ${libkernel-arch} $src
          runHook postConfigure
        '';
        installPhase = ''
          runHook preInstall
          install -m0755 -Dt $out vernos_kernel.elf
          install -m0644 -Dt $out vernos_kernel.sym
          runHook postInstall
        '';
        dontFixup = true;

        AS = "${arch.crossSystem}-as";
        LD = "${arch.crossSystem}-ld";
        STRIP = "${arch.crossSystem}-strip";
      }
      // args
    );

in

nixpkgs.lib.recurseIntoAttrs { qemu-virt = mkKernel ./qemu-virt; }