Unverified Commit 4afcfbf9 authored by Aleksana's avatar Aleksana Committed by GitHub
Browse files

attic-client: 0-unstable-2025-07-01 -> 0-unstable-2025-07-08, use nix 2.28,...

attic-client: 0-unstable-2025-07-01 -> 0-unstable-2025-07-08, use nix 2.28, fix updateScript (#423483)
parents 79c90ad7 f9011635
Loading
Loading
Loading
Loading
+19 −22
Original line number Diff line number Diff line
@@ -8,22 +8,26 @@
  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-07-01";
  version = "0-unstable-2025-07-08";

  src = fetchFromGitHub {
    owner = "zhaofengli";
    repo = "attic";
    rev = "896ad88fa57ad5dbcd267c0ac51f1b71ccfcb4dd";
    hash = "sha256-V0EPQNsQko1a8OqIWc2lLviLnMpR1m08Ej00z5RVTfs=";
    rev = "07147da79388468ff85c2a650500d11ca0edd12e";
    hash = "sha256-pHsHcWQWGyzDh48YHnSw9YVKEnQ95QWnmHNFtvo7iu0=";
  };

  nativeBuildInputs = [
@@ -31,21 +35,15 @@ rustPlatform.buildRustPackage {
    installShellFiles
  ];

  buildInputs = lib.optional needNixInclude nixVersions.nix_2_24 ++ [
    boost
  ];
  buildInputs = lib.optional needNixInclude nix ++ [ boost ];

  cargoBuildFlags = lib.concatMapStrings (c: "-p ${c} ") crates;
  cargoHash = "sha256-AbpWnYfBMrR6oOfy2LkQvIPYsClCWE89bJav+iHTtLM=";
  cargoHash = "sha256-I5GS32dOCECYKSNMi2Xs2rBRxPLcvLEWHlIIWP/bMBU=";
  useFetchCargoVendor = true;

  env =
    {
  env = {
    ATTIC_DISTRIBUTOR = "nixpkgs";
    }
    // lib.optionalAttrs needNixInclude {
      NIX_INCLUDE_PATH = "${lib.getDev nixVersions.nix_2_24}/include";
    };
  } // 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.
@@ -61,22 +59,21 @@ rustPlatform.buildRustPackage {
  '';

  passthru = {
    tests = {
      inherit (nixosTests) atticd;
    };
    tests = { inherit (nixosTests) atticd; };

    updateScript = ./update.sh;
    updateScript = nix-update-script { extraArgs = [ "--version=branch" ]; };
  };

  meta = with lib; {
  meta = {
    description = "Multi-tenant Nix Binary Cache";
    homepage = "https://github.com/zhaofengli/attic";
    license = licenses.asl20;
    maintainers = with maintainers; [
    license = lib.licenses.asl20;
    maintainers = with lib.maintainers; [
      zhaofengli
      aciceri
      defelo
    ];
    platforms = platforms.linux ++ platforms.darwin;
    platforms = lib.platforms.linux ++ lib.platforms.darwin;
    mainProgram = "attic";
  };
}
+0 −40
Original line number Diff line number Diff line
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p wget nix-prefetch-github jq coreutils

# shellcheck shell=bash

if [ -n "$GITHUB_TOKEN" ]; then
    TOKEN_ARGS=(--header "Authorization: token $GITHUB_TOKEN")
fi

if [[ $# -gt 1 || $1 == -* ]]; then
    echo "Regenerates packaging data for attic."
    echo "Usage: $0 [git commit]"
    exit 1
fi

set -x

cd "$(dirname "$0")"
rev="$1"

set -euo pipefail

if [ -z "$rev" ]; then
    rev="$(wget -O- "${TOKEN_ARGS[@]}" "https://api.github.com/repos/zhaofengli/attic/commits?per_page=1" | jq -r '.[0].sha')"
fi

date="$(wget -O- "${TOKEN_ARGS[@]}" "https://api.github.com/repos/zhaofengli/attic/commits/$rev" | jq -r '.commit.author.date' | cut -dT -f1)"

version="0-unstable-$date"

# Sources
src_hash=$(nix-prefetch-github zhaofengli attic --rev "$rev" | jq -r .hash)

# Cargo.lock
src="https://raw.githubusercontent.com/zhaofengli/attic/$rev"
wget "${TOKEN_ARGS[@]}" "$src/Cargo.lock" -O Cargo.lock

sed -i -E -e "s#version = \".*\"#version = \"$version\"#" package.nix
sed -i -E -e "s#rev = \".*\"#rev = \"$rev\"#" package.nix
sed -i -E -e "s#hash = \".*\"#hash = \"$src_hash\"#" package.nix