clouddrive2: init at 0.7.21

This commit is contained in:
L-Trump 2024-10-17 13:05:06 +08:00
parent a3c0b3b215
commit adef663e98
2 changed files with 93 additions and 0 deletions

View File

@ -0,0 +1,68 @@
{
lib,
stdenv,
fetchurl,
makeWrapper,
versionCheckHook,
}:
let
os = if stdenv.hostPlatform.isDarwin then "macos" else "linux";
arch = if stdenv.hostPlatform.isAarch64 then "aarch64" else "x86_64";
in
stdenv.mkDerivation (finalAttrs: {
pname = "clouddrive2";
version = "0.7.21";
src = fetchurl {
url = "https://github.com/cloud-fs/cloud-fs.github.io/releases/download/v${finalAttrs.version}/clouddrive-2-${os}-${arch}-${finalAttrs.version}.tgz";
hash =
{
x86_64-linux = "sha256-U8th7cEAFDBg+CV6DEX0YnqaM2+NJNKmyA/IRtnWESo=";
aarch64-linux = "sha256-LaAVO4p0sSfsGmFPSzly1Hzo+t4oY6mgaTdnHrhu0vI=";
x86_64-darwin = "sha256-/cyLcX7A+WpuS6yciqAz3jvDIJvXEoyQyX+xe6+eRmE=";
aarch64-darwin = "sha256-Y5cKIHVzX0TjMNZGW3YvU8MNpuGsIjp4qNlB+b2BRJM=";
}
.${stdenv.hostPlatform.system} or (throw "unsupported system ${stdenv.hostPlatform.system}");
};
nativeBuildInputs = [ makeWrapper ];
installPhase = ''
runHook preInstall
mkdir -p $out/bin
mkdir -p $out/opt/clouddrive2
cp -r wwwroot "$out/opt/clouddrive2/wwwroot"
cp -r clouddrive "$out/opt/clouddrive2/clouddrive"
makeWrapper $out/opt/clouddrive2/clouddrive $out/bin/clouddrive
runHook postInstall
'';
nativeInstallCheckPhaseInputs = [ versionCheckHook ];
versionCheckProgramArg = [ "--version" ];
doInstallCheck = true;
passthru.updateScript = ./update.sh;
meta = {
homepage = "https://www.clouddrive2.com";
changelog = "https://github.com/cloud-fs/cloud-fs.github.io/releases/tag/v${finalAttrs.version}";
description = "Multi-cloud drives management tool supporting mounting cloud drives locally";
longDescription = ''
CloudDrive is a powerful multi-cloud drive management tool that provides a multi-cloud
drive solution that includes local mounting of cloud drives. It supports lots of cloud
drives in China.
'';
mainProgram = "clouddrive";
license = lib.licenses.unfree;
platforms = [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
];
sourceProvenance = with lib.sourceTypes; [ binaryNativeCode ];
maintainers = with lib.maintainers; [ ltrump ];
};
})

View File

@ -0,0 +1,25 @@
#!/usr/bin/env nix-shell
#!nix-shell -i bash -p bash curl coreutils jq common-updater-scripts
latestTag=$(curl -sSfL ${GITHUB_TOKEN:+-u ":$GITHUB_TOKEN"} https://api.github.com/repos/cloud-fs/cloud-fs.github.io/releases/latest | jq -r ".tag_name")
latestVersion="$(expr "$latestTag" : 'v\(.*\)')"
currentVersion=$(nix-instantiate --eval -E "with import ./. {}; clouddrive2.version" | tr -d '"')
echo "latest version: $latestVersion"
echo "current version: $currentVersion"
if [[ "$latestVersion" == "$currentVersion" ]]; then
echo "package is up-to-date"
exit 0
fi
for i in \
"x86_64-linux linux-x86_64" \
"aarch64-linux linux-aarch64" \
"x86_64-darwin macos-x86_64" \
"aarch64-darwin macos-aarch64"; do
set -- $i
prefetch=$(nix-prefetch-url "https://github.com/cloud-fs/cloud-fs.github.io/releases/download/v$latestVersion/clouddrive-2-$2-$latestVersion.tgz")
hash=$(nix-hash --type sha256 --to-sri $prefetch)
update-source-version clouddrive2 $latestVersion $hash --system=$1 --ignore-same-version
done