Profpatsch/third_party/overlays/sam/pkgs/by-name/syndicated-open/package.nix
 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
{ lib
, buildNimPackage
, fetchFromGitea
, makeDesktopItem
, pkg-config
, pcre
}:

buildNimPackage rec {
  pname = "syndicated-open";
  version = "20231010";

  src = fetchFromGitea {
    domain = "git.syndicate-lang.org";
    owner = "ehmry";
    repo = pname;
    rev = version;
    hash = "sha256-DVBSsnN59XKV7Pc1spBxcLwyOIif3xMHXHID9khVJck=";
  };

  nativeBuildInputs = [ pkg-config ];
  propagatedBuildInputs = [ pcre ];

  lockFile = "${src}/lock.json";

  desktopItem = makeDesktopItem rec {
    name = "open";
    desktopName = "Syndicated URI open";
    exec = "${name} %U";
    mimeTypes = [
      "application/vnd.mozilla.xul+xml"
      "application/xhtml+xml"
      "text/html"
      "text/xml"
      "x-scheme-handler/http"
      "x-scheme-handler/https"
    ];
  };

  postInstall = ''
    ln -s open $out/bin/xdg-open
    cp -a $desktopItem/* $out/
  '';

  meta = src.meta // {
    description = "Syndicated open command";
    maintainers = [ lib.maintainers.ehmry ];
    license = lib.licenses.unlicense;
  };
}