blob: 6c5bc5cd171936349c4d751076f9b0b4199712a9 (
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
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
|
{
lib,
stdenv,
stdenvNoCC,
runCommand,
rsync,
source,
bsdSetupHook,
openbsdSetupHook,
makeMinimal,
install,
}:
lib.makeOverridable (
attrs:
let
stdenv' = if attrs.noCC or false then stdenvNoCC else stdenv;
in
stdenv'.mkDerivation (
rec {
pname = "${attrs.pname or (baseNameOf attrs.path)}-openbsd";
version = "0";
src = runCommand "${pname}-filtered-src" { nativeBuildInputs = [ rsync ]; } ''
for p in ${lib.concatStringsSep " " ([ attrs.path ] ++ attrs.extraPaths or [ ])}; do
set -x
path="$out/$p"
mkdir -p "$(dirname "$path")"
src_path="${source}/$p"
if [[ -d "$src_path" ]]; then src_path+=/; fi
rsync --chmod="+w" -r "$src_path" "$path"
set +x
done
'';
extraPaths = [ ];
nativeBuildInputs = [
bsdSetupHook
openbsdSetupHook
makeMinimal
install
];
HOST_SH = stdenv'.shell;
# Since STRIP below is the flag
STRIPBIN = "${stdenv.cc.bintools.targetPrefix}strip";
makeFlags = [
"STRIP=-s" # flag to install, not command
"-B"
];
MACHINE_ARCH =
{
# amd64 not x86_64 for this on unlike NetBSD
x86_64 = "amd64";
aarch64 = "arm64";
i486 = "i386";
i586 = "i386";
i686 = "i386";
}
.${stdenv'.hostPlatform.parsed.cpu.name} or stdenv'.hostPlatform.parsed.cpu.name;
MACHINE = MACHINE_ARCH;
MACHINE_CPU = MACHINE_ARCH;
MACHINE_CPUARCH = MACHINE_ARCH;
COMPONENT_PATH = attrs.path or null;
strictDeps = true;
meta = with lib; {
maintainers = with maintainers; [ ericson2314 ];
platforms = platforms.openbsd;
license = licenses.bsd2;
};
}
// lib.optionalAttrs stdenv'.hasCC {
# TODO should CC wrapper set this?
CPP = "${stdenv'.cc.targetPrefix}cpp";
}
// lib.optionalAttrs (attrs.headersOnly or false) {
installPhase = "includesPhase";
dontBuild = true;
}
// attrs
)
)
|