forked from NixOS/nixpkgs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
alist: init at 3.38.0 (NixOS#348717)
- Loading branch information
Showing
1 changed file
with
108 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,108 @@ | ||
{ | ||
lib, | ||
buildGoModule, | ||
fetchFromGitHub, | ||
fetchurl, | ||
fuse, | ||
stdenv, | ||
installShellFiles, | ||
versionCheckHook, | ||
}: | ||
buildGoModule rec { | ||
pname = "alist"; | ||
version = "3.38.0"; | ||
|
||
src = fetchFromGitHub { | ||
owner = "AlistGo"; | ||
repo = "alist"; | ||
rev = "refs/tags/v${version}"; | ||
hash = "sha256-HF5T/TZXiyT186qZyzz+m0K9ajF1wk8YAZljcq5ccWM="; | ||
# populate values that require us to use git. By doing this in postFetch we | ||
# can delete .git afterwards and maintain better reproducibility of the src. | ||
leaveDotGit = true; | ||
postFetch = '' | ||
cd "$out" | ||
git rev-parse HEAD > $out/COMMIT | ||
# '0000-00-00T00:00:00Z' | ||
date -u -d "@$(git log -1 --pretty=%ct)" "+%Y-%m-%dT%H:%M:%SZ" > $out/SOURCE_DATE_EPOCH | ||
find "$out" -name .git -print0 | xargs -0 rm -rf | ||
''; | ||
}; | ||
web = fetchurl { | ||
url = "https://github.com/AlistGo/alist-web/releases/download/${version}/dist.tar.gz"; | ||
hash = "sha256-jHbWhjvHfgtdocuuELbOwrMzL8tOQfBVdH9MxasEwGo="; | ||
}; | ||
|
||
vendorHash = "sha256-qSbvb2/y5rdS/OCutNEcRDUQBCAgNudux8XDnY9TRSo="; | ||
|
||
buildInputs = [ fuse ]; | ||
|
||
tags = [ "jsoniter" ]; | ||
|
||
ldflags = [ | ||
"-s" | ||
"-w" | ||
"-X \"github.com/alist-org/alist/v3/internal/conf.GitAuthor=Xhofe <[email protected]>\"" | ||
"-X github.com/alist-org/alist/v3/internal/conf.Version=${version}" | ||
"-X github.com/alist-org/alist/v3/internal/conf.WebVersion=${version}" | ||
]; | ||
|
||
preConfigure = '' | ||
# use matched web files | ||
rm -rf public/dist | ||
tar -xzf ${web} | ||
mv -f dist public | ||
''; | ||
|
||
preBuild = '' | ||
ldflags+=" -X \"github.com/alist-org/alist/v3/internal/conf.GoVersion=$(go version | sed 's/go version //')\"" | ||
ldflags+=" -X \"github.com/alist-org/alist/v3/internal/conf.BuiltAt=$(cat SOURCE_DATE_EPOCH)\"" | ||
ldflags+=" -X github.com/alist-org/alist/v3/internal/conf.GitCommit=$(cat COMMIT)" | ||
''; | ||
|
||
checkFlags = | ||
let | ||
# Skip tests that require network access | ||
skippedTests = [ | ||
"TestHTTPAll" | ||
"TestWebsocketAll" | ||
"TestWebsocketCaller" | ||
]; | ||
in | ||
[ "-skip=^${builtins.concatStringsSep "$|^" skippedTests}$" ]; | ||
|
||
nativeBuildInputs = [ installShellFiles ]; | ||
|
||
postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) '' | ||
installShellCompletion --cmd alist \ | ||
--bash <($out/bin/alist completion bash) \ | ||
--fish <($out/bin/alist completion fish) \ | ||
--zsh <($out/bin/alist completion zsh) | ||
''; | ||
|
||
doInstallCheck = true; | ||
|
||
versionCheckProgramArg = "version"; | ||
|
||
nativeInstallCheckInputs = [ | ||
versionCheckHook | ||
]; | ||
|
||
meta = { | ||
description = "File list/WebDAV program that supports multiple storages"; | ||
homepage = "https://github.com/alist-org/alist"; | ||
changelog = "https://github.com/alist-org/alist/releases/tag/v${version}"; | ||
license = with lib.licenses; [ | ||
agpl3Only | ||
# alist-web | ||
mit | ||
]; | ||
maintainers = with lib.maintainers; [ moraxyc ]; | ||
sourceProvenance = with lib.sourceTypes; [ | ||
fromSource | ||
# alist-web | ||
binaryBytecode | ||
]; | ||
mainProgram = "alist"; | ||
}; | ||
} |