about summary refs log tree commit diff
path: root/pkgs/os-specific/bsd/netbsd/pkgs/sys/base.nix
blob: 4c140fa3bdef7f0e9dad517ca30df36b01ea0c78 (plain) (blame)
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
{
  lib,
  mkDerivation,
  include,
  bsdSetupHook,
  netbsdSetupHook,
  makeMinimal,
  install,
  tsort,
  lorder,
  statHook,
  rsync,
  uudecode,
  config,
  genassym,
  defaultMakeFlags,
  common,
}:
{
  path = "sys";
  version = "9.2";
  sha256 = "03s18q8d9giipf05bx199fajc2qwikji0djz7hw63d2lya6bfnpj";

  # Make the build ignore linker warnings
  prePatch = ''
    substituteInPlace sys/conf/Makefile.kern.inc \
      --replace "-Wa,--fatal-warnings" ""
  '';

  patches = [
    # Fix this error when building bootia32.efi and bootx64.efi:
    # error: PHDR segment not covered by LOAD segment
    ./no-dynamic-linker.patch

    # multiple header dirs, see above
    ./sys-headers-incsdir.patch
  ];

  postPatch =
    ''
      substituteInPlace sys/arch/i386/stand/efiboot/Makefile.efiboot \
        --replace "-nocombreloc" "-z nocombreloc"
    ''
    +
      # multiple header dirs, see above
      include.postPatch;

  CONFIG = "GENERIC";

  propagatedBuildInputs = [ include ];
  nativeBuildInputs = [
    bsdSetupHook
    netbsdSetupHook
    makeMinimal
    install
    tsort
    lorder
    statHook
    rsync
    uudecode
    config
    genassym
  ];

  postConfigure =
    ''
      pushd arch/$MACHINE/conf
      config $CONFIG
      popd
    ''
    # multiple header dirs, see above
    + include.postConfigure;

  makeFlags = defaultMakeFlags ++ [ "FIRMWAREDIR=$(out)/libdata/firmware" ];
  hardeningDisable = [ "pic" ];
  MKKMOD = "no";
  env.NIX_CFLAGS_COMPILE = toString [
    "-Wno-error=array-parameter"
    "-Wno-error=array-bounds"
    "-Wa,--no-warn"
  ];

  postBuild = ''
    make -C arch/$MACHINE/compile/$CONFIG $makeFlags
  '';

  postInstall = ''
    cp arch/$MACHINE/compile/$CONFIG/netbsd $out
  '';

  meta.platforms = lib.platforms.netbsd;
  extraPaths = [ common ];
}