2023-02-18 15:24:54 +00:00
|
|
|
# The Swan
|
|
|
|
# System configuration for my home NAS server
|
|
|
|
|
2024-04-13 13:03:44 +00:00
|
|
|
{
|
|
|
|
inputs,
|
|
|
|
globals,
|
|
|
|
overlays,
|
|
|
|
...
|
|
|
|
}:
|
2023-02-18 15:24:54 +00:00
|
|
|
|
2024-06-19 16:51:16 +00:00
|
|
|
inputs.nixpkgs.lib.nixosSystem rec {
|
2023-02-18 15:24:54 +00:00
|
|
|
system = "x86_64-linux";
|
2024-06-19 16:51:16 +00:00
|
|
|
specialArgs = {
|
2024-08-18 22:23:13 +00:00
|
|
|
pkgs-stable = import inputs.nixpkgs-stable { inherit system; };
|
2024-06-19 16:51:16 +00:00
|
|
|
pkgs-caddy = import inputs.nixpkgs-caddy { inherit system; };
|
|
|
|
};
|
2023-02-18 15:24:54 +00:00
|
|
|
modules = [
|
2023-03-20 03:36:15 +00:00
|
|
|
globals
|
2023-07-02 02:22:03 +00:00
|
|
|
inputs.home-manager.nixosModules.home-manager
|
|
|
|
inputs.disko.nixosModules.disko
|
2023-06-03 15:12:04 +00:00
|
|
|
../../modules/common
|
|
|
|
../../modules/nixos
|
2023-02-18 15:24:54 +00:00
|
|
|
{
|
2023-08-05 21:14:26 +00:00
|
|
|
nixpkgs.overlays = overlays;
|
|
|
|
|
2023-07-01 21:33:24 +00:00
|
|
|
# Hardware
|
2023-02-18 15:24:54 +00:00
|
|
|
server = true;
|
2023-07-17 15:38:08 +00:00
|
|
|
physical = true;
|
2023-02-27 02:50:24 +00:00
|
|
|
networking.hostName = "swan";
|
|
|
|
|
2023-08-05 21:14:26 +00:00
|
|
|
# Not sure what's necessary but too afraid to remove anything
|
2024-04-13 13:03:44 +00:00
|
|
|
boot.initrd.availableKernelModules = [
|
|
|
|
"xhci_pci"
|
|
|
|
"ahci"
|
|
|
|
"nvme"
|
|
|
|
"usb_storage"
|
|
|
|
"sd_mod"
|
|
|
|
];
|
2023-07-01 21:33:24 +00:00
|
|
|
|
|
|
|
# Required for transcoding
|
2023-06-04 16:14:11 +00:00
|
|
|
boot.initrd.kernelModules = [ "amdgpu" ];
|
2023-06-18 14:28:02 +00:00
|
|
|
boot.kernelParams = [
|
|
|
|
"radeon.si_support=0"
|
|
|
|
"amdgpu.si_support=1"
|
|
|
|
"radeon.cik_support=0"
|
|
|
|
"amdgpu.cik_support=1"
|
|
|
|
"amdgpu.dc=1"
|
|
|
|
];
|
2023-08-05 21:14:26 +00:00
|
|
|
|
|
|
|
# Required binary blobs to boot on this machine
|
2023-06-04 16:14:11 +00:00
|
|
|
hardware.enableRedistributableFirmware = true;
|
2023-07-01 21:33:24 +00:00
|
|
|
|
2023-08-05 21:14:26 +00:00
|
|
|
# Prioritize efficiency over performance
|
2023-06-03 15:12:04 +00:00
|
|
|
powerManagement.cpuFreqGovernor = "powersave";
|
2023-08-05 21:14:26 +00:00
|
|
|
|
|
|
|
# Allow firmware updates
|
2023-06-03 15:12:04 +00:00
|
|
|
hardware.cpu.intel.updateMicrocode = true;
|
2023-02-26 13:23:31 +00:00
|
|
|
|
2023-06-03 15:12:04 +00:00
|
|
|
# ZFS
|
2023-02-27 02:50:24 +00:00
|
|
|
zfs.enable = true;
|
2023-07-01 21:33:24 +00:00
|
|
|
# Generated with: head -c 8 /etc/machine-id
|
2023-06-03 15:12:04 +00:00
|
|
|
networking.hostId = "600279f4"; # Random ID required for ZFS
|
2023-08-05 21:14:26 +00:00
|
|
|
|
|
|
|
# Sets root ext4 filesystem instead of declaring it manually
|
2023-02-27 00:53:51 +00:00
|
|
|
disko = {
|
|
|
|
enableConfig = true;
|
2023-02-27 01:49:46 +00:00
|
|
|
devices = (import ../../disks/root.nix { disk = "/dev/nvme0n1"; });
|
2023-02-27 00:53:51 +00:00
|
|
|
};
|
2023-08-05 21:14:26 +00:00
|
|
|
|
2024-10-12 15:18:54 +00:00
|
|
|
zramSwap.enable = true;
|
|
|
|
swapDevices = [
|
|
|
|
{
|
|
|
|
device = "/swapfile";
|
|
|
|
size = 4 * 1024; # 4 GB
|
|
|
|
}
|
|
|
|
];
|
|
|
|
|
2024-03-04 13:01:07 +00:00
|
|
|
boot.zfs = {
|
|
|
|
# Automatically load the ZFS pool on boot
|
|
|
|
extraPools = [ "tank" ];
|
|
|
|
# Only try to decrypt datasets with keyfiles
|
2024-04-13 13:03:44 +00:00
|
|
|
requestEncryptionCredentials = [
|
|
|
|
"tank/archive"
|
|
|
|
"tank/generic"
|
|
|
|
"tank/nextcloud"
|
2024-04-14 04:07:04 +00:00
|
|
|
"tank/generic/git"
|
2024-04-13 13:03:44 +00:00
|
|
|
];
|
2024-03-04 13:01:07 +00:00
|
|
|
# If password is requested and fails, continue to boot eventually
|
|
|
|
passwordTimeout = 300;
|
|
|
|
};
|
2023-02-26 13:23:31 +00:00
|
|
|
|
2023-08-05 21:14:26 +00:00
|
|
|
# Theming
|
|
|
|
|
|
|
|
# Server doesn't require GUI
|
2023-02-18 15:24:54 +00:00
|
|
|
gui.enable = false;
|
2023-08-05 21:14:26 +00:00
|
|
|
|
|
|
|
# Still require colors for programs like Neovim, K9S
|
2024-04-13 13:03:44 +00:00
|
|
|
theme = {
|
2024-04-14 04:07:04 +00:00
|
|
|
colors = (import ../../colorscheme/gruvbox-dark).dark;
|
2024-04-13 13:03:44 +00:00
|
|
|
};
|
2023-08-05 21:14:26 +00:00
|
|
|
|
|
|
|
# Programs and services
|
2024-01-21 14:42:46 +00:00
|
|
|
atuin.enable = true;
|
2023-02-27 02:50:24 +00:00
|
|
|
neovim.enable = true;
|
2023-04-16 20:59:52 +00:00
|
|
|
cloudflare.enable = true;
|
2023-07-01 21:33:24 +00:00
|
|
|
dotfiles.enable = true;
|
2023-07-04 22:20:43 +00:00
|
|
|
arrs.enable = true;
|
2024-08-25 21:56:28 +00:00
|
|
|
filebrowser.enable = true;
|
2024-10-12 15:18:54 +00:00
|
|
|
services.audiobookshelf.enable = true;
|
2023-07-18 03:52:37 +00:00
|
|
|
services.bind.enable = true;
|
2023-07-04 22:20:43 +00:00
|
|
|
services.caddy.enable = true;
|
|
|
|
services.jellyfin.enable = true;
|
|
|
|
services.nextcloud.enable = true;
|
|
|
|
services.calibre-web.enable = true;
|
2023-07-13 03:33:35 +00:00
|
|
|
services.openssh.enable = true;
|
2023-07-16 13:50:58 +00:00
|
|
|
services.prometheus.enable = false;
|
|
|
|
services.vmagent.enable = true;
|
2023-07-04 22:20:43 +00:00
|
|
|
services.samba.enable = true;
|
2023-11-10 03:37:34 +00:00
|
|
|
services.paperless.enable = true;
|
2024-01-17 00:58:01 +00:00
|
|
|
services.postgresql.enable = true;
|
2024-06-19 16:58:47 +00:00
|
|
|
system.autoUpgrade.enable = false;
|
2023-02-18 15:24:54 +00:00
|
|
|
|
2023-08-05 21:14:26 +00:00
|
|
|
# Allows private remote access over the internet
|
2023-06-19 12:30:30 +00:00
|
|
|
cloudflareTunnel = {
|
|
|
|
enable = true;
|
|
|
|
id = "646754ac-2149-4a58-b51a-e1d0a1f3ade2";
|
|
|
|
credentialsFile = ../../private/cloudflared-swan.age;
|
2024-04-13 13:03:44 +00:00
|
|
|
ca = "ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBCHF/UMtJqPFrf6f6GRY0ZFnkCW7b6sYgUTjTtNfRj1RdmNic1NoJZql7y6BrqQinZvy7nsr1UFDNWoHn6ah3tg= open-ssh-ca@cloudflareaccess.org";
|
2023-06-19 12:30:30 +00:00
|
|
|
};
|
|
|
|
|
2023-08-05 21:14:26 +00:00
|
|
|
# Send regular backups and litestream for DBs to an S3-like bucket
|
2023-02-28 02:02:45 +00:00
|
|
|
backup.s3 = {
|
|
|
|
endpoint = "s3.us-west-002.backblazeb2.com";
|
|
|
|
bucket = "noahmasur-backup";
|
|
|
|
accessKeyId = "0026b0e73b2e2c80000000005";
|
|
|
|
};
|
|
|
|
|
2023-02-18 15:24:54 +00:00
|
|
|
# Disable passwords, only use SSH key
|
2024-03-24 17:16:20 +00:00
|
|
|
publicKeys = [
|
|
|
|
"ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIB+AbmjGEwITk5CK9y7+Rg27Fokgj9QEjgc9wST6MA3s personal"
|
|
|
|
];
|
2023-02-18 15:24:54 +00:00
|
|
|
}
|
|
|
|
];
|
|
|
|
}
|