Skip to content

Commit

Permalink
chatgpt: init at 1.2025.014
Browse files Browse the repository at this point in the history
  • Loading branch information
wattmto committed Jan 27, 2025
1 parent 309e8a5 commit b8452f1
Show file tree
Hide file tree
Showing 3 changed files with 75 additions and 0 deletions.
47 changes: 47 additions & 0 deletions pkgs/by-name/ch/chatgpt/package.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
lib,
stdenvNoCC,
darwin,
fetchurl,
_7zz,
undmg,
}:

let
source = import ./source.nix;
in
stdenvNoCC.mkDerivation {
pname = "chatgpt";
version = source.version;

src = fetchurl source.src;

nativeBuildInputs = [
undmg
];

sourceRoot = ".";

installPhase = ''
runHook preInstall
mkdir -p "$out/Applications"
mkdir -p "$out/bin"
cp -a ChatGPT.app "$out/Applications"
ln -s "$out/Applications/ChatGPT.app/Contents/MacOS/ChatGPT" "$out/bin/ChatGPT"
runHook postInstall
'';

passthru.updateScript = ./update.sh;

meta = {
description = "Desktop application for ChatGPT";
homepage = "https://openai.com/chatgpt/desktop/";
license = lib.licenses.unfree;
maintainers = with lib.maintainers; [ wattmto ];
platforms = lib.platforms.darwin;
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
mainProgram = "ChatGPT";
};
}
7 changes: 7 additions & 0 deletions pkgs/by-name/ch/chatgpt/source.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
version = "1.2025.014";
src = fetchurl {
url = "https://persistent.oaistatic.com/sidekick/public/ChatGPT_Desktop_public_1.2025.014_1737150122.dmg";
sha256 = "sha256-NxCkrsPaptYNTZ+urkJqYeC4a0nGaEOFO/7SQL1Jmpc=";
};
}
21 changes: 21 additions & 0 deletions pkgs/by-name/ch/chatgpt/update.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p curl libxml2

XML_URL="https://persistent.oaistatic.com/sidekick/public/sparkle_public_appcast.xml"

XML_DATA=$(curl -s $XML_URL)

LATEST_VERSION=$(echo "$XML_DATA" | xmllint --xpath '/rss/channel/item[1]/*[local-name()="shortVersionString"]/text()' -)
DOWNLOAD_URL=$(echo "$XML_DATA" | xmllint --xpath 'string(//item[1]/enclosure/@url)' -)

HASH=$(nix-prefetch-url $DOWNLOAD_URL | xargs nix hash convert --hash-algo sha256)

cat > source.nix << _EOF_
{
version = "$LATEST_VERSION";
src = fetchurl {
url = "$DOWNLOAD_URL";
sha256 = "$HASH";
};
}
_EOF_

0 comments on commit b8452f1

Please sign in to comment.