-
-
Notifications
You must be signed in to change notification settings - Fork 14
/
flake.nix
81 lines (76 loc) · 2.7 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
{
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
inputs.disko.url = "github:nix-community/disko";
inputs.disko.inputs.nixpkgs.follows = "nixpkgs";
inputs.nixos-facter-modules.url = "github:numtide/nixos-facter-modules";
outputs =
{
nixpkgs,
disko,
nixos-facter-modules,
...
}:
{
nixosConfigurations.hetzner-cloud = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
disko.nixosModules.disko
./configuration.nix
];
};
# tested with 2GB/2CPU droplet, 1GB droplets do not have enough RAM for kexec
nixosConfigurations.digitalocean = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
disko.nixosModules.disko
{ disko.devices.disk.disk1.device = "/dev/vda"; }
{
# do not use DHCP, as DigitalOcean provisions IPs using cloud-init
networking.useDHCP = nixpkgs.lib.mkForce false;
services.cloud-init = {
enable = true;
network.enable = true;
# not strictly needed, just for good measure
datasource_list = [ "DigitalOcean" ];
datasource.DigitalOcean = { };
};
}
./configuration.nix
];
};
nixosConfigurations.hetzner-cloud-aarch64 = nixpkgs.lib.nixosSystem {
system = "aarch64-linux";
modules = [
disko.nixosModules.disko
./configuration.nix
];
};
# Use this for all other targets
# nixos-anywhere --flake .#generic-nixos-facter --generate-hardware-config nixos-generate-config ./hardware-configuration.nix <hostname>
nixosConfigurations.generic = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
disko.nixosModules.disko
./configuration.nix
./hardware-configuration.nix
];
};
# Slightly experimental: Like generic, but with nixos-facter (https://github.com/numtide/nixos-facter)
# nixos-anywhere --flake .#generic-nixos-facter --generate-hardware-config nixos-facter facter.json <hostname>
nixosConfigurations.generic-nixos-facter = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
disko.nixosModules.disko
./configuration.nix
nixos-facter-modules.nixosModules.facter
{
config.facter.reportPath =
if builtins.pathExists ./facter.json then
./facter.json
else
throw "Have you forgotten to run nixos-anywhere with `--generate-hardware-config nixos-facter ./facter.json`?";
}
];
};
};
}