ripasso-cursive: cosmetic changes (#361736)
[NixPkgs.git] / pkgs / by-name / ap / apx / package.nix
blobff21850caafe40824d391a0d36421bf5bfee63bb
2   lib,
3   buildGoModule,
4   fetchFromGitHub,
5   installShellFiles,
6   distrobox,
7   podman,
8 }:
10 buildGoModule rec {
11   pname = "apx";
12   version = "2.4.4";
14   src = fetchFromGitHub {
15     owner = "Vanilla-OS";
16     repo = "apx";
17     rev = "v${version}";
18     hash = "sha256-60z6wbbXQp7MA5l7LP/mToZftX+nbcs2Mewg5jCFwFk=";
19   };
21   vendorHash = "sha256-YHnPLjZWUYoARHF4V1Pm1LYdCJGubPCve0wQ5FpeXUg=";
23   # podman needed for apx to not error when building shell completions
24   nativeBuildInputs = [ installShellFiles podman ];
26   ldflags = [ "-s" "-w" "-X 'main.Version=v${version}'" ];
28   postPatch = ''
29     substituteInPlace config/apx.json \
30       --replace-fail "/usr/share/apx/distrobox/distrobox" "${distrobox}/bin/distrobox" \
31       --replace-fail "/usr/share/apx" "$out/bin/apx"
32     substituteInPlace settings/config.go \
33       --replace-fail "/usr/share/apx/" "$out/share/apx/"
34   '';
36   postInstall = ''
37     install -Dm444 config/apx.json -t $out/share/apx/
38     installManPage man/man1/*
39     install -Dm444 README.md -t $out/share/docs/apx
40     install -Dm444 COPYING.md $out/share/licenses/apx/LICENSE
42     # Create a temp writable home-dir so apx outputs completions without error
43     export HOME=$(mktemp -d)
44     # apx command now works (for completions)
45     # though complains "Error: no such file or directory"
46     installShellCompletion --cmd apx \
47       --bash <($out/bin/apx completion bash) \
48       --fish <($out/bin/apx completion fish) \
49       --zsh <($out/bin/apx completion zsh)
50   '';
52   meta = with lib; {
53     description = "Vanilla OS package manager";
54     homepage = "https://github.com/Vanilla-OS/apx";
55     changelog = "https://github.com/Vanilla-OS/apx/releases/tag/v${version}";
56     license = licenses.gpl3Only;
57     maintainers = with maintainers; [ dit7ya chewblacka ];
58     mainProgram = "apx";
59   };