Skip to content

Commit

Permalink
alist: init at 3.38.0 (NixOS#348717)
Browse files Browse the repository at this point in the history
  • Loading branch information
jian-lin authored Nov 13, 2024
2 parents e92d5eb + 8a103a3 commit 9f2d3e2
Showing 1 changed file with 108 additions and 0 deletions.
108 changes: 108 additions & 0 deletions pkgs/by-name/al/alist/package.nix
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";
};
}

0 comments on commit 9f2d3e2

Please sign in to comment.