about summary refs log tree commit diff
path: root/pkgs/gurl/default.nix
blob: e37d662f57adf2239c07446105ab5eb5cb13ae6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
{ stdenv, fetchurl, fetchFromGitHub, zig }:

## Build
# stdenv.mkDerivation {
#   pname = "gurl";
#   version = "0.1";

#   src = fetchFromGitHub {
#     owner = "MasterQ32";
#     repo = "gurl";
#     rev = "v0.1";
#     sha256 = "1prg7ywsd78h486lfcqhzxmnx2wai7rr3qzxldw9ggjv1mjf5laq";
#     fetchSubmodules = true;
#   };

#   nativeBuildInputs = [ zig ];

#   buildPhase = ''
#     export XDG_CACHE_HOME=$(mktemp -d)
#     zig build
#     rm -rf $XDG_CACHE_HOME
#   '';

#   installPhase = ''
#     mkdir -p $out/bin
#     cp zig-cache/bin/gurl $out/bin
#   '';
# }

## Prebuilt
let
  inherit (stdenv.hostPlatform) system;
  throwSystem = throw "Unsupported system: ${system}";

  version = "0.1";

  prebuilts = let
    base = "https://github.com/MasterQ32/gurl/releases/download";
  in
  {
    x86_64-linux = {
      url = "${base}/v${version}/gurl-x86_64-linux";
      sha256 = "0yz3w5mqgl1spszndpbrmy6jvxpfx2n3qlmv4v8f5mp1my6kgysy";
    };
    aarch64-linux = {
      url = "${base}/v${version}/gurl-aarch64-linux";
      sha256 = "0rwscrnzl29rmg2xpzabv0ww9rc4xsj12ddiw2rn005wag9an1ci";
    };
  };

  source = prebuilts.${system} or throwSystem;
  bin = fetchurl source;

in
  stdenv.mkDerivation {
    inherit version;
    pname = "gurl";
    unpackPhase = "true";

    installPhase = ''
      mkdir -p $out/bin
      cp ${bin} $out/bin/gurl
      chmod +x $out/bin/gurl
    '';

  }