nixpkgs mirror (for testing)
github.com/NixOS/nixpkgs
nix
1{
2 lib,
3 stdenv,
4 buildGoModule,
5 fetchFromGitHub,
6 callPackage,
7 installShellFiles,
8 versionCheckHook,
9 fuse,
10}:
11
12buildGoModule (finalAttrs: {
13 pname = "openlist";
14 version = "4.0.9";
15
16 src = fetchFromGitHub {
17 owner = "OpenListTeam";
18 repo = "OpenList";
19 tag = "v${finalAttrs.version}";
20 hash = "sha256-RsTcaq5w5EY+zddjTI5BJuDqmbFmZwxq4ng9NUXZvIk=";
21 # populate values that require us to use git. By doing this in postFetch we
22 # can delete .git afterwards and maintain better reproducibility of the src.
23 leaveDotGit = true;
24 postFetch = ''
25 cd "$out"
26 git rev-parse HEAD > $out/COMMIT
27 # '0000-00-00T00:00:00Z'
28 date -u -d "@$(git log -1 --pretty=%ct)" "+%Y-%m-%dT%H:%M:%SZ" > $out/SOURCE_DATE_EPOCH
29 find "$out" -name .git -print0 | xargs -0 rm -rf
30 '';
31 };
32
33 frontend = callPackage ./frontend.nix { };
34
35 proxyVendor = true;
36 vendorHash = "sha256-zDN2sw3oYVDTlP5qqe+RkcZ2Lup/vlB4jnluiA/wLLU=";
37
38 buildInputs = [ fuse ];
39
40 tags = [ "jsoniter" ];
41
42 ldflags = [
43 "-s"
44 "-X \"github.com/OpenListTeam/OpenList/v4/internal/conf.GitAuthor=The OpenList Projects Contributors <noreply@openlist.team>\""
45 "-X github.com/OpenListTeam/OpenList/v4/internal/conf.Version=${finalAttrs.version}"
46 "-X github.com/OpenListTeam/OpenList/v4/internal/conf.WebVersion=${finalAttrs.frontend.version}"
47 ];
48
49 preConfigure = ''
50 rm -rf public/dist
51 cp -r ${finalAttrs.frontend} public/dist
52 '';
53
54 preBuild = ''
55 ldflags+=" -X \"github.com/OpenListTeam/OpenList/v4/internal/conf.BuiltAt=$(<SOURCE_DATE_EPOCH)\""
56 ldflags+=" -X github.com/OpenListTeam/OpenList/v4/internal/conf.GitCommit=$(<COMMIT)"
57 '';
58
59 checkFlags =
60 let
61 # Skip tests that require network access
62 skippedTests = [
63 "TestHTTPAll"
64 "TestWebsocketAll"
65 "TestWebsocketCaller"
66 "TestDownloadOrder"
67 ];
68 in
69 [ "-skip=^${builtins.concatStringsSep "$|^" skippedTests}$" ];
70
71 nativeBuildInputs = [ installShellFiles ];
72
73 postInstall = lib.optionalString (stdenv.buildPlatform.canExecute stdenv.hostPlatform) ''
74 installShellCompletion --cmd OpenList \
75 --bash <($out/bin/OpenList completion bash) \
76 --fish <($out/bin/OpenList completion fish) \
77 --zsh <($out/bin/OpenList completion zsh)
78
79 mkdir $out/share/powershell/ -p
80 $out/bin/OpenList completion powershell > $out/share/powershell/OpenList.Completion.ps1
81 '';
82
83 doInstallCheck = true;
84 nativeInstallCheckInputs = [ versionCheckHook ];
85 versionCheckProgram = "${placeholder "out"}/bin/OpenList";
86 versionCheckProgramArg = "version";
87
88 passthru.updateScript = lib.getExe (callPackage ./update.nix { });
89
90 meta = {
91 description = "AList Fork to Anti Trust Crisis";
92 homepage = "https://github.com/OpenListTeam/OpenList";
93 license = lib.licenses.agpl3Only;
94 maintainers = with lib.maintainers; [ moraxyc ];
95 mainProgram = "OpenList";
96 };
97})