Initial attempt at new server on nocix
I'm not sure if this will work - I'm running it now - but I want to commit it so I can see what changes I ended up needing after establishing a baseline reading through the nixos-anywhere getting started instructions.
This commit is contained in:
parent
1cd29c96c5
commit
da2947b293
10 changed files with 279 additions and 133 deletions
|
|
@ -1,70 +0,0 @@
|
|||
{ lib, modulesPath, ... }:
|
||||
{
|
||||
imports = [
|
||||
"${modulesPath}/virtualisation/digital-ocean-config.nix"
|
||||
];
|
||||
|
||||
# do not use DHCP, as DigitalOcean provisions IPs using cloud-init
|
||||
networking.useDHCP = lib.mkForce false;
|
||||
|
||||
# Disables all modules that do not work with NixOS
|
||||
services.cloud-init = {
|
||||
enable = true;
|
||||
network.enable = true;
|
||||
settings = {
|
||||
datasource_list = [
|
||||
"ConfigDrive"
|
||||
"Digitalocean"
|
||||
];
|
||||
datasource.ConfigDrive = { };
|
||||
datasource.Digitalocean = { };
|
||||
# Based on https://github.com/canonical/cloud-init/blob/main/config/cloud.cfg.tmpl
|
||||
cloud_init_modules = [
|
||||
"seed_random"
|
||||
"bootcmd"
|
||||
"write_files"
|
||||
"growpart"
|
||||
"resizefs"
|
||||
"set_hostname"
|
||||
"update_hostname"
|
||||
# Not support on NixOS
|
||||
#"update_etc_hosts"
|
||||
# throws error
|
||||
#"users-groups"
|
||||
# tries to edit /etc/ssh/sshd_config
|
||||
#"ssh"
|
||||
"set_password"
|
||||
];
|
||||
cloud_config_modules = [
|
||||
"ssh-import-id"
|
||||
"keyboard"
|
||||
# doesn't work with nixos
|
||||
#"locale"
|
||||
"runcmd"
|
||||
"disable_ec2_metadata"
|
||||
];
|
||||
## The modules that run in the 'final' stage
|
||||
cloud_final_modules = [
|
||||
"write_files_deferred"
|
||||
"puppet"
|
||||
"chef"
|
||||
"ansible"
|
||||
"mcollective"
|
||||
"salt_minion"
|
||||
"reset_rmc"
|
||||
# install dotty agent fails
|
||||
#"scripts_vendor"
|
||||
"scripts_per_once"
|
||||
"scripts_per_boot"
|
||||
# /var/lib/cloud/scripts/per-instance/machine_id.sh has broken shebang
|
||||
#"scripts_per_instance"
|
||||
"scripts_user"
|
||||
"ssh_authkey_fingerprints"
|
||||
"keys_to_console"
|
||||
"install_hotplug"
|
||||
"phone_home"
|
||||
"final_message"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -20,9 +20,4 @@
|
|||
pkgs.dig
|
||||
];
|
||||
|
||||
myModules = {
|
||||
# Disable standard cloud-init, use nixos-anywhere special cloud-init instead
|
||||
cloud-init.enable = false;
|
||||
do-agent.enable = true;
|
||||
};
|
||||
}
|
||||
77
nixos-anywhere/digitalocean/default.nix
Normal file
77
nixos-anywhere/digitalocean/default.nix
Normal file
|
|
@ -0,0 +1,77 @@
|
|||
{ lib, modulesPath, ... }:
|
||||
{
|
||||
imports = [
|
||||
"${modulesPath}/virtualisation/digital-ocean-config.nix"
|
||||
./configuration.nix
|
||||
];
|
||||
|
||||
myModules = {
|
||||
# Disable standard cloud-init, use nixos-anywhere special cloud-init instead
|
||||
cloud-init.enable = false;
|
||||
do-agent.enable = true;
|
||||
};
|
||||
|
||||
# do not use DHCP, as DigitalOcean provisions IPs using cloud-init
|
||||
networking.useDHCP = lib.mkForce false;
|
||||
|
||||
# Disables all modules that do not work with NixOS
|
||||
services.cloud-init = {
|
||||
enable = true;
|
||||
network.enable = true;
|
||||
settings = {
|
||||
datasource_list = [
|
||||
"ConfigDrive"
|
||||
"Digitalocean"
|
||||
];
|
||||
datasource.ConfigDrive = { };
|
||||
datasource.Digitalocean = { };
|
||||
# Based on https://github.com/canonical/cloud-init/blob/main/config/cloud.cfg.tmpl
|
||||
cloud_init_modules = [
|
||||
"seed_random"
|
||||
"bootcmd"
|
||||
"write_files"
|
||||
"growpart"
|
||||
"resizefs"
|
||||
"set_hostname"
|
||||
"update_hostname"
|
||||
# Not support on NixOS
|
||||
#"update_etc_hosts"
|
||||
# throws error
|
||||
#"users-groups"
|
||||
# tries to edit /etc/ssh/sshd_config
|
||||
#"ssh"
|
||||
"set_password"
|
||||
];
|
||||
cloud_config_modules = [
|
||||
"ssh-import-id"
|
||||
"keyboard"
|
||||
# doesn't work with nixos
|
||||
#"locale"
|
||||
"runcmd"
|
||||
"disable_ec2_metadata"
|
||||
];
|
||||
## The modules that run in the 'final' stage
|
||||
cloud_final_modules = [
|
||||
"write_files_deferred"
|
||||
"puppet"
|
||||
"chef"
|
||||
"ansible"
|
||||
"mcollective"
|
||||
"salt_minion"
|
||||
"reset_rmc"
|
||||
# install dotty agent fails
|
||||
#"scripts_vendor"
|
||||
"scripts_per_once"
|
||||
"scripts_per_boot"
|
||||
# /var/lib/cloud/scripts/per-instance/machine_id.sh has broken shebang
|
||||
#"scripts_per_instance"
|
||||
"scripts_user"
|
||||
"ssh_authkey_fingerprints"
|
||||
"keys_to_console"
|
||||
"install_hotplug"
|
||||
"phone_home"
|
||||
"final_message"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
56
nixos-anywhere/digitalocean/disk-config.nix
Normal file
56
nixos-anywhere/digitalocean/disk-config.nix
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
# Example to create a bios compatible gpt partition
|
||||
{ lib, ... }:
|
||||
{
|
||||
disko.devices = {
|
||||
disk.disk1 = {
|
||||
device = lib.mkDefault "/dev/sda";
|
||||
type = "disk";
|
||||
content = {
|
||||
type = "gpt";
|
||||
partitions = {
|
||||
boot = {
|
||||
name = "boot";
|
||||
size = "1M";
|
||||
type = "EF02";
|
||||
};
|
||||
esp = {
|
||||
name = "ESP";
|
||||
size = "500M";
|
||||
type = "EF00";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "vfat";
|
||||
mountpoint = "/boot";
|
||||
};
|
||||
};
|
||||
root = {
|
||||
name = "root";
|
||||
size = "100%";
|
||||
content = {
|
||||
type = "lvm_pv";
|
||||
vg = "pool";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
lvm_vg = {
|
||||
pool = {
|
||||
type = "lvm_vg";
|
||||
lvs = {
|
||||
root = {
|
||||
size = "100%FREE";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "ext4";
|
||||
mountpoint = "/";
|
||||
mountOptions = [
|
||||
"defaults"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -1,56 +0,0 @@
|
|||
# Example to create a bios compatible gpt partition
|
||||
{ lib, ... }:
|
||||
{
|
||||
disko.devices = {
|
||||
disk.disk1 = {
|
||||
device = lib.mkDefault "/dev/sda";
|
||||
type = "disk";
|
||||
content = {
|
||||
type = "gpt";
|
||||
partitions = {
|
||||
boot = {
|
||||
name = "boot";
|
||||
size = "1M";
|
||||
type = "EF02";
|
||||
};
|
||||
esp = {
|
||||
name = "ESP";
|
||||
size = "500M";
|
||||
type = "EF00";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "vfat";
|
||||
mountpoint = "/boot";
|
||||
};
|
||||
};
|
||||
root = {
|
||||
name = "root";
|
||||
size = "100%";
|
||||
content = {
|
||||
type = "lvm_pv";
|
||||
vg = "pool";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
lvm_vg = {
|
||||
pool = {
|
||||
type = "lvm_vg";
|
||||
lvs = {
|
||||
root = {
|
||||
size = "100%FREE";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "ext4";
|
||||
mountpoint = "/";
|
||||
mountOptions = [
|
||||
"defaults"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
@ -42,8 +42,7 @@
|
|||
# tested with 2GB/2CPU droplet, 1GB droplets do not have enough RAM for kexec
|
||||
nixosConfigurations.digitalocean = nixpkgs.lib.nixosSystem {
|
||||
modules = [
|
||||
./configuration.nix
|
||||
./digitalocean.nix
|
||||
./digitalocean
|
||||
disko.nixosModules.disko
|
||||
{ disko.devices.disk.disk1.device = "/dev/vda"; }
|
||||
home-manager.nixosModules.home-manager {
|
||||
|
|
@ -71,5 +70,34 @@
|
|||
};
|
||||
system = "${system}";
|
||||
};
|
||||
nixosConfigurations.nocix = nixpkgs.lib.nixosSystem {
|
||||
modules = [
|
||||
../modules
|
||||
../users
|
||||
./nocix
|
||||
disko.nixosModules.disko
|
||||
home-manager.nixosModules.home-manager {
|
||||
home-manager.extraSpecialArgs = { inherit configFiles; };
|
||||
home-manager.sharedModules = [
|
||||
nixvim.homeManagerModules.nixvim
|
||||
../modules/home/nixvim.nix
|
||||
];
|
||||
home-manager.useGlobalPkgs = true;
|
||||
home-manager.useUserPackages = true;
|
||||
}
|
||||
sops-nix.nixosModules.sops {
|
||||
sops = {
|
||||
age.generateKey = true;
|
||||
age.keyFile = "/var/libs/sops-nix/key.txt";
|
||||
age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
|
||||
defaultSopsFile = ./secrets/secrets.yaml;
|
||||
};
|
||||
}
|
||||
];
|
||||
specialArgs = {
|
||||
inherit configFiles;
|
||||
};
|
||||
system = "${system}";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
36
nixos-anywhere/nocix/configuration.nix
Normal file
36
nixos-anywhere/nocix/configuration.nix
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
{
|
||||
modulesPath,
|
||||
lib,
|
||||
pkgs,
|
||||
...
|
||||
} @ args:
|
||||
{
|
||||
imports = [
|
||||
(modulesPath + "/installer/scan/not-detected.nix")
|
||||
(modulesPath + "/profiles/qemu-guest.nix")
|
||||
./disk-config.nix
|
||||
];
|
||||
boot.loader.grub = {
|
||||
# no need to set devices, disko will add all devices that have a EF02 partition to the list already
|
||||
# devices = [ ];
|
||||
efiSupport = true;
|
||||
efiInstallAsRemovable = true;
|
||||
};
|
||||
environment.systemPackages = map lib.lowPrio [
|
||||
pkgs.dig
|
||||
];
|
||||
networking = {
|
||||
defaultGateway = {
|
||||
address = "107.150.59.201";
|
||||
interface = "enp2s0";
|
||||
};
|
||||
interfaces.enp2s0 = {
|
||||
ipv4.addresses = [{
|
||||
address = "107.150.59.202";
|
||||
prefixLength = 29;
|
||||
}];
|
||||
};
|
||||
nameservers = ["192.187.107.16"];
|
||||
search = ["nocix.net"];
|
||||
};
|
||||
}
|
||||
6
nixos-anywhere/nocix/default.nix
Normal file
6
nixos-anywhere/nocix/default.nix
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
imports = [
|
||||
./configuration.nix
|
||||
./hardware-configuration.nix
|
||||
];
|
||||
}
|
||||
56
nixos-anywhere/nocix/disk-config.nix
Normal file
56
nixos-anywhere/nocix/disk-config.nix
Normal file
|
|
@ -0,0 +1,56 @@
|
|||
# Example to create a bios compatible gpt partition
|
||||
{ lib, ... }:
|
||||
{
|
||||
disko.devices = {
|
||||
disk.disk1 = {
|
||||
device = lib.mkDefault "/dev/sda";
|
||||
type = "disk";
|
||||
content = {
|
||||
type = "gpt";
|
||||
partitions = {
|
||||
boot = {
|
||||
name = "boot";
|
||||
size = "1M";
|
||||
type = "EF02";
|
||||
};
|
||||
esp = {
|
||||
name = "ESP";
|
||||
size = "500M";
|
||||
type = "EF00";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "vfat";
|
||||
mountpoint = "/boot";
|
||||
};
|
||||
};
|
||||
root = {
|
||||
name = "root";
|
||||
size = "100%";
|
||||
content = {
|
||||
type = "lvm_pv";
|
||||
vg = "pool";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
lvm_vg = {
|
||||
pool = {
|
||||
type = "lvm_vg";
|
||||
lvs = {
|
||||
root = {
|
||||
size = "100%FREE";
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "ext4";
|
||||
mountpoint = "/";
|
||||
mountOptions = [
|
||||
"defaults"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
18
nixos-anywhere/nocix/hardware-configuration.nix
Normal file
18
nixos-anywhere/nocix/hardware-configuration.nix
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
# Do not modify this file! It was generated by ‘nixos-generate-config’
|
||||
# and may be overwritten by future invocations. Please make changes
|
||||
# to /etc/nixos/configuration.nix instead.
|
||||
{ config, lib, pkgs, modulesPath, ... }:
|
||||
|
||||
{
|
||||
imports =
|
||||
[ (modulesPath + "/installer/scan/not-detected.nix")
|
||||
];
|
||||
|
||||
boot.initrd.availableKernelModules = [ "ahci" "ohci_pci" "ehci_pci" "xhci_pci" "sd_mod" ];
|
||||
boot.initrd.kernelModules = [ ];
|
||||
boot.kernelModules = [ "kvm-amd" ];
|
||||
boot.extraModulePackages = [ ];
|
||||
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
hardware.cpu.amd.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue