nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 fetchurl,
5 unzip,
6 writeShellScript,
7 jq,
8 ast-grep,
9 common-updater-scripts,
10}:
11
12stdenv.mkDerivation (finalAttrs: {
13 pname = "tidgi";
14 version = "0.12.4";
15
16 src =
17 {
18 x86_64-darwin = fetchurl {
19 url = "https://github.com/tiddly-gittly/TidGi-Desktop/releases/download/v${finalAttrs.version}/TidGi-darwin-x64-${finalAttrs.version}.zip";
20 hash = "sha256-nxfnPz2oxsYUsT2Q9ADDxVq5xcJvkNDQTBX8EkGUF4g=";
21 };
22 aarch64-darwin = fetchurl {
23 url = "https://github.com/tiddly-gittly/TidGi-Desktop/releases/download/v${finalAttrs.version}/TidGi-darwin-arm64-${finalAttrs.version}.zip";
24 hash = "sha256-bSJFM67+KVECUqjwu1HYipn+zOps1ahNzM721yZL52c=";
25 };
26 }
27 .${stdenv.hostPlatform.system} or (throw "Unsupported system: ${stdenv.hostPlatform.system}");
28
29 dontBuild = true;
30
31 nativeBuildInputs = [ unzip ];
32
33 sourceRoot = ".";
34
35 installPhase = ''
36 runHook preInstall
37
38 mkdir -p "$out/Applications"
39 cp -r *.app "$out/Applications"
40
41 runHook postInstall
42 '';
43
44 passthru.updateScript = writeShellScript "update-tidgi" ''
45 version=$(nix eval --raw --file . tidgi.version)
46 latestVersion=$(curl ''${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} --fail --silent https://api.github.com/repos/tiddly-gittly/TidGi-Desktop/releases/latest | ${lib.getExe jq} --raw-output .tag_name | sed 's/^v//')
47 if [[ "$latestVersion" == "$version" ]]; then
48 exit 0
49 fi
50 ${lib.getExe ast-grep} scan --inline-rules "
51 id: update-version
52 language: nix
53 rule:
54 kind: binding
55 regex: '^\s*version\s*='
56 fix: 'version = \"$latestVersion\";'
57 " --update-all $(env EDITOR=echo nix edit --file . tidgi)
58 systems=$(nix eval --json -f . tidgi.meta.platforms | ${lib.getExe jq} --raw-output '.[]')
59 for system in $systems; do
60 hash=$(nix hash convert --to sri --hash-algo sha256 $(nix-prefetch-url $(nix eval --raw --file . tidgi.src.url --system "$system")))
61 ${lib.getExe' common-updater-scripts "update-source-version"} tidgi $latestVersion $hash --system=$system --ignore-same-version --ignore-same-hash
62 done
63 '';
64
65 meta = {
66 changelog = "https://github.com/tiddly-gittly/TidGi-Desktop/releases/tag/v${finalAttrs.version}";
67 description = "Customizable personal knowledge-base and blogging platform with git as backup manager";
68 homepage = "https://github.com/tiddly-gittly/TidGi-Desktop";
69 license = lib.licenses.mpl20;
70 maintainers = with lib.maintainers; [ klchen0112 ];
71 platforms = [
72 "aarch64-darwin"
73 "x86_64-darwin"
74 ];
75 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
76 };
77})