-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
85 lines (76 loc) · 2.67 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
{
description = "Flake for skarabox.";
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
skarabox.url = "github:ibizaman/skarabox";
skarabox.inputs.nixpkgs.follows = "nixpkgs";
deploy-rs.url = "github:serokell/deploy-rs";
sops-nix.url = "github:Mic92/sops-nix";
};
outputs = { self, nixpkgs, skarabox, sops-nix, deploy-rs }:
let
system = "x86_64-linux";
pkgs = import nixpkgs { inherit system; };
# Taken from https://github.com/serokell/deploy-rs?tab=readme-ov-file#overall-usage
deployPkgs = import nixpkgs {
inherit system;
overlays = [
deploy-rs.overlay
(self: super: { deploy-rs = { inherit (pkgs) deploy-rs; lib = super.deploy-rs.lib; }; })
];
};
ip = "<replace me>";
in
{
nixosModules.skarabox = {
imports = [
skarabox.nixosModules.skarabox
sops-nix.nixosModules.default
({ config, ... }: {
skarabox.hostname = "skarabox";
skarabox.username = "skarabox";
skarabox.disks.rootDisk = "/dev/nvme0n1";
# 10% of size SSD
skarabox.disks.rootReservation = "100G";
skarabox.disks.dataDisk1 = "/dev/sda";
skarabox.disks.dataDisk2 = "/dev/sdb";
# 5% of size Hard Drives
skarabox.disks.dataReservation = "500G";
skarabox.sshAuthorizedKeyFile = ./ssh_skarabox.pub;
skarabox.hostId = builtins.readFile ./hostid;
# Needed to be able to ssh to decrypt the SSD.
boot.initrd.availableKernelModules = [
"rtw88_8821ce"
"r8169"
];
sops.defaultSopsFile = ./secrets.yaml;
sops.age = {
sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
};
})
./configuration.nix
];
};
# Used with nixos-anywere for installation.
nixosConfigurations.skarabox = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
self.nixosModules.skarabox
];
};
# Used with deploy-rs for updates.
deploy.nodes.skarabox = {
hostname = ip;
sshUser = "skarabox";
sshOpts = [ "-o" "IdentitiesOnly=yes" "-i" "ssh_skarabox" ];
profiles = {
system = {
user = "root";
path = deployPkgs.deploy-rs.lib.activate.nixos self.nixosConfigurations.skarabox;
};
};
};
# From https://github.com/serokell/deploy-rs?tab=readme-ov-file#overall-usage
checks = builtins.mapAttrs (system: deployLib: deployLib.deployChecks self.deploy) deploy-rs.lib;
};
}