forked from nix-community/nixos-generators
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlinode.nix
99 lines (83 loc) · 2.18 KB
/
linode.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
{
config,
lib,
pkgs,
modulesPath,
...
}: {
imports = [
"${toString modulesPath}/profiles/qemu-guest.nix"
];
formatAttr = "linode";
fileExtension = ".img.gz";
system.build.linode = import "${toString modulesPath}/../lib/make-disk-image.nix" {
inherit lib config pkgs;
partitionTableType = "none";
format = "raw";
postVM = ''
${pkgs.pigz}/bin/pigz -9 $out/nixos.img
'';
};
# Set up filesystems according to Linode preference:
fileSystems."/" = {
device = "/dev/sda";
fsType = "ext4";
autoResize = true;
};
swapDevices = [{device = "/dev/sdb";}];
# Enable LISH and Linode booting w/ GRUB
boot = {
# Add kernel modules detected by nixos-generate-config:
initrd.availableKernelModules = [
"virtio_pci"
"virtio_scsi"
"ahci"
"sd_mod"
];
growPartition = true;
# Set up LISH serial connection:
kernelParams = ["console=ttyS0,19200n8"];
loader = {
# Increase timeout to allow LISH connection:
timeout = lib.mkForce 10;
grub = {
enable = true;
forceInstall = true;
device = "nodev";
fsIdentifier = "label";
# Allow serial connection for GRUB to be able to use LISH:
extraConfig = ''
serial --speed=19200 --unit=0 --word=8 --parity=no --stop=1;
terminal_input serial;
terminal_output serial
'';
# Link /boot/grub2 to /boot/grub:
extraInstallCommands = ''
${pkgs.coreutils}/bin/ln -fs /boot/grub /boot/grub2
'';
# Remove GRUB splash image:
splashImage = null;
};
};
};
# Hardware option detected by nixos-generate-config:
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
# Install diagnostic tools for Linode support:
environment.systemPackages = with pkgs; [
inetutils
mtr
sysstat
linode-cli
];
networking = {
enableIPv6 = true;
tempAddresses = "disabled";
useDHCP = true;
usePredictableInterfaceNames = false;
interfaces.eth0 = {
tempAddress = "disabled";
useDHCP = true;
};
};
services.qemuGuest.enable = true;
}