structure the configuration.nix a bit

This commit is contained in:
Motiejus Jakštys 2023-01-04 10:06:52 +02:00
parent 9f8bc58439
commit e1e7a4ea43

View File

@ -13,39 +13,42 @@ let ssh_pubkeys = {
/etc/nixos/hardware-configuration.nix /etc/nixos/zfs.nix /etc/nixos/hardware-configuration.nix /etc/nixos/zfs.nix
]; ];
boot.initrd.network.enable = true; boot.initrd.network = {
boot.initrd.network.ssh = {
enable = true; enable = true;
port = 22; ssh = {
authorizedKeys = builtins.attrValues ssh_pubkeys; enable = true;
hostKeys = [ "/etc/secrets/initrd/ssh_host_ed25519_key" ]; port = 22;
authorizedKeys = builtins.attrValues ssh_pubkeys;
hostKeys = [ "/etc/secrets/initrd/ssh_host_ed25519_key" ];
};
}; };
services.zfs.autoSnapshot = { security.sudo = {
enable = true; wheelNeedsPassword = false;
frequent = 0; execWheelOnly = true;
hourly = 24;
daily = 7;
weekly = 0;
monthly = 0;
}; };
services.zfs.autoScrub.enable = true;
services.zfs.trim.enable = true;
services.zfs.expandOnBoot = "all";
networking.hostName = "hel1-a";
time.timeZone = "UTC"; time.timeZone = "UTC";
users.users.motiejus = { users = {
isNormalUser = true; mutableUsers = false;
extraGroups = [ "wheel" ];
};
users.users.motiejus.openssh.authorizedKeys.keys = [ ssh_pubkeys.motiejus ];
users.mutableUsers = false;
security.sudo.wheelNeedsPassword = false; users = {
security.sudo.execWheelOnly = true; git = {
description = "Gitea Service";
home = "/var/lib/gitea";
useDefaultShell = true;
group = "gitea";
isSystemUser = true;
};
motiejus = {
isNormalUser = true;
extraGroups = [ "wheel" ];
openssh.authorizedKeys.keys = [ ssh_pubkeys.motiejus ];
};
};
};
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
jq jq
@ -67,114 +70,124 @@ let ssh_pubkeys = {
]; ];
programs.mtr.enable = true; programs.mtr.enable = true;
programs.mosh.enable = true;
services.openssh = { services = {
enable = true; zfs = {
passwordAuthentication = false; autoSnapshot = {
permitRootLogin = "no"; enable = true;
extraConfig = '' frequent = 0;
AcceptEnv GIT_PROTOCOL hourly = 24;
''; daily = 7;
}; weekly = 0;
monthly = 0;
};
services.locate = { autoScrub.enable = true;
enable = true; trim.enable = true;
locate = pkgs.plocate; expandOnBoot = "all";
localuser = null;
};
services.headscale = {
enable = true;
serverUrl = "https://vpn.jakstys.lt";
openIdConnect = {
issuer = "https://git.jakstys.lt/";
clientId = "1c5fe796-452c-458d-b295-71a9967642fc";
clientSecretFile = "/var/src/secrets/headscale/oidc_client_secret";
}; };
settings = {
ip_prefixes = [ "100.89.176.0/20" ]; openssh = {
dns_config = { enable = true;
nameservers = [ "1.1.1.1" "8.8.4.4" ]; passwordAuthentication = false;
magic_dns = true; permitRootLogin = "no";
base_domain = "jakst"; extraConfig = ''
AcceptEnv GIT_PROTOCOL
'';
};
locate = {
enable = true;
locate = pkgs.plocate;
localuser = null;
};
headscale = {
enable = true;
serverUrl = "https://vpn.jakstys.lt";
openIdConnect = {
issuer = "https://git.jakstys.lt/";
clientId = "1c5fe796-452c-458d-b295-71a9967642fc";
clientSecretFile = "/var/src/secrets/headscale/oidc_client_secret";
};
settings = {
ip_prefixes = [ "100.89.176.0/20" ];
dns_config = {
nameservers = [ "1.1.1.1" "8.8.4.4" ];
magic_dns = true;
base_domain = "jakst";
};
};
};
tailscale.enable = true;
gitea = {
enable = true;
user = "git";
database.user = "git";
domain = "git.jakstys.lt";
rootUrl = "https://git.jakstys.lt";
httpAddress = "127.0.0.1";
httpPort = 3000;
settings = {
admin.DISABLE_REGULAR_ORG_CREATION = true;
api.ENABLE_SWAGGER = false;
mirror.ENABLED = false;
other.SHOW_FOOTER_VERSION = false;
packages.ENABLED = false;
repository.DEFAULT_REPO_UNITS = "repo.code,repo.releases";
repository.DISABLE_MIGRATIONS = true;
repository.DISABLE_STARS = true;
repository.ENABLE_PUSH_CREATE_USER = true;
security.LOGIN_REMEMBER_DAYS = 30;
server.ENABLE_GZIP = true;
server.LANDING_PAGE = "/motiejus";
service.DISABLE_REGISTRATION = true;
service.ENABLE_TIMETRACKING = false;
service.ENABLE_USER_HEATMAP = false;
service.SHOW_MILESTONES_DASHBOARD_PAGE = false;
session.COOKIE_SECURE = true;
"service.explore".REQUIRE_SIGNIN_VIEW = true;
"service.explore".DISABLE_USERS_PAGE = true;
};
};
caddy = {
enable = true;
email = "motiejus+acme@jakstys.lt";
virtualHosts."vpn.jakstys.lt".extraConfig = ''
reverse_proxy 127.0.0.1:8080
'';
virtualHosts."git.jakstys.lt".extraConfig = ''
reverse_proxy 127.0.0.1:3000
'';
};
};
networking = {
hostName = "hel1-a";
firewall = {
allowedTCPPorts = [ 80 443 ];
allowedUDPPorts = [ 443 ];
checkReversePath = "loose"; # tailscale insists on this
};
};
system = {
copySystemConfiguration = true;
autoUpgrade.enable = true;
autoUpgrade = {
allowReboot = true;
rebootWindow = {
lower = "00:00";
upper = "00:30";
}; };
}; };
}; };
services.tailscale.enable = true; # Do not change
system.stateVersion = "22.11";
services.gitea = {
enable = true;
user = "git";
database.user = "git";
domain = "git.jakstys.lt";
rootUrl = "https://git.jakstys.lt";
httpAddress = "127.0.0.1";
httpPort = 3000;
settings = {
admin.DISABLE_REGULAR_ORG_CREATION = true;
api.ENABLE_SWAGGER = false;
mirror.ENABLED = false;
other.SHOW_FOOTER_VERSION = false;
packages.ENABLED = false;
repository.DEFAULT_REPO_UNITS = "repo.code,repo.releases";
repository.DISABLE_MIGRATIONS = true;
repository.DISABLE_STARS = true;
repository.ENABLE_PUSH_CREATE_USER = true;
security.LOGIN_REMEMBER_DAYS = 30;
server.ENABLE_GZIP = true;
server.LANDING_PAGE = "/motiejus";
service.DISABLE_REGISTRATION = true;
service.ENABLE_TIMETRACKING = false;
service.ENABLE_USER_HEATMAP = false;
service.SHOW_MILESTONES_DASHBOARD_PAGE = false;
session.COOKIE_SECURE = true;
};
#service.explore.REQUIRE_SIGNIN_VIEW = true; does not work as of writing
extraConfig = ''
[service.explore]
REQUIRE_SIGNIN_VIEW = true;
DISABLE_USERS_PAGE = true;
'';
};
users.users.git = {
description = "Gitea Service";
home = "/var/lib/gitea";
useDefaultShell = true;
group = "gitea";
isSystemUser = true;
};
services.caddy = {
enable = true;
email = "motiejus+acme@jakstys.lt";
virtualHosts."vpn.jakstys.lt".extraConfig = ''
reverse_proxy 127.0.0.1:8080
'';
virtualHosts."git.jakstys.lt".extraConfig = ''
reverse_proxy 127.0.0.1:3000
'';
};
programs.mosh.enable = true;
networking.firewall.allowedTCPPorts = [ 80 443 ];
networking.firewall.allowedUDPPorts = [ 443 ];
# tailscale insists on this
networking.firewall.checkReversePath = "loose";
system.copySystemConfiguration = true;
system.autoUpgrade.enable = true;
system.autoUpgrade = {
allowReboot = true;
rebootWindow = {
lower = "00:00";
upper = "00:30";
};
};
# do not change
system.stateVersion = "22.11"; # Did you read the comment?
} }