2023-10-30 19:03:16 +08:00
|
|
|
# This is your system's configuration file.
|
|
|
|
# Use this to configure your system environment (it replaces /etc/nixos/configuration.nix)
|
|
|
|
{
|
|
|
|
inputs,
|
|
|
|
outputs,
|
|
|
|
lib,
|
|
|
|
config,
|
|
|
|
pkgs,
|
|
|
|
...
|
|
|
|
}: {
|
|
|
|
# You can import other NixOS modules here
|
|
|
|
imports = [
|
|
|
|
# If you want to use modules your own flake exports (from modules/nixos):
|
|
|
|
# outputs.nixosModules.example
|
2023-11-05 22:14:06 +08:00
|
|
|
outputs.nixosModules.qbittorrent
|
2023-10-30 19:03:16 +08:00
|
|
|
|
|
|
|
# Or modules from other flakes (such as nixos-hardware):
|
|
|
|
|
|
|
|
# You can also split up your configuration and import pieces of it here:
|
|
|
|
# ./users.nix
|
|
|
|
|
2023-10-31 05:46:44 +08:00
|
|
|
# Import common configurations
|
|
|
|
../common/system-tools.nix
|
|
|
|
|
2023-12-19 09:46:53 +08:00
|
|
|
# Import containers
|
|
|
|
./containers/dashboard
|
|
|
|
./containers/microbin
|
|
|
|
./containers/multimedia
|
|
|
|
|
|
|
|
# Import services
|
|
|
|
./services/adguardhome
|
2024-01-01 07:23:46 +08:00
|
|
|
./services/borgbackup
|
2023-12-19 09:46:53 +08:00
|
|
|
./services/home-assistant
|
|
|
|
./services/minecraft-server
|
|
|
|
./services/traefik
|
2023-10-31 05:46:44 +08:00
|
|
|
|
2023-10-30 19:03:16 +08:00
|
|
|
# Import your generated (nixos-generate-config) hardware configuration
|
|
|
|
./hardware-configuration.nix
|
|
|
|
];
|
|
|
|
|
2023-11-20 06:38:12 +08:00
|
|
|
age.secrets.wireguard = {
|
|
|
|
# Private key for wireguard
|
|
|
|
file = inputs.self + /secrets/wireguard.age;
|
|
|
|
owner = "root";
|
|
|
|
group = "root";
|
|
|
|
};
|
|
|
|
|
2023-10-30 19:03:16 +08:00
|
|
|
nixpkgs = {
|
|
|
|
# You can add overlays here
|
|
|
|
overlays = [
|
|
|
|
# Add overlays your own flake exports (from overlays and pkgs dir):
|
|
|
|
outputs.overlays.additions
|
|
|
|
outputs.overlays.modifications
|
|
|
|
outputs.overlays.unstable-packages
|
|
|
|
|
|
|
|
# You can also add overlays exported from other flakes:
|
|
|
|
# neovim-nightly-overlay.overlays.default
|
|
|
|
|
|
|
|
# Or define it inline, for example:
|
|
|
|
# (final: prev: {
|
|
|
|
# hi = final.hello.overrideAttrs (oldAttrs: {
|
|
|
|
# patches = [ ./change-hello-to-hi.patch ];
|
|
|
|
# });
|
|
|
|
# })
|
|
|
|
];
|
|
|
|
# Configure your nixpkgs instance
|
|
|
|
config = {
|
|
|
|
# Disable if you don't want unfree packages
|
|
|
|
allowUnfree = true;
|
2023-11-07 07:53:17 +08:00
|
|
|
packageOverrides = pkgs: {
|
|
|
|
# enable vaapi on OS-level
|
|
|
|
vaapiIntel = pkgs.vaapiIntel.override { enableHybridCodec = true; };
|
|
|
|
};
|
2023-10-30 19:03:16 +08:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
nix = {
|
2023-10-31 05:46:44 +08:00
|
|
|
gc = {
|
|
|
|
# Automatically run the garbage collector an a specified time.
|
|
|
|
automatic = true;
|
|
|
|
dates = "weekly";
|
|
|
|
options = "--delete-older-than 30d";
|
|
|
|
};
|
|
|
|
|
2023-10-30 19:03:16 +08:00
|
|
|
# This will add each flake input as a registry
|
|
|
|
# To make nix3 commands consistent with your flake
|
|
|
|
registry = lib.mapAttrs (_: value: {flake = value;}) inputs;
|
|
|
|
|
|
|
|
# This will additionally add your inputs to the system's legacy channels
|
|
|
|
# Making legacy nix commands consistent as well, awesome!
|
|
|
|
nixPath = lib.mapAttrsToList (key: value: "${key}=${value.to.path}") config.nix.registry;
|
|
|
|
|
|
|
|
settings = {
|
|
|
|
# Enable flakes and new 'nix' command
|
|
|
|
experimental-features = "nix-command flakes";
|
|
|
|
# Deduplicate and optimize nix store
|
|
|
|
auto-optimise-store = true;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-12-01 05:39:38 +08:00
|
|
|
# Select internationalisation properties
|
2023-11-20 12:05:51 +08:00
|
|
|
i18n.defaultLocale = "en_AU.UTF-8";
|
|
|
|
# Set timezone
|
|
|
|
time.timeZone = "Australia/Perth";
|
|
|
|
|
2023-11-07 07:53:50 +08:00
|
|
|
boot = {
|
|
|
|
loader = {
|
|
|
|
systemd-boot.enable = true;
|
|
|
|
efi = {
|
|
|
|
canTouchEfiVariables = true;
|
|
|
|
efiSysMountPoint = "/boot/efi";
|
|
|
|
};
|
|
|
|
};
|
|
|
|
kernel.sysctl = {
|
|
|
|
# Allow listening on TCP & UDP ports below 1024
|
|
|
|
"net.ipv4.ip_unprivileged_port_start" = 0;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2023-11-07 07:53:17 +08:00
|
|
|
hardware.opengl = {
|
|
|
|
enable = true;
|
|
|
|
extraPackages = with pkgs; [
|
|
|
|
intel-media-driver
|
|
|
|
vaapiIntel
|
|
|
|
vaapiVdpau
|
|
|
|
libvdpau-va-gl
|
|
|
|
intel-compute-runtime # OpenCL filter support (hardware tonemapping and subtitle burn-in)
|
|
|
|
];
|
|
|
|
};
|
|
|
|
|
2023-10-31 05:46:44 +08:00
|
|
|
networking = {
|
|
|
|
hostName = "viridian";
|
|
|
|
domain = "kanto.dev";
|
|
|
|
networkmanager.enable = true;
|
2023-11-20 06:38:12 +08:00
|
|
|
# Required for wireguard
|
|
|
|
nat = {
|
|
|
|
enable = true;
|
|
|
|
externalInterface = "wlp2s0";
|
|
|
|
internalInterfaces = [ "wg0" ];
|
|
|
|
};
|
|
|
|
# Setup our firewall
|
2023-10-31 05:46:44 +08:00
|
|
|
firewall = {
|
|
|
|
enable = true;
|
|
|
|
allowedTCPPorts = [
|
2023-11-05 22:14:06 +08:00
|
|
|
53 # adguardhome (DNS)
|
2023-10-31 05:46:44 +08:00
|
|
|
80 # traefik (HTTP)
|
|
|
|
443 # traefik (HTTPS)
|
|
|
|
32372 # qbittorrent
|
|
|
|
];
|
|
|
|
allowedUDPPorts = [
|
2023-11-05 22:14:06 +08:00
|
|
|
53 # adguardhome (DNS)
|
2023-10-31 05:46:44 +08:00
|
|
|
80 # traefik (HTTP)
|
|
|
|
443 # traefik (HTTPS)
|
|
|
|
32372 # qbittorrent
|
2023-11-20 06:38:12 +08:00
|
|
|
51820 # Wireguard
|
2023-10-31 05:46:44 +08:00
|
|
|
];
|
|
|
|
};
|
2023-12-01 05:39:38 +08:00
|
|
|
|
|
|
|
# Setup our Home network VPN
|
2023-11-20 06:38:12 +08:00
|
|
|
wireguard.interfaces = {
|
|
|
|
wg0 = {
|
|
|
|
# IP address and subnet of the server's end of the tunnel interface
|
|
|
|
ips = [ "10.100.0.1/24" ];
|
|
|
|
listenPort = 51820;
|
|
|
|
# This allows the wireguard server to route your traffic to the internet and hence be like a VPN
|
|
|
|
# For this to work you have to set the dnsserver IP of your router (or dnsserver of choice) in your clients
|
|
|
|
postSetup = ''
|
|
|
|
${pkgs.iptables}/bin/iptables -t nat -A POSTROUTING -s 10.100.0.0/24 -o wlp2s0 -j MASQUERADE
|
|
|
|
'';
|
|
|
|
# This undoes the above command
|
|
|
|
postShutdown = ''
|
|
|
|
${pkgs.iptables}/bin/iptables -t nat -D POSTROUTING -s 10.100.0.0/24 -o wlp2s0 -j MASQUERADE
|
|
|
|
'';
|
|
|
|
# Path to the private key file.
|
|
|
|
privateKeyFile = config.age.secrets.wireguard.path;
|
|
|
|
peers = [
|
|
|
|
{ # Pixel 6 Pro
|
|
|
|
publicKey = "VaXMnFAXdbJCllNY5sIjPp9AcSM7ap2oA0tU9SIMK3E=";
|
|
|
|
# List of IPs assigned to this peer within the tunnel subnet.
|
|
|
|
allowedIPs = [ "10.100.0.2/32" ];
|
|
|
|
}
|
|
|
|
{ # Samsung S23 Ultra
|
|
|
|
publicKey = "dL91i7+VDWfeLCOr53JlzQ32WJ3lRJGqdecoqUpEnlQ=";
|
|
|
|
allowedIPs = [ "10.100.0.3/32" ];
|
|
|
|
}
|
|
|
|
];
|
|
|
|
};
|
|
|
|
};
|
2023-10-31 05:46:44 +08:00
|
|
|
};
|
2023-10-30 19:03:16 +08:00
|
|
|
|
2023-11-05 22:14:06 +08:00
|
|
|
# Setup environment
|
|
|
|
environment = {
|
|
|
|
# Symlink /bin/sh to POSIX-Complient shell
|
|
|
|
binsh = "${pkgs.bash}/bin/bash";
|
|
|
|
shells = with pkgs; [ zsh ];
|
|
|
|
|
|
|
|
# Install packages, prefix with 'unstable.' to use overlay
|
|
|
|
systemPackages = with pkgs; [
|
2024-01-14 06:29:18 +08:00
|
|
|
agenix.packages."${system}".default
|
2023-11-05 22:14:06 +08:00
|
|
|
];
|
|
|
|
};
|
|
|
|
programs = {
|
|
|
|
zsh.enable = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
services = {
|
|
|
|
# This setups a SSH server. Very important if you're setting up a headless system.
|
|
|
|
# Feel free to remove if you don't need it.
|
|
|
|
openssh = {
|
|
|
|
enable = true;
|
|
|
|
# Forbid root login through SSH.
|
|
|
|
settings.PermitRootLogin = "no";
|
|
|
|
# Use keys only. Remove if you want to SSH using password (not recommended)
|
|
|
|
settings.PasswordAuthentication = false;
|
|
|
|
};
|
2023-10-30 19:03:16 +08:00
|
|
|
};
|
|
|
|
|
2023-11-09 18:49:20 +08:00
|
|
|
# Virtualisation
|
|
|
|
virtualisation.docker.enable = true;
|
|
|
|
|
2023-11-05 22:14:06 +08:00
|
|
|
# Configure your system-wide user settings (groups, etc), add more users as needed.
|
|
|
|
users = {
|
|
|
|
users = {
|
|
|
|
# System administator
|
|
|
|
sabrina = {
|
|
|
|
isNormalUser = true;
|
2023-11-09 18:49:20 +08:00
|
|
|
extraGroups = [ "networkmanager" "wheel" "media" "docker" ];
|
2023-11-05 23:39:49 +08:00
|
|
|
openssh.authorizedKeys.keyFiles = [
|
2023-11-06 17:35:06 +08:00
|
|
|
../../home-manager/sajenim/id_ed25519_sk.pub
|
2023-11-05 23:39:49 +08:00
|
|
|
];
|
2023-11-05 22:14:06 +08:00
|
|
|
shell = pkgs.zsh;
|
|
|
|
};
|
|
|
|
};
|
2023-10-30 19:03:16 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
# https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion
|
|
|
|
system.stateVersion = "23.05";
|
|
|
|
}
|
|
|
|
|