-
Notifications
You must be signed in to change notification settings - Fork 5
/
flake.nix
138 lines (137 loc) · 4.12 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
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
{
inputs = {
devshell.url = "github:numtide/devshell";
nixos-shell.url = "github:Mic92/nixos-shell";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-22.05";
flake-compat = {
url = "github:edolstra/flake-compat";
flake = false;
};
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixos-shell, nixpkgs, flake-utils, ... }@inputs:
(flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
inputs.devshell.overlay
self.overlays.default
self.overlays.caddy
];
};
in with pkgs; rec {
devShell = devshell.mkShell {
commands = [{
command = "ssh -F ssh_config root@bench";
name = "connect";
} {
command = "nixos-shell --flake '.'";
help = "Run a VM with the NixOS configuration";
name = "vm";
}];
env = [{
name = "QEMU_NET_OPTS";
value = "hostfwd=tcp::8080-:8080,hostfwd=tcp::8081-:8081,hostfwd=tcp::2222-:22";
}];
packages = [
awscli2
caddy
darkhttpd
gnuplot
k6
lighttpd
nixos-shell
nginx
rs
terraform
wrk2
];
};
packages = {
static-html = pkgs.buildEnv {
name = "static-html";
paths = [ ./static ];
};
};
})) // (let
system = "x86_64-linux";
pkgs = import nixpkgs {
inherit system;
overlays = [
self.overlays.default
self.overlays.caddy
];
};
in {
overlays.caddy = prev: final: {
caddySendfile = final.caddy.overrideAttrs (old: {
patches = [
./sendfile.patch
];
});
caddyNoMetrics = final.caddy.overrideAttrs (old: {
patches = [
./no-metrics.patch
];
});
};
overlays.default = prev: final: {
static-html = self.packages.${system}.static-html;
lighttpd = final.lighttpd.override {
enableMagnet = true;
};
};
nixosConfigurations = {
aws-bench-baseline = nixpkgs.lib.nixosSystem {
inherit pkgs system;
modules = [
"${nixpkgs}/nixos/modules/virtualisation/amazon-image.nix"
(import ./base.nix)
(import ./bench.nix)
];
};
aws-bench-no-metrics = nixpkgs.lib.nixosSystem {
inherit pkgs system;
modules = [
"${nixpkgs}/nixos/modules/virtualisation/amazon-image.nix"
(import ./base.nix)
(import ./bench.nix)
(import ./no-metrics.nix)
];
};
aws-bench-sendfile = nixpkgs.lib.nixosSystem {
inherit pkgs system;
modules = [
"${nixpkgs}/nixos/modules/virtualisation/amazon-image.nix"
(import ./base.nix)
(import ./bench.nix)
(import ./sendfile.nix)
];
};
aws-driver = nixpkgs.lib.nixosSystem {
inherit pkgs system;
modules = [
"${nixpkgs}/nixos/modules/virtualisation/amazon-image.nix"
(import ./base.nix)
(import ./driver.nix)
];
};
vm = nixpkgs.lib.makeOverridable nixpkgs.lib.nixosSystem {
inherit pkgs system;
modules = [
nixos-shell.nixosModules.nixos-shell
(import ./base.nix)
(import ./bench.nix)
(import ./no-metrics.nix)
(import ./driver.nix)
({ ... }: {
config.services.getty.autologinUser = nixpkgs.lib.mkDefault "root";
config.nixos-shell.mounts.mountHome = false;
config.nixos-shell.mounts.mountNixProfile = false;
})
];
};
};
});
}