blob: c48b589fc8c6d4f656f2cbe3549ffa5af534e5c4 [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
25 ${extraConf}
26
27 # Allow passing a custom command via env since nix-shell doesn't support
28 # this yet: https://github.com/NixOS/nix/issues/534
29 if [ ! -n "$COMMAND" ]; then
30 COMMAND="bash --noprofile --norc"
31 fi
32 exec $COMMAND
33 '';
34in
35(pkgs.buildFHSUserEnv {
36 name = "monogon-nix";
37 targetPkgs = pkgs: with pkgs; [
38 git
39 buildifier
40 (stdenv.mkDerivation {
41 name = "bazel";
42 src = builtins.fetchurl {
Tim Windelschmidt84f0b022025-01-08 01:59:22 +010043 url = "https://github.com/bazelbuild/bazel/releases/download/7.4.1/bazel-7.4.1-linux-x86_64";
44 sha256 = "0ar0qvxa3a7bms4baa84r1aq5yk53prc32k75063zrnw789h4zy9";
Tim Windelschmidt48f22ce2023-09-20 22:48:26 +020045 };
46 unpackPhase = ''
47 true
48 '';
Tim Windelschmidt1ac503c2024-03-07 16:15:35 +010049 nativeBuildInputs = [ makeWrapper ];
Tim Windelschmidt48f22ce2023-09-20 22:48:26 +020050 buildPhase = ''
51 mkdir -p $out/bin
52 cp $src $out/bin/.bazel-inner
53 chmod +x $out/bin/.bazel-inner
54
Tim Windelschmidt1ac503c2024-03-07 16:15:35 +010055 cp ${./bazel-inner.sh} $out/bin/bazel
Tim Windelschmidt48f22ce2023-09-20 22:48:26 +020056 chmod +x $out/bin/bazel
Tim Windelschmidt1ac503c2024-03-07 16:15:35 +010057
58 # Use wrapProgram to set the actual bazel path
59 wrapProgram $out/bin/bazel --set BAZEL_REAL $out/bin/.bazel-inner
Tim Windelschmidt48f22ce2023-09-20 22:48:26 +020060 '';
61 dontStrip = true;
62 })
63 zlib
64 curl
65 gcc
66 binutils
Tim Windelschmidtc834b7d2023-10-26 05:52:28 +020067 openjdk21
Tim Windelschmidt48f22ce2023-09-20 22:48:26 +020068 patch
69 python3
70 busybox
71 niv
72 google-cloud-sdk
Lorenz Brun3aa00d42023-11-20 23:08:41 +010073 qemu_kvm
74 swtpm
Tim Windelschmidt48f22ce2023-09-20 22:48:26 +020075 ];
76 runScript = wrapper;
77})