| Tim Windelschmidt | 48f22ce | 2023-09-20 22:48:26 +0200 | [diff] [blame] | 1 | { pkgs, extraConf ? "" }: with pkgs; |
| 2 | let |
| 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 | ''; |
| 34 | in |
| 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 Windelschmidt | 961a7cc | 2024-01-13 21:00:02 +0100 | [diff] [blame] | 43 | url = "https://github.com/bazelbuild/bazel/releases/download/7.0.0/bazel-7.0.0-linux-x86_64"; |
| 44 | sha256 = "0vnlpfwq1nnigscybwc7cxd9n14zrcsk7jzrrc66wwzr882zf94b"; |
| Tim Windelschmidt | 48f22ce | 2023-09-20 22:48:26 +0200 | [diff] [blame] | 45 | }; |
| 46 | unpackPhase = '' |
| 47 | true |
| 48 | ''; |
| Tim Windelschmidt | 1ac503c | 2024-03-07 16:15:35 +0100 | [diff] [blame] | 49 | nativeBuildInputs = [ makeWrapper ]; |
| Tim Windelschmidt | 48f22ce | 2023-09-20 22:48:26 +0200 | [diff] [blame] | 50 | buildPhase = '' |
| 51 | mkdir -p $out/bin |
| 52 | cp $src $out/bin/.bazel-inner |
| 53 | chmod +x $out/bin/.bazel-inner |
| 54 | |
| Tim Windelschmidt | 1ac503c | 2024-03-07 16:15:35 +0100 | [diff] [blame] | 55 | cp ${./bazel-inner.sh} $out/bin/bazel |
| Tim Windelschmidt | 48f22ce | 2023-09-20 22:48:26 +0200 | [diff] [blame] | 56 | chmod +x $out/bin/bazel |
| Tim Windelschmidt | 1ac503c | 2024-03-07 16:15:35 +0100 | [diff] [blame] | 57 | |
| 58 | # Use wrapProgram to set the actual bazel path |
| 59 | wrapProgram $out/bin/bazel --set BAZEL_REAL $out/bin/.bazel-inner |
| Tim Windelschmidt | 48f22ce | 2023-09-20 22:48:26 +0200 | [diff] [blame] | 60 | ''; |
| 61 | dontStrip = true; |
| 62 | }) |
| 63 | zlib |
| 64 | curl |
| 65 | gcc |
| 66 | binutils |
| Tim Windelschmidt | c834b7d | 2023-10-26 05:52:28 +0200 | [diff] [blame] | 67 | openjdk21 |
| Tim Windelschmidt | 48f22ce | 2023-09-20 22:48:26 +0200 | [diff] [blame] | 68 | patch |
| 69 | python3 |
| 70 | busybox |
| 71 | niv |
| 72 | google-cloud-sdk |
| Lorenz Brun | 3aa00d4 | 2023-11-20 23:08:41 +0100 | [diff] [blame] | 73 | qemu_kvm |
| 74 | swtpm |
| Tim Windelschmidt | 48f22ce | 2023-09-20 22:48:26 +0200 | [diff] [blame] | 75 | ]; |
| 76 | runScript = wrapper; |
| 77 | }) |