feat(darwin): more provisioned apps

This commit is contained in:
alina 🌸 2024-05-01 07:43:04 +03:00
parent 80fc71d327
commit 6d4c7a62a7
Signed by: teidesu
SSH key fingerprint: SHA256:uNeCpw6aTSU4aIObXLvHfLkDa82HWH9EiOj9AXOIRpI
5 changed files with 81 additions and 6 deletions

View file

@ -14,6 +14,11 @@
alacritty alacritty
raycast raycast
karabiner karabiner
wireguard
brave
forkgram
snipaste
nekoray
])) ]))
(import (abs "users/teidesu/darwin.nix") {}) (import (abs "users/teidesu/darwin.nix") {})
]; ];

View file

@ -14,13 +14,13 @@ rec {
withMountedDmg = path: shell: '' withMountedDmg = path: shell: ''
_result=$(hdiutil mount ${path} | tail -n1) _result=$(hdiutil mount ${path} | tail -n1)
DMG_DEVICE=$(echo "$_result" | awk '{print $1}') DMG_DEVICE=$(echo "$_result" | awk '{print $1}')
DMG_MOUNTPOINT=$(echo "$_result" | awk '{print $3}') DMG_MOUNTPOINT=$(echo "$_result" | perl -lane 'print "@F[2..$#F]"')
unset _result unset _result
function _unmount { function _unmount {
hdiutil unmount $DMG_DEVICE > /dev/null hdiutil unmount $DMG_DEVICE > /dev/null
} }
trap _unmount ERR exit # trap _unmount ERR exit
${shell} ${shell}
@ -65,4 +65,36 @@ rec {
rm -rf $DOWNLOADED_FILE rm -rf $DOWNLOADED_FILE
fi fi
''; '';
downloadAndInstallZipApp = {
url,
filename,
params ? "",
renameTo ? null,
afterInstall ? ""
}: let
conditionFile = if renameTo == null then filename else renameTo;
in ''
if [ ! -d "/Applications/"${lib.escapeShellArg (builtins.baseNameOf conditionFile)} ]; then
${download { inherit url params; }}
tmpdir=$(mktemp -d)
unzip -q $DOWNLOADED_FILE -d $tmpdir
if [ ! -d "$tmpdir/"${lib.escapeShellArg filename} ]; then
echo "Error: file not found:" ${lib.escapeShellArg filename}
rm -rf $DOWNLOADED_FILE $tmpdir
exit 1
fi
${if (renameTo != null) then ''
mv "$tmpdir/"${lib.escapeShellArg filename} "$tmpdir/"${lib.escapeShellArg renameTo}
mv "$tmpdir/"${lib.escapeShellArg renameTo} /Applications
'' else ''
mv "$tmpdir/"${lib.escapeShellArg filename} /Applications
''}
rm -rf $DOWNLOADED_FILE $tmpdir
${afterInstall}
fi
'';
} }

View file

@ -9,7 +9,9 @@
# i'll just handle dmg's myself :D # i'll just handle dmg's myself :D
let let
repo = pkgs.callPackage ./productivity.nix {}; repo =
(pkgs.callPackage ./productivity.nix {})
// (pkgs.callPackage ./system.nix {});
in appsFactory: { in appsFactory: {
system.activationScripts.postUserActivation.text = '' system.activationScripts.postUserActivation.text = ''
set -eau set -eau

View file

@ -8,14 +8,25 @@ in with common; {
filename = "Raycast.app"; filename = "Raycast.app";
}; };
brave = downloadAndInstallDmgApp {
url = "https://referrals.brave.com/latest/BRV010/Brave-Browser.dmg";
filename = "Brave Browser.app";
};
snipaste = downloadAndInstallDmgApp {
url = "https://dl.snipaste.com/mac-beta";
filename = "Snipaste.app";
};
karabiner = downloadAndInstallDmgPkg { karabiner = downloadAndInstallDmgPkg {
url = "https://github.com/pqrs-org/Karabiner-Elements/releases/download/v14.13.0/Karabiner-Elements-14.13.0.dmg"; url = "https://github.com/pqrs-org/Karabiner-Elements/releases/download/v14.13.0/Karabiner-Elements-14.13.0.dmg";
filename = "Karabiner-Elements.pkg"; filename = "Karabiner-Elements.pkg";
condition = "! -d /Applications/Karabiner-Elements.app"; condition = "! -d /Applications/Karabiner-Elements.app";
}; };
alacritty = downloadAndInstallDmgApp { forkgram = downloadAndInstallZipApp {
url = "https://github.com/alacritty/alacritty/releases/download/v0.13.2/Alacritty-v0.13.2.dmg"; url = "https://github.com/forkgram/tdesktop/releases/download/v4.16.10/Forkgram.macOS.no.auto-update_arm64.zip";
filename = "Alacritty.app"; filename = "Telegram.app";
renameTo = "Forkgram.app";
}; };
} }

View file

@ -0,0 +1,25 @@
{ callPackage }:
let
common = callPackage ./common.nix {};
in with common; {
wireguard = downloadAndInstallZipApp {
url = "https://s3.tei.su/wireguard-mac-1.0.16.zip";
filename = "WireGuard.app";
};
nekoray = downloadAndInstallZipApp {
url = "https://github.com/abbasnaqdi/nekoray-macos/releases/download/3.26/nekoray_arm64.zip";
filename = "nekoray_arm64.app";
renameTo = "nekoray.app";
# https://github.com/abbasnaqdi/nekoray-macos/issues/64
afterInstall = ''
plutil -insert LSUIElement -bool YES /Applications/nekoray.app/Contents/Info.plist
'';
};
alacritty = downloadAndInstallDmgApp {
url = "https://github.com/alacritty/alacritty/releases/download/v0.13.2/Alacritty-v0.13.2.dmg";
filename = "Alacritty.app";
};
}