mirror of
https://github.com/olexsmir/dotfiles.git
synced 2026-01-15 08:41:34 +02:00
nix: add vps setup
This commit is contained in:
parent
028a52d9ff
commit
4240620b6b
13 changed files with 498 additions and 0 deletions
74
nix/hosts/thought/configuration.nix
Normal file
74
nix/hosts/thought/configuration.nix
Normal file
|
|
@ -0,0 +1,74 @@
|
|||
{ pkgs, ... }:
|
||||
{
|
||||
imports = [
|
||||
./disko-config.nix
|
||||
./hardware-configuration.nix
|
||||
];
|
||||
|
||||
system.stateVersion = "24.05";
|
||||
|
||||
swapDevices = [
|
||||
{
|
||||
device = "/swapfile";
|
||||
size = 2048; # MB
|
||||
}
|
||||
];
|
||||
|
||||
boot.loader.grub = {
|
||||
efiSupport = true;
|
||||
efiInstallAsRemovable = true;
|
||||
};
|
||||
|
||||
time.timeZone = "Europe/Kyiv";
|
||||
i18n.defaultLocale = "en_US.UTF-8";
|
||||
|
||||
networking = {
|
||||
hostName = "vps";
|
||||
useDHCP = true;
|
||||
# Interface names will be auto-detected in hardware-configuration.nix
|
||||
# Using generic DHCP setting
|
||||
interfaces = { };
|
||||
firewall = {
|
||||
enable = true;
|
||||
allowedTCPPorts = [
|
||||
80
|
||||
443
|
||||
];
|
||||
};
|
||||
};
|
||||
|
||||
environment.systemPackages = with pkgs; [
|
||||
neovim
|
||||
git
|
||||
htop
|
||||
tmux
|
||||
];
|
||||
|
||||
age.identityPaths = [ "/keys.txt" ]; # TODO: i dont like that i overwrites literally everything
|
||||
|
||||
services = {
|
||||
caddy.enable = true;
|
||||
openssh = {
|
||||
enable = true;
|
||||
settings = {
|
||||
PasswordAuthentication = false;
|
||||
PermitRootLogin = "no";
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
nix = {
|
||||
gc = {
|
||||
automatic = true;
|
||||
dates = "weekly";
|
||||
options = "--delete-older-than 30d";
|
||||
};
|
||||
settings = {
|
||||
auto-optimise-store = true;
|
||||
experimental-features = [
|
||||
"nix-command"
|
||||
"flakes"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
11
nix/hosts/thought/default.nix
Normal file
11
nix/hosts/thought/default.nix
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
{ ... }:
|
||||
{
|
||||
imports = [
|
||||
./digitalocean.nix
|
||||
./configuration.nix
|
||||
./hardware-configuration.nix
|
||||
|
||||
../../users/q.nix
|
||||
../../modules/forgejo.nix
|
||||
];
|
||||
}
|
||||
70
nix/hosts/thought/digitalocean.nix
Normal file
70
nix/hosts/thought/digitalocean.nix
Normal file
|
|
@ -0,0 +1,70 @@
|
|||
{ 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"
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
55
nix/hosts/thought/disko-config.nix
Normal file
55
nix/hosts/thought/disko-config.nix
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
{ lib, ... }:
|
||||
{
|
||||
disko.devices = {
|
||||
disk.disk1 = {
|
||||
device = lib.mkDefault "/dev/vda";
|
||||
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"
|
||||
];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
25
nix/hosts/thought/hardware-configuration.nix
Normal file
25
nix/hosts/thought/hardware-configuration.nix
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
# 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 + "/profiles/qemu-guest.nix")
|
||||
];
|
||||
|
||||
boot.initrd.availableKernelModules = [ "ata_piix" "uhci_hcd" "virtio_pci" "virtio_scsi" "virtio_blk" ];
|
||||
boot.initrd.kernelModules = [ ];
|
||||
boot.kernelModules = [ "kvm-intel" ];
|
||||
boot.extraModulePackages = [ ];
|
||||
|
||||
# Enables DHCP on each ethernet and wireless interface. In case of scripted networking
|
||||
# (the default) this is the recommended approach. When using systemd-networkd it's
|
||||
# still possible to use this option, but it's recommended to use it in conjunction
|
||||
# with explicit per-interface declarations with `networking.interfaces.<interface>.useDHCP`.
|
||||
networking.useDHCP = lib.mkDefault true;
|
||||
# networking.interfaces.ens3.useDHCP = lib.mkDefault true;
|
||||
# networking.interfaces.ens4.useDHCP = lib.mkDefault true;
|
||||
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue