-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
83 lines (74 loc) · 2.41 KB
/
flake.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
{
inputs = {
typhon.url = "github:typhon-ci/typhon";
nixpkgs.follows = "typhon/nixpkgs";
};
outputs = {
self,
typhon,
nixpkgs,
}: let
configuration = {pkgs, ...}: {
imports = [
typhon.nixosModules.default
"${nixpkgs}/nixos/modules/virtualisation/qemu-vm.nix"
];
virtualisation = {
diskSize = 2048;
memorySize = 2048;
};
nix = {
package = pkgs.nixVersions.nix_2_18;
settings.experimental-features = ["nix-command" "flakes"];
};
services.typhon = {
enable = true;
hashedPasswordFile = builtins.toString (pkgs.runCommand "password" {} ''
echo -n "password" | ${pkgs.libargon2}/bin/argon2 "Guérande" -id -e > $out
'');
};
users.users.root = {
initialPassword = "root";
packages = [
(pkgs.writeShellApplication {
name = "stress";
runtimeInputs = [pkgs.jq];
text = let
curl = "curl -sf -H 'password: password'";
in ''
api="http://localhost:3000/api"
${curl} --json '{"flake": true, "url": "github:typhon-ci/stress"}' "$api/projects/stress/create"
${curl} -X POST "$api/projects/stress/refresh"
while [ "$(${curl} "$api/projects/stress" | jq '.last_refresh.Success')" == "null" ]
do
sleep 1
done
${curl} -X POST "$api/projects/stress/update_jobsets"
while [ "$(${curl} "$api/projects/stress" | jq '.jobsets | length')" == "0" ]
do
sleep 1
done
jobsets=$(${curl} "$api/projects/stress" | jq -r '.jobsets | .[] | @uri')
for jobset in $jobsets
do
${curl} -X POST "$api/projects/stress/jobsets/$jobset/evaluate"
done
'';
})
];
};
};
system = "x86_64-linux";
vm = (import "${nixpkgs}/nixos" {inherit configuration system;}).vm;
pkgs = import nixpkgs {inherit system;};
in {
packages.${system}.default = pkgs.writeShellScriptBin "run" ''
QEMU_KERNEL_PARAMS=console=ttyS0 ${vm}/bin/run-nixos-vm -nographic; reset
'';
typhonProject = typhon.lib.builders.mkProject {
actions.jobsets = typhon.lib.git.mkJobsets {
url = "https://github.com/typhon-ci/typhon";
};
};
};
}