Loading pkgs/by-name/ty/typora/package.nix +109 −129 Original line number Diff line number Diff line { lib, stdenv, fetchurl, undmg, dpkg, lib, glib, autoPatchelfHook, makeShellWrapper, # dependencies alsa-lib, nss, nspr, gtk3, libgbm, libGL, # runtime dependencies cups, dbus, libdrm, gtk3, pango, cairo, libxkbcommon, libgbm, expat, alsa-lib, buildFHSEnv, writeTextFile, }: let pname = "typora"; version = "1.12.4"; src = fetchurl { x86_64-linux = { passthru = { sources = { x86_64-linux = fetchurl { urls = [ "https://download.typora.io/linux/typora_${version}_amd64.deb" "https://downloads.typoraio.cn/linux/typora_${version}_amd64.deb" ]; hash = "sha256-P3wgzMVcyvmXM/w24kPgYGOfSaAh+SFzgeoJoasEmH8="; }; aarch64-linux = { aarch64-linux = fetchurl { urls = [ "https://download.typora.io/linux/typora_${version}_arm64.deb" "https://downloads.typoraio.cn/linux/typora_${version}_arm64.deb" ]; hash = "sha256-tQFCppOeeWJK8ovf71LPJRVteOJ8XbbNojhV4QLmVJ0="; }; aarch64-darwin = fetchurl { urls = [ "https://download.typora.io/mac/Typora-${version}.dmg" "https://downloads.typoraio.cn/mac/Typora-${version}.dmg" ]; hash = "sha256-XPaMUHmIz+pjT/JQVV9ddNpTWtBDLjyoi5W1Qz9gBAo="; }; }; updateScript = ./update.sh; }; src = passthru.sources.${stdenv.hostPlatform.system} or (throw "unsupported system ${stdenv.hostPlatform.system}"); meta = { description = "A minimal Markdown editor and reader."; homepage = "https://typora.io/"; changelog = "https://typora.io/releases/all"; license = lib.licenses.unfree; maintainers = with lib.maintainers; [ npulidomateo chillcicada ]; platforms = builtins.attrNames passthru.sources; } .${stdenv.hostPlatform.system} or (throw "unsupported system ${stdenv.hostPlatform.system}"); // lib.optionalAttrs stdenv.hostPlatform.isLinux { mainProgram = "typora"; }; typoraBase = stdenv.mkDerivation { inherit pname version src; in nativeBuildInputs = [ dpkg ]; if stdenv.hostPlatform.isDarwin then stdenv.mkDerivation { inherit pname version src passthru meta ; dontConfigure = true; dontBuild = true; nativeBuildInputs = [ undmg ]; sourceRoot = "."; installPhase = '' runHook preInstall mkdir -p $out/bin $out/share mv usr/share $out ln -s $out/share/typora/Typora $out/bin/Typora mkdir -p $out/Applications cp -a Typora.app $out/Applications runHook postInstall ''; }; } else stdenv.mkDerivation { inherit pname version src passthru meta ; nativeBuildInputs = [ dpkg autoPatchelfHook makeShellWrapper ]; typoraFHS = buildFHSEnv { pname = "typora-fhs"; inherit version; targetPkgs = pkgs: (with pkgs; [ typoraBase udev buildInputs = [ alsa-lib glib nss nspr atk cups dbus gtk3 libdrm pango cairo libgbm libGL expat libxkbcommon libx11 libxcursor libxrandr libxcomposite libxdamage libxext libxfixes libxcb ]); runScript = '' Typora "$@" ''; }; launchScript = writeTextFile { name = "typora-launcher"; executable = true; text = '' #!${stdenv.shell} ]; # Configuration directory setup XDG_CONFIG_HOME=''${XDG_CONFIG_HOME:-~/.config} TYPORA_CONFIG_DIR="$XDG_CONFIG_HOME/Typora" TYPORA_DICT_DIR="$TYPORA_CONFIG_DIR/typora-dictionaries" runtimeDependencies = map lib.getLib [ cups dbus pango ]; # Create config directories with proper permissions mkdir -p "$TYPORA_DICT_DIR" chmod 755 "$TYPORA_CONFIG_DIR" chmod 755 "$TYPORA_DICT_DIR" installPhase = '' runHook preInstall # Read user flags if they exist if [ -f "$XDG_CONFIG_HOME/typora-flags.conf" ]; then TYPORA_USER_FLAGS="$(sed 's/#.*//' "$XDG_CONFIG_HOME/typora-flags.conf" | tr '\n' ' ')" fi mkdir -p $out/{bin,share,opt} exec ${typoraFHS}/bin/typora-fhs "$@" $TYPORA_USER_FLAGS ''; }; cp -r usr/share/typora $out/opt cp -r usr/share/{applications,icons} $out/share in stdenv.mkDerivation { inherit pname version src; sed -i '/Change Log/d' "$out/share/applications/typora.desktop" dontUnpack = true; dontConfigure = true; dontBuild = true; installPhase = '' runHook preInstall mkdir -p $out/bin ln -s ${launchScript} $out/bin/typora ln -s ${typoraBase}/share/ $out makeShellWrapper $out/opt/typora/Typora $out/bin/typora \ --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ libGL ]}" runHook postInstall ''; passthru.updateScript = ./update.sh; meta = { description = "A minimal Markdown editor and reader."; homepage = "https://typora.io/"; changelog = "https://typora.io/releases/all"; license = lib.licenses.unfree; maintainers = with lib.maintainers; [ npulidomateo chillcicada ]; platforms = [ "x86_64-linux" ]; mainProgram = "typora"; }; } pkgs/by-name/ty/typora/update.sh +7 −4 Original line number Diff line number Diff line Loading @@ -5,8 +5,11 @@ set -euo pipefail version=$(curl -s "https://typora.io/#linux" | sed -E -n 's/.*typora_([0-9.]+)_amd64.*/\1/p') amd64_hash=$(nix-hash --type sha256 --to-sri $(nix-prefetch-url https://download.typora.io/linux/typora_${version}_amd64.deb)) update-source-version typora $version $amd64_hash --system=x86_64-linux --ignore-same-version linux_amd64_hash=$(nix-hash --type sha256 --to-sri $(nix-prefetch-url https://download.typora.io/linux/typora_${version}_amd64.deb)) update-source-version typora $version $linux_amd64_hash --system=x86_64-linux --ignore-same-version arm64_hash=$(nix-hash --type sha256 --to-sri $(nix-prefetch-url https://download.typora.io/linux/typora_${version}_arm64.deb)) update-source-version typora $version $arm64_hash --system=aarch64-linux --ignore-same-version linux_arm64_hash=$(nix-hash --type sha256 --to-sri $(nix-prefetch-url https://download.typora.io/linux/typora_${version}_arm64.deb)) update-source-version typora $version $linux_arm64_hash --system=aarch64-linux --ignore-same-version darwin_arm64_hash=$(nix-hash --type sha256 --to-sri $(nix-prefetch-url https://download.typora.io/mac/Typora-${version}.dmg)) update-source-version typora $version $darwin_arm64_hash --system=aarch64-darwin --ignore-same-version Loading
pkgs/by-name/ty/typora/package.nix +109 −129 Original line number Diff line number Diff line { lib, stdenv, fetchurl, undmg, dpkg, lib, glib, autoPatchelfHook, makeShellWrapper, # dependencies alsa-lib, nss, nspr, gtk3, libgbm, libGL, # runtime dependencies cups, dbus, libdrm, gtk3, pango, cairo, libxkbcommon, libgbm, expat, alsa-lib, buildFHSEnv, writeTextFile, }: let pname = "typora"; version = "1.12.4"; src = fetchurl { x86_64-linux = { passthru = { sources = { x86_64-linux = fetchurl { urls = [ "https://download.typora.io/linux/typora_${version}_amd64.deb" "https://downloads.typoraio.cn/linux/typora_${version}_amd64.deb" ]; hash = "sha256-P3wgzMVcyvmXM/w24kPgYGOfSaAh+SFzgeoJoasEmH8="; }; aarch64-linux = { aarch64-linux = fetchurl { urls = [ "https://download.typora.io/linux/typora_${version}_arm64.deb" "https://downloads.typoraio.cn/linux/typora_${version}_arm64.deb" ]; hash = "sha256-tQFCppOeeWJK8ovf71LPJRVteOJ8XbbNojhV4QLmVJ0="; }; aarch64-darwin = fetchurl { urls = [ "https://download.typora.io/mac/Typora-${version}.dmg" "https://downloads.typoraio.cn/mac/Typora-${version}.dmg" ]; hash = "sha256-XPaMUHmIz+pjT/JQVV9ddNpTWtBDLjyoi5W1Qz9gBAo="; }; }; updateScript = ./update.sh; }; src = passthru.sources.${stdenv.hostPlatform.system} or (throw "unsupported system ${stdenv.hostPlatform.system}"); meta = { description = "A minimal Markdown editor and reader."; homepage = "https://typora.io/"; changelog = "https://typora.io/releases/all"; license = lib.licenses.unfree; maintainers = with lib.maintainers; [ npulidomateo chillcicada ]; platforms = builtins.attrNames passthru.sources; } .${stdenv.hostPlatform.system} or (throw "unsupported system ${stdenv.hostPlatform.system}"); // lib.optionalAttrs stdenv.hostPlatform.isLinux { mainProgram = "typora"; }; typoraBase = stdenv.mkDerivation { inherit pname version src; in nativeBuildInputs = [ dpkg ]; if stdenv.hostPlatform.isDarwin then stdenv.mkDerivation { inherit pname version src passthru meta ; dontConfigure = true; dontBuild = true; nativeBuildInputs = [ undmg ]; sourceRoot = "."; installPhase = '' runHook preInstall mkdir -p $out/bin $out/share mv usr/share $out ln -s $out/share/typora/Typora $out/bin/Typora mkdir -p $out/Applications cp -a Typora.app $out/Applications runHook postInstall ''; }; } else stdenv.mkDerivation { inherit pname version src passthru meta ; nativeBuildInputs = [ dpkg autoPatchelfHook makeShellWrapper ]; typoraFHS = buildFHSEnv { pname = "typora-fhs"; inherit version; targetPkgs = pkgs: (with pkgs; [ typoraBase udev buildInputs = [ alsa-lib glib nss nspr atk cups dbus gtk3 libdrm pango cairo libgbm libGL expat libxkbcommon libx11 libxcursor libxrandr libxcomposite libxdamage libxext libxfixes libxcb ]); runScript = '' Typora "$@" ''; }; launchScript = writeTextFile { name = "typora-launcher"; executable = true; text = '' #!${stdenv.shell} ]; # Configuration directory setup XDG_CONFIG_HOME=''${XDG_CONFIG_HOME:-~/.config} TYPORA_CONFIG_DIR="$XDG_CONFIG_HOME/Typora" TYPORA_DICT_DIR="$TYPORA_CONFIG_DIR/typora-dictionaries" runtimeDependencies = map lib.getLib [ cups dbus pango ]; # Create config directories with proper permissions mkdir -p "$TYPORA_DICT_DIR" chmod 755 "$TYPORA_CONFIG_DIR" chmod 755 "$TYPORA_DICT_DIR" installPhase = '' runHook preInstall # Read user flags if they exist if [ -f "$XDG_CONFIG_HOME/typora-flags.conf" ]; then TYPORA_USER_FLAGS="$(sed 's/#.*//' "$XDG_CONFIG_HOME/typora-flags.conf" | tr '\n' ' ')" fi mkdir -p $out/{bin,share,opt} exec ${typoraFHS}/bin/typora-fhs "$@" $TYPORA_USER_FLAGS ''; }; cp -r usr/share/typora $out/opt cp -r usr/share/{applications,icons} $out/share in stdenv.mkDerivation { inherit pname version src; sed -i '/Change Log/d' "$out/share/applications/typora.desktop" dontUnpack = true; dontConfigure = true; dontBuild = true; installPhase = '' runHook preInstall mkdir -p $out/bin ln -s ${launchScript} $out/bin/typora ln -s ${typoraBase}/share/ $out makeShellWrapper $out/opt/typora/Typora $out/bin/typora \ --prefix LD_LIBRARY_PATH : "${lib.makeLibraryPath [ libGL ]}" runHook postInstall ''; passthru.updateScript = ./update.sh; meta = { description = "A minimal Markdown editor and reader."; homepage = "https://typora.io/"; changelog = "https://typora.io/releases/all"; license = lib.licenses.unfree; maintainers = with lib.maintainers; [ npulidomateo chillcicada ]; platforms = [ "x86_64-linux" ]; mainProgram = "typora"; }; }
pkgs/by-name/ty/typora/update.sh +7 −4 Original line number Diff line number Diff line Loading @@ -5,8 +5,11 @@ set -euo pipefail version=$(curl -s "https://typora.io/#linux" | sed -E -n 's/.*typora_([0-9.]+)_amd64.*/\1/p') amd64_hash=$(nix-hash --type sha256 --to-sri $(nix-prefetch-url https://download.typora.io/linux/typora_${version}_amd64.deb)) update-source-version typora $version $amd64_hash --system=x86_64-linux --ignore-same-version linux_amd64_hash=$(nix-hash --type sha256 --to-sri $(nix-prefetch-url https://download.typora.io/linux/typora_${version}_amd64.deb)) update-source-version typora $version $linux_amd64_hash --system=x86_64-linux --ignore-same-version arm64_hash=$(nix-hash --type sha256 --to-sri $(nix-prefetch-url https://download.typora.io/linux/typora_${version}_arm64.deb)) update-source-version typora $version $arm64_hash --system=aarch64-linux --ignore-same-version linux_arm64_hash=$(nix-hash --type sha256 --to-sri $(nix-prefetch-url https://download.typora.io/linux/typora_${version}_arm64.deb)) update-source-version typora $version $linux_arm64_hash --system=aarch64-linux --ignore-same-version darwin_arm64_hash=$(nix-hash --type sha256 --to-sri $(nix-prefetch-url https://download.typora.io/mac/Typora-${version}.dmg)) update-source-version typora $version $darwin_arm64_hash --system=aarch64-darwin --ignore-same-version