{ lib, rustPlatform, fetchFromGitHub, nixVersions, nixosTests, boost, pkg-config, stdenv, installShellFiles, nix-update-script, crates ? [ "attic-client" ], }: let # Only the attic-client crate builds against the Nix C++ libs # This derivation is also used to build the server needNixInclude = lib.elem "attic-client" crates; nix = nixVersions.nix_2_28; in rustPlatform.buildRustPackage { pname = "attic"; version = "0-unstable-2025-09-24"; src = fetchFromGitHub { owner = "zhaofengli"; repo = "attic"; rev = "12cbeca141f46e1ade76728bce8adc447f2166c6"; hash = "sha256-0nZlCCDC5PfndsQJXXtcyrtrfW49I3KadGMDlutzaGU="; }; nativeBuildInputs = [ pkg-config installShellFiles ]; buildInputs = lib.optional needNixInclude nix ++ [ boost ]; cargoBuildFlags = lib.concatMapStrings (c: "-p ${c} ") crates; cargoHash = "sha256-h041o0s+bciXnvSuk4j+/uCY/sRRQWDVf+WEb9GEYeY="; env = { ATTIC_DISTRIBUTOR = "nixpkgs"; } // lib.optionalAttrs needNixInclude { NIX_INCLUDE_PATH = "${lib.getDev nix}/include"; }; # Attic interacts with Nix directly and its tests require trusted-user access # to nix-daemon to import NARs, which is not possible in the build sandbox. doCheck = false; postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' if [[ -f $out/bin/attic ]]; then installShellCompletion --cmd attic \ --bash <($out/bin/attic gen-completions bash) \ --zsh <($out/bin/attic gen-completions zsh) \ --fish <($out/bin/attic gen-completions fish) fi ''; passthru = { tests = { inherit (nixosTests) atticd; }; updateScript = nix-update-script { extraArgs = [ "--version=branch" ]; }; }; meta = { description = "Multi-tenant Nix Binary Cache"; homepage = "https://github.com/zhaofengli/attic"; license = lib.licenses.asl20; maintainers = with lib.maintainers; [ zhaofengli aciceri defelo ]; platforms = lib.platforms.linux ++ lib.platforms.darwin; mainProgram = "attic"; }; }