lol
1{
2 lib,
3 buildGoModule,
4 fetchFromGitHub,
5 installShellFiles,
6 distrobox,
7 podman,
8 writableTmpDirAsHomeHook,
9}:
10
11buildGoModule rec {
12 pname = "apx";
13 version = "2.4.5";
14
15 src = fetchFromGitHub {
16 owner = "Vanilla-OS";
17 repo = "apx";
18 tag = "v${version}";
19 hash = "sha256-0Rfj7hrH26R9GHOPPVdCaeb1bfAw9KnPpJYXyiei90U=";
20 };
21
22 vendorHash = "sha256-RoZ6sXbvIHfQcup9Ba/PpzS0eytKdX4WjDUlgB3UjfE=";
23
24 # podman needed for apx to not error when building shell completions
25 nativeBuildInputs = [
26 installShellFiles
27 podman
28 ];
29
30 nativeCheckInputs = [
31 writableTmpDirAsHomeHook
32 ];
33
34 ldflags = [
35 "-s"
36 "-w"
37 "-X 'main.Version=v${version}'"
38 ];
39
40 postPatch = ''
41 substituteInPlace config/apx.json \
42 --replace-fail "/usr/share/apx/distrobox/distrobox" "${distrobox}/bin/distrobox" \
43 --replace-fail "/usr/share/apx" "$out/bin/apx"
44 substituteInPlace settings/config.go \
45 --replace-fail "/usr/share/apx/" "$out/share/apx/"
46 '';
47
48 postInstall = ''
49 install -Dm444 config/apx.json -t $out/share/apx/
50 installManPage man/man1/*
51 install -Dm444 README.md -t $out/share/docs/apx
52 install -Dm444 COPYING.md $out/share/licenses/apx/LICENSE
53
54 # apx command now works (for completions)
55 # though complains "Error: no such file or directory"
56 installShellCompletion --cmd apx \
57 --bash <($out/bin/apx completion bash) \
58 --fish <($out/bin/apx completion fish) \
59 --zsh <($out/bin/apx completion zsh)
60 '';
61
62 meta = {
63 description = "Vanilla OS package manager";
64 homepage = "https://github.com/Vanilla-OS/apx";
65 changelog = "https://github.com/Vanilla-OS/apx/releases/tag/v${version}";
66 license = lib.licenses.gpl3Only;
67 maintainers = with lib.maintainers; [
68 dit7ya
69 chewblacka
70 ];
71 mainProgram = "apx";
72 };
73}