124 lines
3.7 KiB
Nix
124 lines
3.7 KiB
Nix
{ withSystem, self, inputs, lib, ... }:
|
|
# Intent: NixOS service node for Forgejo + restic with mTLS, host-local secrets, and a paired Home Manager profile for john.
|
|
let
|
|
username = "john";
|
|
hostname = "soteria";
|
|
ipv4 = "192.168.1.233";
|
|
ipv6 = "fded:fb16:653e:25da:be24:11ff:fe54:aa39";
|
|
names = [ "${hostname}.john-stream.com" ipv4 ipv6 ];
|
|
in
|
|
{
|
|
flake.nixosConfigurations."${hostname}" = inputs.nixpkgs.lib.nixosSystem {
|
|
modules = with inputs.self.modules; [
|
|
nixos.lxc
|
|
nixos.login-text
|
|
inputs.home-manager.nixosModules.home-manager
|
|
nixos."${username}"
|
|
nixos.ssh-new
|
|
# nixos.mtls
|
|
nixos.mysops
|
|
# nixos.ssh-certs
|
|
nixos.docker
|
|
nixos.step-client
|
|
nixos.forgejo
|
|
nixos.restic-server
|
|
# nixos.restic-envoy
|
|
({ config, pkgs, ... }: {
|
|
networking.hostName = hostname;
|
|
|
|
# Removes password for sudo
|
|
security.sudo-rs.extraRules = lib.mkAfter [
|
|
{
|
|
users = [ username ];
|
|
commands = [
|
|
{
|
|
command = "ALL";
|
|
options = [ "NOPASSWD" ];
|
|
}
|
|
];
|
|
}
|
|
];
|
|
|
|
users.users."${username}".extraGroups = [ "mtls" ];
|
|
mtls = {
|
|
enable = true;
|
|
subject = hostname;
|
|
san = names;
|
|
lifetime = "12h";
|
|
renew.onCalendar = "*:3/15";
|
|
renew.reloadUnits = [ "forgejo.service" "restic-rest-server.service" ];
|
|
certReaders = [ config.services.forgejo.user "restic" ];
|
|
};
|
|
forgejo = {
|
|
enable = true;
|
|
root_url = "https://forgejo.john-stream.com";
|
|
https = true;
|
|
port = 443;
|
|
};
|
|
|
|
resticServer = {
|
|
enable = true;
|
|
dataDir = "/mnt/restic";
|
|
privateRepos = true;
|
|
listenAddress = "0.0.0.0:8000";
|
|
tls = {
|
|
certFile = config.mtls.certFile;
|
|
keyFile = config.mtls.keyFile;
|
|
};
|
|
};
|
|
|
|
loginText.extraServiceStatus = {
|
|
Docker = "docker";
|
|
"mTLS Renewal" = "mtls-renew.timer";
|
|
"Forgejo" = "forgejo.service";
|
|
"Forgejo Backup" = "forgejo-dump.timer";
|
|
"Restic REST Server" = "restic-rest-server.service";
|
|
};
|
|
|
|
ssh-new.certificates = {
|
|
provisioner = "admin";
|
|
host = {
|
|
enable = true;
|
|
extraPrincipals = names;
|
|
autoRenew = true;
|
|
};
|
|
user.enable = true;
|
|
};
|
|
|
|
# This provides the secrets at install time
|
|
sops.defaultSopsFile = ./secrets.yaml;
|
|
|
|
home-manager.users."${username}".imports = [ inputs.self.modules.homeManager.soteria ];
|
|
|
|
environment.systemPackages = [
|
|
inputs.self.packages.${pkgs.stdenv.hostPlatform.system}.my-neovim
|
|
inputs.self.packages.${pkgs.stdenv.hostPlatform.system}.jsl-zsh
|
|
];
|
|
})
|
|
];
|
|
};
|
|
|
|
flake.modules.homeManager.soteria = { config, pkgs, lib, ... }: {
|
|
imports = with inputs.self.modules.homeManager; [
|
|
rebuild
|
|
mysops
|
|
step-client
|
|
({ config, pkgs, lib, ... }: {
|
|
homeManagerFlakeDir = "${config.xdg.configHome}/home-manager";
|
|
docker.enable = true;
|
|
|
|
# This will provide the edit-secrets script targeting this file
|
|
mysops.hostSecretFile = "${config.homeManagerFlakeDir}/modules/hosts/soteria/secrets.yaml";
|
|
})
|
|
];
|
|
};
|
|
|
|
# flake.homeConfigurations.soteria = withSystem "x86_64-linux" (ctx@{ config, inputs', ...}:
|
|
# inputs.home-manager.lib.homeManagerConfiguration {
|
|
# pkgs = inputs'.nixpkgs.legacyPackages;
|
|
# modules = [
|
|
# inputs.self.modules.homeManager."${username}"
|
|
# inputs.self.modules.homeManager.soteria
|
|
# ];
|
|
# });
|
|
} |