refactor: gigantic refactor
This commit is contained in:
1 parent
d1e2bde503
commit
0474f7bbb4
50 files changed
+232
-207
No files matched your search
@@ -0,0 +1,30 @@
|
||||
{
|
||||
self,
|
||||
inputs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
inherit (inputs.nixpkgs.lib) nixosSystem;
|
||||
|
||||
specialArgs = { inherit inputs self; };
|
||||
|
||||
mkNixosSystem =
|
||||
modules:
|
||||
nixosSystem {
|
||||
inherit specialArgs;
|
||||
modules = modules ++ [
|
||||
../system
|
||||
../options.nix
|
||||
inputs.home-manager.nixosModules.home-manager
|
||||
{
|
||||
home-manager.useGlobalPkgs = true;
|
||||
home-manager.useUserPackages = true;
|
||||
home-manager.users.leonhard = ../home/default.nix;
|
||||
}
|
||||
];
|
||||
};
|
||||
in
|
||||
{
|
||||
desktop = mkNixosSystem [ ./desktop ];
|
||||
server = mkNixosSystem [ ./server ];
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
{
|
||||
imports = [
|
||||
./hardware-configuration.nix
|
||||
];
|
||||
|
||||
# Enable CUPS to print documents.
|
||||
#services.printing.enable = true;
|
||||
|
||||
# Enable firmware
|
||||
#hardware.enableAllFirmware = true;
|
||||
|
||||
# Enable bluetooth
|
||||
#hardware.bluetooth.enable = true;
|
||||
|
||||
# Enable sound with pipewire.
|
||||
# security.rtkit.enable = true;
|
||||
# services.pipewire = {
|
||||
# enable = true;
|
||||
# alsa.enable = true;
|
||||
# alsa.support32Bit = true;
|
||||
# pulse.enable = true;
|
||||
# };
|
||||
|
||||
users.users = {
|
||||
leonhard = {
|
||||
initialPassword = "leonhard";
|
||||
isNormalUser = true;
|
||||
extraGroups = [ "wheel" ];
|
||||
};
|
||||
};
|
||||
|
||||
networking.hostName = "desktop";
|
||||
}
|
||||
@@ -0,0 +1,44 @@
|
||||
{
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
imports = [ ];
|
||||
|
||||
boot.initrd.availableKernelModules = [
|
||||
"sd_mod"
|
||||
"sr_mod"
|
||||
];
|
||||
boot.initrd.kernelModules = [ ];
|
||||
boot.kernelModules = [ ];
|
||||
boot.extraModulePackages = [ ];
|
||||
|
||||
fileSystems."/" = {
|
||||
device = "/dev/disk/by-label/nixos";
|
||||
fsType = "ext4";
|
||||
};
|
||||
|
||||
fileSystems."/boot" = {
|
||||
device = "/dev/disk/by-label/boot";
|
||||
fsType = "vfat";
|
||||
options = [
|
||||
"fmask=0077"
|
||||
"dmask=0077"
|
||||
];
|
||||
};
|
||||
|
||||
swapDevices = [
|
||||
{ device = "/dev/disk/by-label/swap"; }
|
||||
];
|
||||
|
||||
# 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.eth0.useDHCP = lib.mkDefault true;
|
||||
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
virtualisation.hypervGuest.enable = true;
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
...
|
||||
}:
|
||||
{
|
||||
imports = [
|
||||
./hardware-configuration.nix
|
||||
./secrets
|
||||
./dyndns
|
||||
./gitea.nix
|
||||
./vaultwarden.nix
|
||||
];
|
||||
|
||||
options.nix-leonhard.domain =
|
||||
with lib.types;
|
||||
lib.mkOption {
|
||||
type = str;
|
||||
default = "";
|
||||
description = "Domain of the device.";
|
||||
};
|
||||
|
||||
nix-leonhard.graphical = false;
|
||||
|
||||
users.users.leonhard = {
|
||||
initialPassword = "leonhard";
|
||||
isNormalUser = true;
|
||||
extraGroups = [ "wheel" ];
|
||||
openssh.authorizedKeys.keys = config.nix-leonhard.publicKeys;
|
||||
};
|
||||
|
||||
networking = {
|
||||
hostName = "server";
|
||||
firewall.enable = false;
|
||||
interfaces.eno1 = {
|
||||
ipv4.addresses = [
|
||||
{
|
||||
address = "192.168.178.210";
|
||||
prefixLength = 24;
|
||||
}
|
||||
];
|
||||
};
|
||||
defaultGateway = {
|
||||
address = "192.168.178.1";
|
||||
interface = "eno1";
|
||||
};
|
||||
nameservers = [
|
||||
"1.1.1.1"
|
||||
"8.8.8.8"
|
||||
];
|
||||
};
|
||||
|
||||
services.openssh = {
|
||||
enable = true;
|
||||
ports = [ 5432 ];
|
||||
settings = {
|
||||
PasswordAuthentication = false;
|
||||
KbdInteractiveAuthentication = false;
|
||||
PermitRootLogin = "no";
|
||||
};
|
||||
};
|
||||
|
||||
security.acme = {
|
||||
acceptTerms = true;
|
||||
defaults.email = "admin@${config.nix-leonhard.domain}";
|
||||
defaults.webroot = "/var/lib/acme/acme-challenge/";
|
||||
certs.${config.nix-leonhard.domain} = {
|
||||
group = config.services.nginx.group;
|
||||
};
|
||||
};
|
||||
|
||||
services.nginx = {
|
||||
enable = true;
|
||||
|
||||
virtualHosts.${config.nix-leonhard.domain} = {
|
||||
forceSSL = true;
|
||||
useACMEHost = config.nix-leonhard.domain;
|
||||
locations."/.well-known/".root = config.security.acme.defaults.webroot;
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
pyenv = pkgs.python3.withPackages (ps: with ps; [ nc-dnsapi ]);
|
||||
in
|
||||
{
|
||||
users.groups.dyndns = { };
|
||||
users.users.dyndns = {
|
||||
isSystemUser = true;
|
||||
group = "dyndns";
|
||||
description = "DynDNS service user";
|
||||
};
|
||||
|
||||
systemd.timers."dyndns" = {
|
||||
requires = [ "network-online.target" ];
|
||||
wantedBy = [ "timers.target" ];
|
||||
timerConfig = {
|
||||
OnBootSec = "5m";
|
||||
OnUnitActiveSec = "5m";
|
||||
Unit = "dyndns.service";
|
||||
};
|
||||
};
|
||||
|
||||
systemd.services."dyndns" = {
|
||||
serviceConfig = {
|
||||
Type = "oneshot";
|
||||
User = "dyndns";
|
||||
ExecStart = "${pyenv.interpreter} ${./dyndns.py}";
|
||||
EnvironmentFile = config.sops.secrets.dyndns.path;
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,27 @@
|
||||
from nc_dnsapi import Client
|
||||
import os, urllib3
|
||||
|
||||
CUSTOMER = os.environ["NC_CUSTOMER"]
|
||||
API_PASSWORD = os.environ["NC_API_PASSWORD"]
|
||||
API_KEY = os.environ["NC_API_KEY"]
|
||||
DOMAIN = os.environ["NC_DOMAIN"]
|
||||
|
||||
ip = urllib3.request("GET", "https://api.ipify.org").data.decode()
|
||||
|
||||
with Client(CUSTOMER, API_KEY, API_PASSWORD) as api:
|
||||
to_be_updated = []
|
||||
records = api.dns_records(DOMAIN)
|
||||
|
||||
for record in records:
|
||||
if record.type in ["A", "AAAA"] and record.destination != ip:
|
||||
record.destination = ip
|
||||
to_be_updated.append(record)
|
||||
|
||||
|
||||
if to_be_updated:
|
||||
api.update_dns_records(DOMAIN, to_be_updated)
|
||||
|
||||
zone = api.dns_zone(DOMAIN)
|
||||
if zone.ttl != '300':
|
||||
zone.ttl = '300'
|
||||
api.update_dns_zone(DOMAIN, zone)
|
||||
@@ -0,0 +1,34 @@
|
||||
{
|
||||
config,
|
||||
...
|
||||
}:
|
||||
let
|
||||
domain = config.nix-leonhard.domain;
|
||||
gitDomain = "git.${domain}";
|
||||
in
|
||||
{
|
||||
services.gitea = {
|
||||
enable = true;
|
||||
settings.server.ROOT_URL = "https://${gitDomain}";
|
||||
settings.server.SSH_PORT = builtins.elemAt config.services.openssh.ports 0;
|
||||
settings.service.DISABLE_REGISTRATION = true;
|
||||
settings.log.LEVEL = "Critical";
|
||||
};
|
||||
|
||||
security.acme.certs.${domain}.extraDomainNames = [
|
||||
gitDomain
|
||||
];
|
||||
|
||||
services.nginx = {
|
||||
enable = true;
|
||||
|
||||
virtualHosts.${gitDomain} = {
|
||||
forceSSL = true;
|
||||
useACMEHost = config.nix-leonhard.domain;
|
||||
locations."/" = {
|
||||
proxyPass = "http://127.0.0.1:${toString config.services.gitea.settings.server.HTTP_PORT}";
|
||||
proxyWebsockets = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
{
|
||||
config,
|
||||
lib,
|
||||
modulesPath,
|
||||
...
|
||||
}:
|
||||
|
||||
{
|
||||
imports = [
|
||||
(modulesPath + "/installer/scan/not-detected.nix")
|
||||
];
|
||||
|
||||
boot.initrd.availableKernelModules = [
|
||||
"xhci_pci"
|
||||
"ahci"
|
||||
"usbhid"
|
||||
"sd_mod"
|
||||
];
|
||||
boot.initrd.kernelModules = [ ];
|
||||
boot.kernelModules = [ ];
|
||||
boot.extraModulePackages = [ ];
|
||||
|
||||
fileSystems."/" = {
|
||||
device = "/dev/disk/by-label/nixos";
|
||||
fsType = "ext4";
|
||||
};
|
||||
|
||||
fileSystems."/boot" = {
|
||||
device = "/dev/disk/by-label/boot";
|
||||
fsType = "vfat";
|
||||
options = [
|
||||
"fmask=0077"
|
||||
"dmask=0077"
|
||||
];
|
||||
};
|
||||
|
||||
swapDevices = [
|
||||
{ device = "/dev/disk/by-label/swap"; }
|
||||
];
|
||||
|
||||
nixpkgs.hostPlatform = lib.mkDefault "x86_64-linux";
|
||||
hardware.cpu.intel.updateMicrocode = lib.mkDefault config.hardware.enableRedistributableFirmware;
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
config,
|
||||
...
|
||||
}:
|
||||
{
|
||||
imports = [
|
||||
./secret-config.nix
|
||||
];
|
||||
|
||||
sops.secrets.dyndns = {
|
||||
format = "dotenv";
|
||||
sopsFile = ./dyndns.env;
|
||||
owner = config.systemd.services.dyndns.serviceConfig.User;
|
||||
};
|
||||
sops.secrets.vaultwarden = {
|
||||
format = "dotenv";
|
||||
sopsFile = ./vaultwarden.env;
|
||||
owner = config.systemd.services.vaultwarden.serviceConfig.User;
|
||||
};
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
NC_DOMAIN=ENC[AES256_GCM,data:q4yNX+QAzptwBo82PWL2XlJmaV4PL8o=,iv:09/3DcXAH9/86dPyblRfbc3ILuUmUzgRUjX0KIuQmOU=,tag:N3Ad0vfuz2Li9pra7laEpA==,type:str]
|
||||
NC_CUSTOMER=ENC[AES256_GCM,data:tqi91SnB,iv:OGwGNi298lHvcTuOi9tavb3Z+td7XzEk8A73tvRbQew=,tag:ivXW4uCirxja5PIZaGc/HA==,type:str]
|
||||
NC_API_PASSWORD=ENC[AES256_GCM,data:PJ/ppYER5nXAJTUD+eD2BS8jwuqLrb6dXfc5lfhL8vzYeCCvmRyTrvsfMLYFA8rC1VQ=,iv:3LsvJoPuq7YSKK93YNDBFmJmSaNF9VMPmAhL9mr5vjI=,tag:OozQp5V+A2ZsBll94vQtpw==,type:str]
|
||||
NC_API_KEY=ENC[AES256_GCM,data:LzfK825771pwYAoHEzaDh+5D9LyA29e3Jq9SLZTaCCtHz98r8uIhwZpWCFWU3hfU+xw=,iv:yAo1/DiSbl5T49X6EWlbhdYTOcZwuDw3AFlVbj/KlrM=,tag:sW1ahTqAcekhhv+5ctefUg==,type:str]
|
||||
sops_age__list_0__map_enc=-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBOOFdSQnlXODBHMlIvRjNK\nQUN6N0Z5b2tZZWk0elZHWXZZSlk3YkEzOTJ3CkdIWmg0dFpCdkQ2ek4wRllHeUpE\nQUpXWHhSRG9aeHAvamJLeGQvUnFUYjQKLS0tIGdsNG5WMDVvbEl2NnU0OGpkMTF1\nTGdaVGhBaEJ1bGNNZi9ReUI0TmJaMXMKE5Zg7MwjkKHSNceY3kRomMAgqXnN2slq\ndGM1s1MVZ83x3AdKTxCfhPXOqHCTgdpHpvvCq+EqntB2Tze/SVApSw==\n-----END AGE ENCRYPTED FILE-----\n
|
||||
sops_age__list_0__map_recipient=age1cma8j2jk0jmzgttjmqn06l87u4as9k46yzmvetflzqp995wzdsgsjppacx
|
||||
sops_lastmodified=2026-02-12T09:56:38Z
|
||||
sops_mac=ENC[AES256_GCM,data:sixevaa0DdTDFqYkCT6giO/OjOeI3Z4OWP10zXazHoiRODXMnU4O4CwfHvzPbD0z0lLCUNe1lF9vCQgQhhxw09Ose3XOZXspcdO95aea+705cgA9uSAxA5Sms7eFGdhWFAHaOYI/Up9OYFtzDO2CJN4XYY9IinnkfEwlpoXog3g=,iv:NRUGvsOYhB6t1qgvaiXvam91jUOOgvirmJ+Exuldmhc=,tag:Uo4+n5umEHGpszz4B8p8+w==,type:str]
|
||||
sops_unencrypted_suffix=_unencrypted
|
||||
sops_version=3.11.0
|
||||
Binary file not shown.
@@ -0,0 +1,7 @@
|
||||
ADMIN_TOKEN=ENC[AES256_GCM,data:DIH33/RioAcZVesw+5be4JK+7Jzu5S0qnHc7wsf7jwK2ZNfMDUycW5rSsgcrDNQciY+/4AK8c6a6DvMiLBqPOzi24uG6mdLT36yMvNDHP8Y8Mrfobyj1Rj03QrUUnl0+9IuBbZutBIzP2BGdQjdzB3UfEaGLaU3g,iv:sy4qxaPCEe4qC8r9kUM+DjNnl3haZoy1gqjEipQLia4=,tag:fWbSx3NV5yV2l2s1uiavXg==,type:str]
|
||||
sops_age__list_0__map_enc=-----BEGIN AGE ENCRYPTED FILE-----\nYWdlLWVuY3J5cHRpb24ub3JnL3YxCi0+IFgyNTUxOSBGdGg4bG1CZFhvYjVDZ0ZO\nZGUxTXpEMTJ1OHdiRmE1cHNvSkJPVlNIaG1JCnBmbWptRDZ2MWJmQnlPd2tvSk5r\neXAxQnNaUFlKcXdGN1p0bG53UU0rMG8KLS0tIEVuWlkwcjZEdHJibmdSWjdHUGQ1\nNmpWeXRWeU9NY2xoRXkvT1lmcFdVVUkKSy0xXHQuha2xkRiV9JxqvJxNCBBHtHgs\nDhma7HCGHYrbFEWFIH7qvjdHG2FYf/UqQchoSFDGrDHTZtY+pYFujg==\n-----END AGE ENCRYPTED FILE-----\n
|
||||
sops_age__list_0__map_recipient=age1cma8j2jk0jmzgttjmqn06l87u4as9k46yzmvetflzqp995wzdsgsjppacx
|
||||
sops_lastmodified=2026-02-23T12:43:01Z
|
||||
sops_mac=ENC[AES256_GCM,data:3RpYLYzkbAHZ1umutT/1yBpqpbdDcAGPjG5ANAlCbPgapK82qqyf/aiaDaKzOL1OHAIhV0xlR1WLE10jtij6dVjiKezqzw+eruS7Jyi09GHOLLnPv2VskccVBwr0U8u+Z/QbxoI4BW8a2gt6gdyUkNzqPR+Adf9wDaORjlkCSwk=,iv:AsKzTvxW+h92zEcotNvyMrp7Hqvkca7QHK/BWwL8LYE=,tag:MOXySJ/SSvT4oa8Fempn2w==,type:str]
|
||||
sops_unencrypted_suffix=_unencrypted
|
||||
sops_version=3.11.0
|
||||
@@ -0,0 +1,39 @@
|
||||
{
|
||||
config,
|
||||
...
|
||||
}:
|
||||
let
|
||||
domain = config.nix-leonhard.domain;
|
||||
vaultDomain = "bitwarden.${domain}";
|
||||
in
|
||||
{
|
||||
services.vaultwarden = {
|
||||
enable = true;
|
||||
domain = vaultDomain;
|
||||
environmentFile = config.sops.secrets.vaultwarden.path;
|
||||
config = {
|
||||
SIGNUPS_ALLOWED = false;
|
||||
|
||||
ROCKET_ADDRESS = "127.0.0.1";
|
||||
ROCKET_PORT = 8222;
|
||||
ROCKET_LOG = "critical";
|
||||
};
|
||||
};
|
||||
|
||||
security.acme.certs.${domain}.extraDomainNames = [
|
||||
vaultDomain
|
||||
];
|
||||
|
||||
services.nginx = {
|
||||
enable = true;
|
||||
|
||||
virtualHosts.${vaultDomain} = {
|
||||
forceSSL = true;
|
||||
useACMEHost = config.nix-leonhard.domain;
|
||||
locations."/" = {
|
||||
proxyPass = "http://127.0.0.1:${toString config.services.vaultwarden.config.ROCKET_PORT}";
|
||||
proxyWebsockets = true;
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
Reference in new issue
Block a user