nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenvNoCC,
4 buildFHSEnv,
5 appimageTools,
6 fetchurl,
7 desktop-file-utils,
8 dpkg,
9 runScript ? "bitcometd",
10 writeShellScript,
11 nix-update,
12}:
13
14let
15 pname = "bitcomet";
16 version = "2.19.2";
17
18 meta = {
19 homepage = "https://www.bitcomet.com";
20 description = "BitTorrent download client";
21 mainProgram = "bitcometd";
22 sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
23 license = lib.licenses.unfree;
24 platforms = [
25 "aarch64-linux"
26 "x86_64-linux"
27 ];
28 maintainers = [ ];
29 };
30
31 bitcomet = stdenvNoCC.mkDerivation {
32 inherit pname version meta;
33
34 src =
35 let
36 selectSystem =
37 attrs:
38 attrs.${stdenvNoCC.hostPlatform.system}
39 or (throw "Unsupported system: ${stdenvNoCC.hostPlatform.system}");
40 arch = selectSystem {
41 x86_64-linux = "x86_64";
42 aarch64-linux = "arm64";
43 };
44 in
45 fetchurl {
46 url = "https://download.bitcomet.com/linux/${arch}/BitComet-${version}-${arch}.deb";
47 hash = selectSystem {
48 x86_64-linux = "sha256-26hpKNCetqV0whfzNo950EAmK+LKC1RsN5f/9HU9zKs=";
49 aarch64-linux = "sha256-VrrjQ4dcj0XL2xmNspo2mJ+3BVy9vKyVw6QaHkha0LY=";
50 };
51 };
52
53 nativeBuildInputs = [
54 dpkg
55 desktop-file-utils
56 ];
57
58 installPhase = ''
59 runHook preInstall
60
61 desktop-file-edit usr/share/applications/bitcomet.desktop \
62 --remove-key="Version" \
63 --remove-key="Comment" \
64 --set-key="Exec" --set-value="BitComet" \
65 --set-icon="bitcomet"
66 cp -r usr $out
67
68 runHook postInstall
69 '';
70 };
71in
72buildFHSEnv {
73 inherit pname version meta;
74
75 executableName = "bitcometd";
76
77 runScript = "bitcometd";
78
79 targetPkgs = pkgs: [ bitcomet ] ++ appimageTools.defaultFhsEnvArgs.targetPkgs pkgs;
80
81 multiPkgs = appimageTools.defaultFhsEnvArgs.multiPkgs;
82
83 passthru = {
84 inherit bitcomet;
85 updateScript = writeShellScript "update-bitcomet" ''
86 latestVersion=$(curl --fail --silent https://www.cometbbs.com/t/linux%E5%86%85%E6%B5%8B%E7%89%88/88604 | grep -oP 'BitComet-\K[0-9]+\.[0-9]+\.[0-9]+(?=-x86_64\.deb)' | head -n1)
87 ${lib.getExe nix-update} pkgsCross.gnu64.bitcomet.bitcomet --version $latestVersion
88 ${lib.getExe nix-update} pkgsCross.aarch64-multiplatform.bitcomet.bitcomet --version skip
89 '';
90 };
91}