1{
2 lib,
3 callPackage,
4 buildGoModule,
5 fetchFromGitHub,
6 ncurses,
7 gettext,
8 pigeon,
9 go-mockery,
10 protoc-go-inject-tag,
11 libxcrypt,
12 vips,
13 pkg-config,
14 nixosTests,
15 nix-update-script,
16 versionCheckHook,
17}:
18
19let
20 bingoBinsMakefile = builtins.concatStringsSep "\n" (
21 lib.mapAttrsToList (n: v: "${n} := ${v}\n\\$(${n}):") {
22 GO_XGETTEXT = "xgettext";
23 MOCKERY = "mockery";
24 PIGEON = "pigeon";
25 PROTOC_GO_INJECT_TAG = "protoc-go-inject-tag";
26 }
27 );
28in
29buildGoModule rec {
30 pname = "opencloud";
31 version = "3.5.0";
32
33 src = fetchFromGitHub {
34 owner = "opencloud-eu";
35 repo = "opencloud";
36 tag = "v${version}";
37 hash = "sha256-NPBz9pevjDUqDrEg/S6Vtk+jAA9f2H95ehO8EgcB1eY=";
38 };
39
40 postPatch = ''
41 echo "${bingoBinsMakefile}" >.bingo/Variables.mk
42
43 # tries to build web assets, done separately
44 substituteInPlace services/idp/Makefile \
45 --replace-fail 'node-generate-prod: assets' 'node-generate-prod:'
46 # tries to download something web assets ..
47 substituteInPlace services/web/Makefile \
48 --replace-fail 'node-generate-prod: download-assets' 'node-generate-prod:'
49
50 # tries to build some random binaries off the internet and
51 # no need to build protobuf bindings anyway, as they are in-repo already
52 sed -i -e '/\$(BINGO) get/d' -e '/\$(BUF) generate/d' .make/protobuf.mk
53 '';
54
55 vendorHash = null;
56
57 preConfigure = ''
58 export HOME=$(mktemp -d)
59 make generate
60 '';
61
62 ldflags = [
63 "-s"
64 "-w"
65 "-X"
66 "github.com/opencloud-eu/opencloud/pkg/version.String=nixos"
67 "-X"
68 "github.com/opencloud-eu/opencloud/pkg/version.Tag=${version}"
69 "-X"
70 "github.com/opencloud-eu/opencloud/pkg/version.Date=19700101"
71 ];
72
73 tags = [ "enable_vips" ];
74
75 nativeBuildInputs = [
76 ncurses
77 gettext
78 pigeon
79 go-mockery
80 protoc-go-inject-tag
81 pkg-config
82 ];
83
84 buildInputs = [
85 libxcrypt
86 vips
87 ];
88
89 # wants testcontainers and docker, and we don't have a good way to skip tests
90 # based on package name and not test name
91 preCheck = ''
92 rm services/search/pkg/opensearch/*_test.go
93 '';
94
95 env = {
96 # avoids 'make generate' calling `git`, otherwise no-op
97 STRING = version;
98 VERSION = version;
99 };
100
101 excludedPackages = [ "tests/*" ];
102
103 passthru = {
104 web = callPackage ./web.nix { };
105 idp-web = callPackage ./idp-web.nix { };
106 tests = { inherit (nixosTests) opencloud; };
107 updateScript = nix-update-script { };
108 };
109
110 doInstallCheck = true;
111 nativeInstallCheckInputs = [ versionCheckHook ];
112 versionCheckProgramArg = [ "version" ];
113
114 meta = {
115 description = "OpenCloud gives you a secure and private way to store, access, and share your files";
116 homepage = "https://github.com/opencloud-eu/opencloud";
117 changelog = "https://github.com/opencloud-eu/opencloud/blob/${src.tag}/CHANGELOG.md";
118 license = lib.licenses.asl20;
119 maintainers = with lib.maintainers; [
120 christoph-heiss
121 k900
122 ];
123 mainProgram = "opencloud";
124 };
125}