-
Notifications
You must be signed in to change notification settings - Fork 1
/
vm-nextcloud.nix
233 lines (219 loc) · 5.98 KB
/
vm-nextcloud.nix
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
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
{ pkgs, config, lib, options, ... }: {
virtualisation = {
memorySize = 8000;
cores = 4;
};
imports = [
./nextcloud-extras.nix
];
nixpkgs = {
overlays = [
(self: super: {
# Remove first run wizard and password policy check from Nextcloud
# package
nextcloud29 = super.nextcloud29.overrideAttrs (oldAttrs: rec {
installPhase = oldAttrs.installPhase + ''
mkdir -p $out/
cp -R . $out/
rm -r $out/apps/firstrunwizard
rm -r $out/apps/password_policy
'';
dontBuild = true;
});
})
];
};
# Setup Nextcloud including apps
services.nextcloud = {
enable = true;
package = pkgs.nextcloud29;
hostName = "localhost";
extraApps = with config.services.nextcloud.package.packages.apps; {
inherit contacts calendar user_oidc;
# FIXME
# enable hmr when debug flag is enabled
hmr_enabler = pkgs.php.buildComposerProject (finalAttrs: {
pname = "hmr_enabler";
version = "1.0.0";
src = pkgs.fetchFromGitHub {
owner = "nextcloud";
repo = "hmr_enabler";
rev = "b8d3ad290bfa6fe407280587181a5167d71a2617";
hash = "sha256-yXFby5zlDiPdrw6HchmBoUdu9Zjfgp/bSu0G/isRpKg=";
};
composerNoDev = false;
vendorHash = "sha256-PCWWu/SqTUGnZXUnXyL8c72p8L14ZUqIxoa5i49XPH4=";
postInstall = ''
cp -r $out/share/php/hmr_enabler/* $out/
rm -r $out/share
'';
});
};
extraAppsEnable = true;
config = {
adminuser = "admin";
adminpassFile = "${pkgs.writeText "adminpass" "test123"}";
};
ensureUsers = {
admin = {
email = "admin@localhost";
passwordFile = "${pkgs.writeText "password" "test123"}";
};
user1 = {
email = "user1@localhost";
passwordFile = "${pkgs.writeText "password" "test123"}";
};
user2 = {
email = "user2@localhost";
passwordFile = "${pkgs.writeText "password" "test123"}";
};
};
phpPackage = lib.mkForce (pkgs.php.buildEnv {
extensions = ({ enabled, all }: enabled ++ (with all; [
xdebug
]));
});
phpOptions = {
"xdebug.mode" = "debug";
"xdebug.client_host" = "10.0.2.2";
"xdebug.client_port" = "9000";
"xdebug.start_with_request" = "yes";
"xdebug.idekey" = "ECLIPSE";
};
appstoreEnable = true;
configureRedis = true;
extraOCCCommands = ''
${config.services.nextcloud.occ}/bin/nextcloud-occ app:enable cleanup
'';
settings = {
log_type = "file";
loglevel = 1;
mail_smtpmode = "sendmail";
mail_sendmailmode = "pipe";
trusted_domains = [ "10.100.100.1" ];
"integrity.check.disabled" = true;
debug = true;
# Required to allow insecure connection to KeyCloak on localhost
allow_local_remote_servers = true;
#apps_paths = [
# {
# path = "/var/lib/nextcloud/server/apps";
# url = "/apps";
# writable = false;
# }
#];
};
};
nixos-shell.mounts.extraMounts = {
"/var/lib/nextcloud/store-apps/cleanup" = {
target = /home/onny/projects/nixos-nextcloud-testumgebung/cleanup;
cache = "none";
};
"/var/lib/nextcloud/store-apps/files_mindmap2" = {
target = /home/onny/projects/nixos-nextcloud-testumgebung/files_mindmap2;
cache = "none";
};
#"/var/lib/nextcloud/server" = {
# target = /home/onny/projects/nixos-nextcloud-testumgebung/server;
# cache = "none";
#};
};
#services.nginx.virtualHosts."localhost".root = lib.mkForce "/var/lib/nextcloud/server";
# Setup mail server
services.stalwart-mail = {
enable = true;
# FIXME remove package definition in 24.11
package = pkgs.stalwart-mail;
settings = {
tracer.stdout = {
type = "stdout";
level = "debug";
enable = true;
ansi = true;
};
server = {
hostname = "localhost";
tls.enable = false;
listener = {
"smtp-submission" = {
bind = [ "[::]:587" ];
protocol = "smtp";
};
"imap" = {
bind = [ "[::]:143" ];
protocol = "imap";
};
};
};
imap.auth.allow-plain-text = true;
session.auth = {
mechanisms = "[plain, login]";
directory = "'in-memory'";
};
storage.directory = "in-memory";
session.rcpt.directory = "'in-memory'";
queue.outbound.next-hop = "'local'";
directory."in-memory" = {
type = "memory";
principals = [
{
class = "individual";
name = "user1";
secret = "test123";
email = [ "user1@localhost" ];
}
{
class = "individual";
name = "user2";
secret = "test123";
email = [ "user2@localhost" ];
}
{
class = "individual";
name = "admin";
secret = "test123";
email = [ "admin@localhost" ];
}
];
};
};
};
# Configure local mail delivery
programs.msmtp = {
enable = true;
accounts.default = {
host = "localhost";
port = 587;
auth = "login";
tls = "off";
from = "admin@localhost";
user = "admin";
password = "test123";
};
};
# How to setup https://www.schiessle.org/articles/2023/07/04/nextcloud-and-openid-connect/
services.keycloak = {
enable = true;
settings = {
hostname = "localhost";
http-enabled = true;
http-port = 8081;
hostname-strict-https = false;
};
database.passwordFile = "${pkgs.writeText "dbPassword" ''test123''}";
};
system.stateVersion = "24.05";
environment.systemPackages = with pkgs; [
litecli
sqldiff
unzip
wget
tmux
];
services.getty.autologinUser = "root";
documentation = {
info.enable = false;
man.enable = false;
nixos.enable = false;
};
}