forked from NixOS/nixpkgs
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpackage.nix
More file actions
114 lines (99 loc) · 3.09 KB
/
Copy pathpackage.nix
File metadata and controls
114 lines (99 loc) · 3.09 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
{
lib,
buildGoModule,
fetchFromGitHub,
fetchzip,
fuse,
stdenv,
installShellFiles,
versionCheckHook,
callPackage,
}:
buildGoModule rec {
pname = "alist";
version = "3.45.0";
webVersion = "3.45.0";
src = fetchFromGitHub {
owner = "AlistGo";
repo = "alist";
tag = "v${version}";
hash = "sha256-h8oWeTX3z3xye5O4+s7LA7Wm36JOrsU+UdKGZXaDKXk=";
# 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 = fetchzip {
url = "https://github.com/AlistGo/alist-web/releases/download/${webVersion}/dist.tar.gz";
hash = "sha256-rNVa+dr/SX2aYHBzeV8QdD5XYCFyelhbqkTpvhF+S2g=";
};
proxyVendor = true;
vendorHash = "sha256-IMoLVAgOaVM1xIFDe8BGOpzyBnDMfD9Q6VogFfOWFzU=";
buildInputs = [ fuse ];
tags = [ "jsoniter" ];
ldflags = [
"-s"
"-w"
"-X \"github.com/alist-org/alist/v3/internal/conf.GitAuthor=Xhofe <i@nn.ci>\""
"-X github.com/alist-org/alist/v3/internal/conf.Version=${version}"
"-X github.com/alist-org/alist/v3/internal/conf.WebVersion=${webVersion}"
];
preConfigure = ''
rm -rf public/dist
cp -r ${web} public/dist
'';
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"
"TestDownloadOrder"
];
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
];
passthru = {
updateScript = lib.getExe (callPackage ./update.nix { });
};
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";
};
}