How to rename or add a symlink to a file in the nix store?

It seems the brilliant minds at Google forgot to rename two files before shipping the Android SDK to the public.

The accepted solution to that stackoverflow post is to manually rename the offending files. Unfortunately my android sdk directory is in the nix store, which is read only.

What I’d need to do is (in pseudo nix-bash syntax)

ln -s \
  ${android-sdk}/share/android-sdk/build-tools/32.0.0/d8 \
  ${android-sdk}/share/android-sdk/build-tools/32.0.0/dx

ln -s \
  ${android-sdk}/share/android-sdk/build-tools/32.0.0/lib/d8.jar \
  ${android-sdk}/share/android-sdk/build-tools/32.0.0/lib/dx.jar

where android-sdk is the package containing my android environment. Can I add an overlay or something else to make this work?

1 Like

Not sure how dirty this is, but it seems to work:

❯ cat shell.nix
{ pkgs ? import <nixpkgs> { } }:

pkgs.mkShell {
  buildInputs = [
    (pkgs.hello.overrideAttrs (old: rec {
      installPhase = ''
        installPhase
        ln -s $out/bin/hello $out/bin/hello2
      '';
    }))
  ];
}
❯ nix-shell
[...]
❯ ls -la /nix/store/lian2qdqqwhica07ardl4zqds6ji2q6a-hello-2.10/bin/
total 22
dr-xr-xr-x 2 root root     4 Jan  1  1970 .
dr-xr-xr-x 4 root root     4 Jan  1  1970 ..
-r-xr-xr-x 1 root root 37944 Jan  1  1970 hello
lrwxrwxrwx 1 root root     5 Jan  1  1970 hello2 -> hello
❯
3 Likes