-
Notifications
You must be signed in to change notification settings - Fork 27
/
default.nix
126 lines (114 loc) · 2.99 KB
/
default.nix
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
{ pkgs ? import <nixpkgs> {} }:
let
ncurses5 = pkgs.ncurses.override { abiVersion = "5"; };
fhs = pkgs.buildFHSUserEnv {
name = "piksi-env";
targetPkgs = pkgs: with pkgs; [
awscli
bash
binutils
bc
bison
bzip2
cacert
ccache
clang
clang-tools
cmake
coreutils
cpio
curl
db
file
flex
gcc
git
glibc
glibc.dev
gnugrep
gnum4
gnumake
gnused
gnutar
gdb
libcxx
mercurial
ncurses5
ncurses5.dev
nettools
openssl
openssl.dev
patch
patchelf
perl
proot
python3
python27Full
readline
readline.dev
rsync
sqlite
sqlite.dev
unzip
utillinux
vim
wget
which
valgrind
xz
zlib
];
multiPkgs = pkgs: with pkgs; [ ];
runScript = "$SHELL";
# We need to disable the gcc hardening that's enabled by default in the gcc
# wrapper for NixOS, otherwise it'll cause packages to fail to compile in the
# nix-shell environment.
#
# References:
# - https://szibele.com/developing-software-on-nixos/
# - https://github.com/NixOS/nixpkgs/issues/18995
#
# So we add hardeningDisable=all to the shell environment or we add it as an
# argument to the mkDerivation call (however, since buildFHSUserEnv doesn't
# understand this argument, it's added to the bash environement).
profile = ''
if [[ -z "$VARIANT" ]]; then export VARIANT=internal; fi
# buildFHSUserEnv seems to export NIX_CFLAGS_COMPILE and NIX_LDFLAGS_BEFORE
# but the cc-wrapper wants a var that includes a marker for the build
# triplet that it's wrapping:
#
export NIX_x86_64_unknown_linux_gnu_CFLAGS_COMPILE=$NIX_CFLAGS_COMPILE
export NIX_x86_64_unknown_linux_gnu_LDFLAGS_BEFORE=$NIX_LDFLAGS_BEFORE
# Make sure buildroot Python loads dynamic modules from the right place
export PATH=$PWD/scripts/wrappers/bin:$PWD/buildroot/$VARIANT/host_output/host/bin:$PWD/buildroot/output/$VARIANT/host/bin:$PATH
export LD_LIBRARY_PATH=$PWD/buildroot/output/$VARIANT/host/usr/lib:/lib:/usr/lib
export LD_LIBRARY_PATH=$PWD/buildroot/$VARIANT/host_output/host/usr/lib:$LD_LIBRARY_PATH
# See note about hardeningDisable above
export hardeningDisable=all
# This is intended to be picked up by PS1 to mark that this is a subshell
export debian_chroot='piksi-nix'
# Workaround issus with SSL cert store not being propegrated for some
# reason, per:
#
# - https://github.com/NixOS/nixpkgs/issues/8534
# - https://github.com/NixOS/nixpkgs/issues/3382
#
export GIT_SSL_CAINFO=/etc/ssl/certs/ca-certificates.crt
export CURL_CA_BUNDLE=/etc/ssl/certs/ca-certificates.crt
export SSL_CERT_FILE=/etc/ssl/certs/ca-certificates.crt
export IN_PIKSI_SHELL=1
'';
extraBuildCommands = ''
'';
};
in pkgs.stdenv.mkDerivation rec {
name = "piksi-buildroot-env";
nativeBuildInputs = [ fhs ];
shellHook = ''
if [ -z "$PS1" ]; then
:
else
exec piksi-env
fi
'';
}