dotfiles.nix/nixos/viridian/configuration.nix

257 lines
6.5 KiB
Nix
Raw Normal View History

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):
2023-11-05 22:14:06 +08:00
inputs.agenix.nixosModules.default
2023-10-30 19:03:16 +08:00
# 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-11-05 22:14:06 +08:00
# Import services
./services/traefik
./services/media-stack
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
];
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;
};
};
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-10-31 05:46:44 +08:00
networking = {
hostName = "viridian";
domain = "kanto.dev";
networkmanager.enable = true;
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)
2023-11-06 17:35:06 +08:00
5624 # sajenim.dev (HTTPD)
2023-10-31 05:46:44 +08:00
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)
2023-11-06 17:35:06 +08:00
5624 # sajenim.dev (HTTPD)
2023-10-31 05:46:44 +08:00
32372 # qbittorrent
];
};
};
2023-10-30 19:03:16 +08:00
2023-11-05 22:14:06 +08:00
boot = {
loader = {
systemd-boot.enable = true;
efi = {
2023-10-30 19:03:16 +08:00
canTouchEfiVariables = true;
efiSysMountPoint = "/boot/efi";
2023-11-05 22:14:06 +08:00
};
};
kernel.sysctl = {
# Allow listening on TCP & UDP ports below 1024
"net.ipv4.ip_unprivileged_port_start" = 0;
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; [
inputs.agenix.packages."${system}".default
];
};
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-11-06 17:35:06 +08:00
# Web server
httpd = {
enable = true;
adminAddr = "its.jassy@pm.me";
virtualHosts."sajenim.dev" = {
documentRoot = "/var/www/sajenim.dev";
listen = [{
ip = "192.168.1.102";
port = 5624;
ssl = false;
}];
};
};
2023-11-05 22:14:06 +08:00
# Privacy protection center
adguardhome = {
enable = true;
openFirewall = true;
settings = {
# Web interface IP address to listen on.
bind_port = 3000;
# Web interface IP port to listen on.
bind_host = "0.0.0.0";
# Custom DNS responses
dns.rewrites = [
{ domain = "kanto.dev";
answer = "192.168.1.102";
}
{ domain = "*.kanto.dev";
answer = "kanto.dev";
}
];
};
};
2023-10-31 05:46:44 +08:00
2023-11-05 22:14:06 +08:00
# Home automation that puts local control and privacy first.
home-assistant = {
enable = true;
openFirewall = true;
extraComponents = [
# Components required to complete the onboarding
"esphome"
"met"
"radio_browser"
"adguard"
"jellyfin"
];
config = {
# Includes dependencies for a basic setup
# https://www.home-assistant.io/integrations/defaultoconfig/
default_config = {};
http = {
use_x_forwarded_for = true;
trusted_proxies = [
"192.168.1.102"
];
};
};
configDir = "/var/lib/home-assistant";
};
# Sandbox game developed by Mojang Studios
minecraft-server = {
enable = true;
2023-11-06 17:35:06 +08:00
package = pkgs.unstable.minecraft-server;
2023-11-05 22:14:06 +08:00
openFirewall = true;
dataDir = "/var/lib/minecraft";
declarative = true;
serverProperties = {
gamemode = "survival";
2023-11-06 17:35:06 +08:00
level-name = "kanto.dev";
2023-11-05 22:14:06 +08:00
difficulty = "easy";
2023-11-06 17:35:06 +08:00
server-port = 25565;
motd = "Welcome to our little private place!";
2023-11-05 22:14:06 +08:00
};
eula = true;
2023-10-30 19:03:16 +08:00
};
};
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;
extraGroups = [ "networkmanager" "wheel" "media" ];
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;
};
};
# Additional groups to create.
groups = {
media.members = [
"jellyfin"
"sonarr"
"radarr"
"lidarr"
"qbittorrent"
];
};
2023-10-30 19:03:16 +08:00
};
# https://nixos.wiki/wiki/FAQ/When_do_I_update_stateVersion
system.stateVersion = "23.05";
}