blob: d648429f5dc0c59f74f718a9ce8f2493195be9e4 (
plain) (
blame)
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
|
{
pkgs,
extraModules,
vhack,
...
}:
vhack.runTest {
name = "sharkey-cpu";
nodes = {
server = {config, ...}: {
imports =
extraModules
++ [
../../../../modules
];
vhack = {
persist.enable = true;
nginx.enable = true;
sharkey = {
enable = true;
fqdn = "sharkey.server";
};
};
systemd.services = {
# Avoid an error from this service.
"acme-sharkey.server".enable = false;
# Test that sharkey's hardening still allows access to the CPUs.
sharkey.serviceConfig.ExecStart = let
nodejs = pkgs.lib.getExe pkgs.nodejs;
script = pkgs.writeTextFile {
name = "script.js";
text =
# js
''
import * as os from 'node:os';
var cpus = os.cpus()
if (cpus.length != 0) {
console.log(cpus[0].model)
} else {
// Fail?
}
while (true) {
}
'';
};
in
pkgs.lib.mkForce "${nodejs} ${script}";
};
};
};
services = [
{server = "sharkey.service";}
];
testScript = {...}:
# Python
''
from time import sleep
# Give the service time to run.
sleep(3)
'';
}
|