-
Notifications
You must be signed in to change notification settings - Fork 1
/
upgrade.nix
152 lines (129 loc) · 4.92 KB
/
upgrade.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
import ./make-test.nix (pkgs: {
name = "nextcloud-upgrade";
nodes = let
common = { options, pkgs, ... }: {
nextcloud.enable = true;
nextcloud.domain = "localhost";
services.nginx.enable = true;
services.postgresql.enable = true;
systemd.services.postgresql.environment = {
LD_PRELOAD = "${pkgs.libeatmydata}/lib/libeatmydata.so";
};
environment.systemPackages = [ pkgs.jq ];
virtualisation.memorySize = 1024;
};
in {
generation1 = { lib, options, config, pkgs, ... }: {
imports = [ common ];
nextcloud.majorVersion = 18;
nextcloud.apps = let
nc18apps = (lib.importJSON ../packages/18/upstream.json).applications;
excludedApps = [
# We'll need dpendency ordering for this app
"auto_mail_accounts"
# Needs Perl
"camerarawpreviews"
# Needs /usr/bin/clamscan
"files_antivirus"
# Broken upgrade routine across major versions
"files_external_dropbox"
# Upstream URL very unstable
"files_external_gdrive"
# Needs PHP's inotify extension
"files_inotify"
# Needs the OAuth library
"grauphel"
# Only works with MyQSL
"sensorlogger"
# Windows only (at least it seems)
"sharepoint"
# Seems to be incompatible with PostgreSQL
"twofactor_admin"
# Needs "user_backend_sql_raw" in config
"user_backend_sql_raw"
# Needs write access to to "apps/cms_pico/appdata_public/".
"cms_pico"
# No OCC support, since it requires $_SERVER['REQUEST_URI']
"sendent"
# XXX: Currently (2019-12-12) results in HTTP 404
"emlviewer"
# XXX: Conflicts with the "news" app - investigate this someday.
"files_mindmap"
# XXX: Requires pdlib and thus module system integration for PHP
# extensions.
"facerecognition"
# These apps have non-deterministic download URLs
"occweb"
"quicknotes"
"spgverein"
"twainwebscan"
"twofactor_yubikey"
# Will be enabled later
"spreed"
"richdocuments"
];
enableApp = name: let
isExcluded = lib.elem name excludedApps;
in lib.const (lib.optionalAttrs (!isExcluded) {
enable = true;
});
in lib.mapAttrs enableApp nc18apps;
};
generation2 = { lib, nodes, ... }: {
imports = [ common ];
systemd.services.libreoffice-online.enable = false;
systemd.services.mongooseim.enable = false;
nextcloud.apps = lib.genAttrs [
"apporder" "bookmarks" "calendar" "circles" "contacts" "deck"
"external" "end_to_end_encryption" "files_accesscontrol"
"files_markdown" "files_rightclick" "gpxpod" "groupfolders" "mail"
"metadata" "news" "passwords" "polls" "phonetrack" "richdocuments"
"social" "spreed" "tasks"
] (lib.const { enable = true; });
};
};
testScript = { nodes, ... }: let
switchToGeneration = gen: let
node = "generation${toString gen}";
inherit (nodes.${node}.config.system.build) toplevel;
switchCmd = "${toplevel}/bin/switch-to-configuration test";
in ''
$machine->nest('switch to generation ${toString gen}', sub {
$machine->succeed('${switchCmd} >&2');
$main::machine = ''$${node};
});
'';
expectedAppsPerlHash = let
inherit (pkgs.lib) attrNames filterAttrs const escape;
inherit (nodes.generation2.config.nextcloud) apps;
alwaysEnabled = [
"cloud_federation_api" "dav" "federatedfilesharing" "files"
"lookup_server_connector" "oauth2" "provisioning_api" "settings"
"twofactor_backupcodes" "viewer" "workflowengine"
];
enabled = attrNames (filterAttrs (const (x: x.enable)) apps);
allEnabled = enabled ++ alwaysEnabled;
mkHash = val: "'${escape ["\\" "'"] val}' => 1";
in "(${pkgs.lib.concatMapStringsSep ", " mkHash allEnabled})";
in ''
my $machine = $generation1;
$machine->waitForUnit('multi-user.target');
$machine->startJob('nextcloud.service');
$machine->waitForUnit('nextcloud.service');
$machine->succeed(
'curl -L http://localhost/ | grep -o "a safe home for all your data"'
);
${switchToGeneration 2}
$machine->startJob('nextcloud.service');
$machine->waitForUnit('nextcloud.service');
$machine->succeed(
'curl -L http://localhost/ | grep -o initial-state-core-loginUsername'
);
my $applist = $machine->succeed('nextcloud-occ app:list --output=json'
.' | jq -r ".enabled | keys[] | @text"');
my %expected = ${expectedAppsPerlHash};
my %actual = map { $_ => 1 } split "\n", $applist;
use Test::More tests => 1;
is_deeply(\%actual, \%expected, 'enabled apps should match with config');
'';
})