ctucx.git: nixfiles

ctucx' nixfiles

commit 6627b58ecca47d59b9a2b91b64d8c1bb821071a5
parent 4d112e8d58ac4c04d905797370f0b0a7fe45ea62
Author: Leah (ctucx) <leah@ctu.cx>
Date: Sun, 12 Jun 2022 10:36:09 +0200

configurations/homebrew: (un)link openjdk so macos can use it
1 file changed, 16 insertions(+), 0 deletions(-)
M
configurations/homebrew.nix
|
16
++++++++++++++++
diff --git a/configurations/homebrew.nix b/configurations/homebrew.nix
@@ -31,4 +31,20 @@
       "ICE Buddy" = 1595947689;
     };
   };
+
+  system.activationScripts.postActivation.text = ''
+    # Link the homebrew openjdk so that macos can use it
+    HOMEBREW_JAVAVM="/opt/homebrew/opt/openjdk/libexec/openjdk.jdk"
+    MACOS_JAVAVM="/Library/Java/JavaVirtualMachines/openjdk.jdk"
+    if [ -d "$HOMEBREW_JAVAVM" ]; then
+      if [ ! -e "MACOS_JAVAVM" ] ; then
+        ln -sfn $HOMEBREW_JAVAVM $MACOS_JAVAVM;
+      fi
+    else
+      if [ ! -e "$MACOS_JAVAVM" ] ; then
+        rm $MACOS_JAVAVM;
+      fi
+    fi
+  '';
+
 }