| 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 | |
| Jan Schär | b554dd3 | 2025-05-22 09:53:33 +0000 | [diff] [blame^] | 25 | # 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 Windelschmidt | 48f22ce | 2023-09-20 22:48:26 +0200 | [diff] [blame] | 33 | ${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 | ''; |
| 42 | in |
| Jan Schär | b554dd3 | 2025-05-22 09:53:33 +0000 | [diff] [blame^] | 43 | (pkgs.buildFHSEnv { |
| Tim Windelschmidt | 48f22ce | 2023-09-20 22:48:26 +0200 | [diff] [blame] | 44 | name = "monogon-nix"; |
| 45 | targetPkgs = pkgs: with pkgs; [ |
| 46 | git |
| 47 | buildifier |
| 48 | (stdenv.mkDerivation { |
| 49 | name = "bazel"; |
| 50 | src = builtins.fetchurl { |
| Tim Windelschmidt | 2979a43 | 2025-02-24 18:55:52 +0100 | [diff] [blame] | 51 | url = "https://github.com/bazelbuild/bazel/releases/download/8.1.0/bazel-8.1.0-linux-x86_64"; |
| 52 | sha256 = "19dwgh631d6c1m4ds1b1b3pbz18zm5i0x8bggjgsc04fyljfbfml"; |
| Tim Windelschmidt | 48f22ce | 2023-09-20 22:48:26 +0200 | [diff] [blame] | 53 | }; |
| 54 | unpackPhase = '' |
| 55 | true |
| 56 | ''; |
| Tim Windelschmidt | 1ac503c | 2024-03-07 16:15:35 +0100 | [diff] [blame] | 57 | nativeBuildInputs = [ makeWrapper ]; |
| Tim Windelschmidt | 48f22ce | 2023-09-20 22:48:26 +0200 | [diff] [blame] | 58 | buildPhase = '' |
| 59 | mkdir -p $out/bin |
| 60 | cp $src $out/bin/.bazel-inner |
| 61 | chmod +x $out/bin/.bazel-inner |
| 62 | |
| Tim Windelschmidt | 1ac503c | 2024-03-07 16:15:35 +0100 | [diff] [blame] | 63 | cp ${./bazel-inner.sh} $out/bin/bazel |
| Tim Windelschmidt | 48f22ce | 2023-09-20 22:48:26 +0200 | [diff] [blame] | 64 | chmod +x $out/bin/bazel |
| Tim Windelschmidt | 1ac503c | 2024-03-07 16:15:35 +0100 | [diff] [blame] | 65 | |
| 66 | # Use wrapProgram to set the actual bazel path |
| 67 | wrapProgram $out/bin/bazel --set BAZEL_REAL $out/bin/.bazel-inner |
| Tim Windelschmidt | 48f22ce | 2023-09-20 22:48:26 +0200 | [diff] [blame] | 68 | ''; |
| 69 | dontStrip = true; |
| 70 | }) |
| 71 | zlib |
| 72 | curl |
| 73 | gcc |
| 74 | binutils |
| Tim Windelschmidt | c834b7d | 2023-10-26 05:52:28 +0200 | [diff] [blame] | 75 | openjdk21 |
| Tim Windelschmidt | 48f22ce | 2023-09-20 22:48:26 +0200 | [diff] [blame] | 76 | patch |
| 77 | python3 |
| 78 | busybox |
| 79 | niv |
| 80 | google-cloud-sdk |
| Lorenz Brun | 3aa00d4 | 2023-11-20 23:08:41 +0100 | [diff] [blame] | 81 | qemu_kvm |
| 82 | swtpm |
| Tim Windelschmidt | 48f22ce | 2023-09-20 22:48:26 +0200 | [diff] [blame] | 83 | ]; |
| 84 | runScript = wrapper; |
| 85 | }) |