nixos-config/machines/weilite/default.nix

207 lines
4.7 KiB
Nix
Raw Permalink Normal View History

2024-08-25 09:45:58 +00:00
{
inputs,
config,
pkgs,
modulesPath,
...
}:
{
imports = [
2024-07-30 03:01:07 +00:00
inputs.sops-nix.nixosModules.sops
(modulesPath + "/profiles/qemu-guest.nix")
2024-09-14 08:33:01 +00:00
./services
];
config = {
networking.hostName = "weilite";
commonSettings = {
auth.enable = true;
2024-09-24 02:53:51 +00:00
autoupgrade.enable = true;
nix = {
enable = true;
enableMirrors = true;
};
};
boot = {
2024-08-25 09:45:58 +00:00
loader = {
systemd-boot.enable = true;
efi.canTouchEfiVariables = true;
};
2024-08-25 09:45:58 +00:00
initrd.availableKernelModules = [
"uhci_hcd"
"ehci_pci"
"ahci"
"usb_storage"
"sd_mod"
];
kernelModules = [ "kvm-intel" ];
};
2024-09-23 12:17:26 +00:00
nixpkgs.config.allowUnfree = true;
2024-08-25 09:45:58 +00:00
environment.systemPackages = [ pkgs.virtiofsd ];
2024-07-30 03:01:07 +00:00
sops = {
defaultSopsFile = ./secrets.yaml;
age.sshKeyPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
secrets = {
cloudflare_dns_token = {
owner = "caddy";
mode = "400";
};
2024-09-23 12:17:26 +00:00
dnspod_dns_token = {
owner = "caddy";
mode = "400";
};
2024-09-14 08:33:01 +00:00
"immich/oauth_client_secret" = {
owner = "immich";
mode = "400";
};
2024-07-30 03:01:07 +00:00
};
};
2024-08-01 09:01:53 +00:00
custom.prometheus = {
enable = true;
};
systemd.mounts = [
2024-08-25 09:45:58 +00:00
{
what = "immich";
2024-07-30 03:01:07 +00:00
where = "/mnt/XinPhotos/immich";
type = "virtiofs";
2024-09-23 12:17:26 +00:00
options = "rw,nodev,nosuid";
2024-07-30 03:01:07 +00:00
wantedBy = [ "immich-server.service" ];
}
2024-08-25 09:45:58 +00:00
{
what = "originals";
2024-07-30 03:01:07 +00:00
where = "/mnt/XinPhotos/originals";
type = "virtiofs";
2024-09-23 12:17:26 +00:00
options = "rw,nodev,nosuid";
wantedBy = [ "immich-server.service" ];
}
2024-09-23 12:17:26 +00:00
{
what = "restic";
where = "/var/lib/restic";
type = "virtiofs";
options = "rw,nodev,nosuid";
wantedBy = [ "restic-rest-server.service" ];
}
{
what = "ocis";
where = "/var/lib/ocis";
type = "virtiofs";
options = "rw,nodev,nosuid";
wantedBy = [ "ocis.service" ];
}
];
2024-08-25 09:45:58 +00:00
services.openssh.ports = [
22
2222
];
services.immich = {
enable = true;
mediaLocation = "/mnt/XinPhotos/immich";
host = "127.0.0.1";
port = 3001;
openFirewall = true;
machine-learning.enable = true;
environment = {
IMMICH_MACHINE_LEARNING_ENABLED = "true";
};
2024-09-14 08:33:01 +00:00
database.enable = true;
};
custom.immich.jsonSettings = {
oauth = {
enabled = true;
issuerUrl = "https://auth.xinyang.life/oauth2/openid/immich/";
clientId = "immich";
clientSecret = {
_secret = config.sops.secrets."immich/oauth_client_secret".path;
};
scope = "openid email profile";
signingAlgorithm = "ES256";
storageLabelClaim = "email";
buttonText = "Login with Kanidm";
autoLaunch = true;
mobileOverrideEnabled = true;
mobileRedirectUri = "https://immich.xinyang.life:8000/api/oauth/mobile-redirect/";
};
passwordLogin = {
enabled = false;
};
newVersionCheck = {
enabled = false;
};
};
services.dae = {
enable = true;
configFile = "/var/lib/dae/config.dae";
};
services.tailscale = {
enable = true;
openFirewall = true;
permitCertUid = "caddy";
};
services.caddy = {
enable = true;
2024-07-30 03:01:07 +00:00
package = pkgs.caddy.withPlugins {
caddyModules = [
2024-08-25 09:45:58 +00:00
{
repo = "github.com/caddy-dns/cloudflare";
version = "89f16b99c18ef49c8bb470a82f895bce01cbaece";
}
2024-09-24 02:53:51 +00:00
{
2024-09-23 12:17:26 +00:00
repo = "github.com/caddy-dns/dnspod";
version = "1fd4ce87e919f47db5fa029c31ae74b9737a58af";
}
2024-07-30 03:01:07 +00:00
];
2024-09-23 12:17:26 +00:00
vendorHash = "sha256-OhOeU2+JiJyIW9WdCYq98OKckXQZ9Fn5zULz0aLsXMI=";
2024-07-30 03:01:07 +00:00
};
virtualHosts."weilite.coho-tet.ts.net:8080".extraConfig = ''
reverse_proxy 127.0.0.1:${toString config.services.immich.port}
'';
2024-07-30 03:01:07 +00:00
# API Token must be added in systemd environment file
virtualHosts."immich.xinyang.life:8000".extraConfig = ''
reverse_proxy 127.0.0.1:${toString config.services.immich.port}
'';
2024-09-23 12:17:26 +00:00
globalConfig = ''
acme_dns dnspod {env.DNSPOD_API_TOKEN}
'';
2024-07-30 03:01:07 +00:00
};
networking.firewall.allowedTCPPorts = [ 8000 ];
systemd.services.caddy = {
serviceConfig = {
2024-09-23 12:17:26 +00:00
EnvironmentFile = config.sops.secrets.dnspod_dns_token.path;
2024-07-30 03:01:07 +00:00
};
};
time.timeZone = "Asia/Shanghai";
2024-08-25 09:45:58 +00:00
fileSystems."/" = {
device = "/dev/disk/by-label/nixos";
fsType = "btrfs";
};
fileSystems."/boot" = {
device = "/dev/sda1";
fsType = "vfat";
2024-08-25 09:45:58 +00:00
options = [
"fmask=0022"
"dmask=0022"
];
};
system.stateVersion = "24.11";
};
}