nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 125 lines 3.5 kB view raw
1{ 2 lib, 3 buildGoModule, 4 fetchFromGitHub, 5 installShellFiles, 6 distrobox, 7 podman, 8 writableTmpDirAsHomeHook, 9 curl, 10 jq, 11 common-updater-scripts, 12 writeShellScript, 13}: 14 15buildGoModule rec { 16 pname = "apx"; 17 version = "2.4.5"; 18 versionConfig = "1.0.0"; 19 20 src = fetchFromGitHub { 21 owner = "Vanilla-OS"; 22 repo = "apx"; 23 tag = "v${version}"; 24 hash = "sha256-0Rfj7hrH26R9GHOPPVdCaeb1bfAw9KnPpJYXyiei90U="; 25 }; 26 27 # Official Vanilla APX configs (stacks + package-managers) 28 configsSrc = fetchFromGitHub { 29 owner = "Vanilla-OS"; 30 repo = "vanilla-apx-configs"; 31 tag = "v${versionConfig}"; 32 hash = "sha256-cCXmHkRjcWcpMtgPVtQF5Q76jr1Qt2RHSLtWLQdq+aE="; 33 }; 34 35 vendorHash = "sha256-RoZ6sXbvIHfQcup9Ba/PpzS0eytKdX4WjDUlgB3UjfE="; 36 37 # podman needed for apx to not error when building shell completions 38 nativeBuildInputs = [ 39 installShellFiles 40 podman 41 ]; 42 43 nativeCheckInputs = [ 44 writableTmpDirAsHomeHook 45 ]; 46 47 ldflags = [ 48 "-s" 49 "-w" 50 "-X 'main.Version=v${version}'" 51 ]; 52 53 postPatch = '' 54 substituteInPlace config/apx.json \ 55 --replace-fail "/usr/share/apx/distrobox/distrobox" "${distrobox}/bin/distrobox" \ 56 --replace-fail "/usr/share/apx" "$out/share/apx" 57 substituteInPlace settings/config.go \ 58 --replace-fail "/usr/share/apx/" "$out/share/apx/" 59 ''; 60 61 postInstall = '' 62 # Base configuration of apx 63 install -Dm444 config/apx.json -t $out/share/apx/ 64 65 # Install official Vanilla configs (same as install script) 66 install -d $out/share/apx 67 cp -r ${configsSrc}/stacks $out/share/apx/ 68 cp -r ${configsSrc}/package-managers $out/share/apx/ 69 70 # Man pages, documentation, license 71 installManPage man/man1/* 72 install -Dm444 README.md -t $out/share/docs/apx 73 install -Dm444 COPYING.md $out/share/licenses/apx/LICENSE 74 75 # apx command now works (for completions) 76 # though complains "Error: no such file or directory" 77 installShellCompletion --cmd apx \ 78 --bash <($out/bin/apx completion bash) \ 79 --fish <($out/bin/apx completion fish) \ 80 --zsh <($out/bin/apx completion zsh) 81 ''; 82 83 passthru.updateScript = writeShellScript "update-apx" '' 84 set -euo pipefail 85 PATH=${ 86 lib.makeBinPath [ 87 curl 88 jq 89 common-updater-scripts 90 ] 91 }:$PATH 92 93 echo "Fetching latest version for vanilla-apx-configs..." 94 LATEST_CONFIG=$(curl -s https://api.github.com/repos/Vanilla-OS/vanilla-apx-configs/releases/latest | jq -r .tag_name | sed 's/^v//') 95 96 echo "Updating versionConfig to $LATEST_CONFIG..." 97 update-source-version apx "$LATEST_CONFIG" --version-key=versionConfig --source-key=configsSrc 98 99 echo "Updating main apx package..." 100 nix-update apx 101 ''; 102 103 meta = { 104 description = "Vanilla OS package manager"; 105 longDescription = '' 106 Apx is the Vanilla OS package manager that allows you to install packages 107 from multiple sources inside managed containers without altering the host system. 108 109 Note: This package requires Podman to be enabled in your NixOS configuration. 110 Add the following to your configuration.nix: 111 112 virtualisation.podman.enable = true; 113 environment.systemPackages = with pkgs; [ apx ]; 114 ''; 115 homepage = "https://github.com/Vanilla-OS/apx"; 116 changelog = "https://github.com/Vanilla-OS/apx/releases/tag/v${version}"; 117 license = lib.licenses.gpl3Only; 118 maintainers = with lib.maintainers; [ 119 dit7ya 120 chewblacka 121 masrlinu 122 ]; 123 mainProgram = "apx"; 124 }; 125}