blob: 320e3df359af12f897f17cde7c5df6e76d0160c8 [file] [log] [blame]
Tim Windelschmidt48f22ce2023-09-20 22:48:26 +02001{ pkgs, extraConf ? "" }: with pkgs;
2let
3 wrapper = pkgs.writeScript "wrapper.sh"
4 ''
5 # Fancy colorful PS1 to make people notice easily they're in the Monogon Nix shell.
6 PS1='\[\033]0;\u/monogon:\w\007\]'
7 if type -P dircolors >/dev/null ; then
8 PS1+='\[\033[01;35m\]\u/monogon\[\033[01;36m\] \w \$\[\033[00m\] '
9 fi
10 export PS1
11
12 # Use Nix-provided cert store.
13 export NIX_SSL_CERT_FILE="${cacert}/etc/ssl/certs/ca-bundle.crt"
14 export SSL_CERT_FILE="${cacert}/etc/ssl/certs/ca-bundle.crt"
15
16 # Let some downstream machinery know we're on NixOS. This is used mostly to
17 # work around Bazel/NixOS interactions.
18 export MONOGON_NIXOS=yep
19
20 # Convince rules_go to use /bin/bash and not a NixOS store bash which has
21 # no idea how to resolve other things in the nix store once PATH is
22 # stripped by (host_)action_env.
23 export BAZEL_SH=/bin/bash
24
Jan Schärb554dd32025-05-22 09:53:33 +000025 # buildFHSEnv makes /etc a tmpfs and symlinks some files from host /etc.
26 # Create some additional symlinks for files we want from host /etc.
27 for i in bazel.bazelrc gitconfig; do
28 if [[ -e "/.host-etc/$i" ]] && [[ ! -e "/etc/$i" ]]; then
29 ln -s "/.host-etc/$i" "/etc/$i"
30 fi
31 done
32
Tim Windelschmidt48f22ce2023-09-20 22:48:26 +020033 ${extraConf}
34
35 # Allow passing a custom command via env since nix-shell doesn't support
36 # this yet: https://github.com/NixOS/nix/issues/534
37 if [ ! -n "$COMMAND" ]; then
38 COMMAND="bash --noprofile --norc"
39 fi
40 exec $COMMAND
41 '';
42in
Jan Schärb554dd32025-05-22 09:53:33 +000043(pkgs.buildFHSEnv {
Tim Windelschmidt48f22ce2023-09-20 22:48:26 +020044 name = "monogon-nix";
45 targetPkgs = pkgs: with pkgs; [
46 git
47 buildifier
48 (stdenv.mkDerivation {
49 name = "bazel";
50 src = builtins.fetchurl {
Tim Windelschmidt2979a432025-02-24 18:55:52 +010051 url = "https://github.com/bazelbuild/bazel/releases/download/8.1.0/bazel-8.1.0-linux-x86_64";
52 sha256 = "19dwgh631d6c1m4ds1b1b3pbz18zm5i0x8bggjgsc04fyljfbfml";
Tim Windelschmidt48f22ce2023-09-20 22:48:26 +020053 };
54 unpackPhase = ''
55 true
56 '';
Tim Windelschmidt1ac503c2024-03-07 16:15:35 +010057 nativeBuildInputs = [ makeWrapper ];
Tim Windelschmidt48f22ce2023-09-20 22:48:26 +020058 buildPhase = ''
59 mkdir -p $out/bin
60 cp $src $out/bin/.bazel-inner
61 chmod +x $out/bin/.bazel-inner
62
Tim Windelschmidt1ac503c2024-03-07 16:15:35 +010063 cp ${./bazel-inner.sh} $out/bin/bazel
Tim Windelschmidt48f22ce2023-09-20 22:48:26 +020064 chmod +x $out/bin/bazel
Tim Windelschmidt1ac503c2024-03-07 16:15:35 +010065
66 # Use wrapProgram to set the actual bazel path
67 wrapProgram $out/bin/bazel --set BAZEL_REAL $out/bin/.bazel-inner
Tim Windelschmidt48f22ce2023-09-20 22:48:26 +020068 '';
69 dontStrip = true;
70 })
71 zlib
72 curl
73 gcc
74 binutils
Tim Windelschmidtc834b7d2023-10-26 05:52:28 +020075 openjdk21
Tim Windelschmidt48f22ce2023-09-20 22:48:26 +020076 patch
77 python3
78 busybox
79 niv
80 google-cloud-sdk
Lorenz Brun3aa00d42023-11-20 23:08:41 +010081 qemu_kvm
82 swtpm
Tim Windelschmidt48f22ce2023-09-20 22:48:26 +020083 ];
84 runScript = wrapper;
85})