|
| 1 | +{ |
| 2 | + lib, |
| 3 | + fetchurl, |
| 4 | + appimageTools, |
| 5 | + makeWrapper, |
| 6 | + writeScript, |
| 7 | +}: |
| 8 | +let |
| 9 | + pname = "redact"; |
| 10 | + version = "0.18.0"; |
| 11 | + src = fetchurl { |
| 12 | + url = "https://update-desktop.redact.dev/build/Redact-${version}.AppImage"; |
| 13 | + hash = "sha256-qqqf8BAwXEKgZwl6vsPw/0S+qItz5ZqB59DJkW9q1xc="; |
| 14 | + }; |
| 15 | + appimageContents = appimageTools.extractType2 { inherit pname src version; }; |
| 16 | +in |
| 17 | +appimageTools.wrapType2 { |
| 18 | + inherit pname version src; |
| 19 | + |
| 20 | + nativeBuildInputs = [ makeWrapper ]; |
| 21 | + |
| 22 | + extraInstallCommands = '' |
| 23 | + wrapProgram $out/bin/${pname} \ |
| 24 | + --add-flags "\''${NIXOS_OZONE_WL:+\''${WAYLAND_DISPLAY:+--ozone-platform=wayland --enable-features=WaylandWindowDecorations}}" |
| 25 | + install -Dm444 ${appimageContents}/redact.desktop -t $out/share/applications |
| 26 | + install -Dm444 ${appimageContents}/redact.png -t $out/share/icons/hicolor/512x512/apps/redact.png |
| 27 | + substituteInPlace $out/share/applications/redact.desktop \ |
| 28 | + --replace-fail 'Exec=AppRun' 'Exec=${pname}' |
| 29 | + ''; |
| 30 | + |
| 31 | + passthru.updateScript = |
| 32 | + writeScript "update.sh" |
| 33 | + /** |
| 34 | + Scraping the Windows URL for version is intentional, since |
| 35 | + the download link for Linux on redact.dev points to an older version, |
| 36 | + even though the Cloudflare bucket contains the latest Linux version. |
| 37 | + */ |
| 38 | + '' |
| 39 | + #!/usr/bin/env nix-shell |
| 40 | + #!nix-shell -i bash -p curl coreutils gnused common-updater-scripts |
| 41 | + set -eu -o pipefail |
| 42 | + url="$(curl -ILs -w %{url_effective} -o /dev/null https://download.redact.dev/windows)" |
| 43 | + version="$(echo $url | sed -n 's/.*Redact-Setup-\([0-9]\+\.[0-9]\+\.[0-9]\+\).*/\1/p')" |
| 44 | + currentVersion=$(nix-instantiate --eval -E "with import ./. {}; redact.version or (lib.getVersion redact)" | tr -d '"') |
| 45 | + if [[ "$version" != "$currentVersion" ]]; then |
| 46 | + hash=$(nix-hash --to-sri --type sha256 "$(nix-prefetch-url "$url")") |
| 47 | + update-source-version redact "$version" "$hash" --print-changes |
| 48 | + fi |
| 49 | + ''; |
| 50 | + |
| 51 | + meta = { |
| 52 | + description = "The only platform that allows you to automatically clean up your old posts from services like Twitter, Reddit, Facebook, Discord, and more, all in one place."; |
| 53 | + homepage = "https://redact.dev/"; |
| 54 | + license = lib.licenses.unfree; |
| 55 | + maintainers = with lib.maintainers; [ reputable2772 ]; |
| 56 | + mainProgram = "redact"; |
| 57 | + sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ]; |
| 58 | + platforms = [ "x86_64-linux" ]; |
| 59 | + }; |
| 60 | +} |
0 commit comments