@cryptotaxi247 / infra-1 / commits / a3988c0f

Add makemake configuration

Eelco Dolstra committed Jan 7, 2020 at 18:07 UTC a3988c0fdef75e5f34e3b967f0ae3022b9151f2a
2 files changed +94
ngi0/hydra/flake.lock new
+11
@@ -0,0 +1,11 @@
1 +{
2 + "inputs": {
3 + "nixpkgs": {
4 + "inputs": {},
5 + "narHash": "sha256-UcPmWgmf7Xgr4Ta8YjLuuxqzLmIYSk+uL2gPy/5bqmk=",
6 + "originalUrl": "nixpkgs/release-19.09",
7 + "url": "github:edolstra/nixpkgs/44603b4103dbce2c9c18e6cc0df51a74f5eb8975"
8 + }
9 + },
10 + "version": 3
11 +}
ngi0/hydra/flake.nix new
+83
@@ -0,0 +1,83 @@
1 +{
2 + edition = 201909;
3 +
4 + inputs.nixpkgs.uri = "nixpkgs/release-19.09";
5 +
6 + outputs = { self, nixpkgs }: {
7 +
8 + nixopsConfigurations.default = {
9 + inherit nixpkgs;
10 +
11 + makemake =
12 + { config, lib, pkgs, ... }:
13 +
14 + {
15 + deployment.targetEnv = "hetzner";
16 + deployment.hetzner.mainIPv4 = "116.202.113.248"; # 2a01:4f8:231:4187::2
17 + deployment.hetzner.createSubAccount = false;
18 +
19 + deployment.hetzner.partitionCommand =
20 + ''
21 + if ! [ -e /usr/local/sbin/zfs ]; then
22 + echo "installing zfs..."
23 + bash -i -c 'echo y | zfsonlinux_install'
24 + fi
25 +
26 + umount -R /mnt || true
27 +
28 + zpool destroy rpool || true
29 +
30 + for disk in /dev/nvme0n1 /dev/nvme1n1; do
31 + echo "partitioning $disk..."
32 + index="''${disk: -3:1}"
33 + parted -s $disk "mklabel msdos"
34 + parted -a optimal -s $disk "mkpart primary ext4 1m 256m"
35 + parted -a optimal -s $disk "mkpart primary zfs 256m 100%"
36 + udevadm settle
37 + mkfs.ext4 -L boot$index ''${disk}p1
38 + done
39 +
40 + echo "creating ZFS pool..."
41 + zpool create -f -o ashift=12 -O atime=off -O compression=lz4 -O xattr=sa -O acltype=posixacl \
42 + rpool mirror /dev/nvme0n1p2 /dev/nvme1n1p2
43 + zfs set mountpoint=legacy rpool
44 +
45 + zfs create -o primarycache=all -o recordsize=16k -o logbias=throughput rpool/root
46 + zfs create -o primarycache=all -o recordsize=16k -o logbias=throughput rpool/postgres
47 + '';
48 +
49 + deployment.hetzner.mountCommand =
50 + ''
51 + mkdir -p /mnt
52 + mount -t zfs rpool/root /mnt
53 + mkdir -p /mnt/postgres
54 + mount -t zfs rpool/postgres /mnt/postgres
55 + mkdir -p /mnt/boot
56 + mount /dev/disk/by-label/boot0 /mnt/boot
57 + '';
58 +
59 + fileSystems."/" =
60 + { device = "rpool/root";
61 + fsType = "zfs";
62 + };
63 +
64 + fileSystems."/boot" =
65 + { device = "/dev/disk/by-label/boot0";
66 + fsType = "ext4";
67 + };
68 +
69 + fileSystems."/postgres" =
70 + { device = "rpool/postgres";
71 + fsType = "zfs";
72 + };
73 +
74 + networking.hostId = "5240310e";
75 +
76 + boot.loader.grub.devices = [ "/dev/nvme0n1" "/dev/nvme1n1" ];
77 + boot.loader.grub.copyKernels = true;
78 + };
79 +
80 + };
81 +
82 + };
83 +}