Merge branch 'main' of gh:greg-hellings/nixos-config

This commit is contained in:
Greg Hellings
2024-03-25 15:20:47 -05:00
53 changed files with 819 additions and 572 deletions
+3 -9
View File
@@ -8,8 +8,6 @@ let
machine = {
channel ? inputs.nixstable,
extraMods ? [],
gnome ? false,
gui ? false,
name,
system ? "x86_64-linux",
hm ? inputs.hm
@@ -20,7 +18,7 @@ let
};
in channel.lib.nixosSystem {
inherit system;
specialArgs = { inherit nixpkgs inputs; };
specialArgs = { inherit nixpkgs inputs overlays; };
modules = [
{
nixpkgs.overlays = overlays;
@@ -28,7 +26,7 @@ let
home-manager.useUserPackages = true;
home-manager.users.greg = import ../home/home.nix;
home-manager.extraSpecialArgs = {
inherit gnome gui inputs overlays;
inherit inputs overlays;
home = "/home/greg";
host = name;
};
@@ -41,11 +39,7 @@ let
};
in {
genesis = machine { name = "genesis"; };
jude = unstable {
name = "jude";
gnome = true;
gui = true;
};
jude = unstable { name = "jude"; };
icdm-root = unstable { name = "icdm-root"; };
linode = machine { name = "linode"; };
mm = unstable { name = "mm"; };
+2 -2
View File
@@ -8,8 +8,8 @@
i18n.defaultLocale = "en_US.UTF-8";
# Configure keymap in X11
services.xserver = {
services.xserver.xkb = {
layout = "us";
xkbVariant = "";
variant = "";
};
}
+2
View File
@@ -3,6 +3,8 @@
{
# Use the systemd-boot EFI boot loader.
boot = {
binfmt.emulatedSystems = [ "aarch64-linux" ];
kernelPackages = pkgs.linuxPackages_latest;
supportedFilesystems = [ "ntfs" ];
loader = {
timeout = 15;
+54 -35
View File
@@ -1,4 +1,4 @@
{ pkgs, ... }:
{ pkgs, config, ... }:
{
imports = [
@@ -23,46 +23,64 @@
hostName = "jude";
enableIPv6 = false;
interfaces.enp12s0.useDHCP = true;
firewall.enable = true;
firewall = {
enable = false;
allowedTCPPorts = [ 21000 ];
allowedUDPPorts = [ 21000 21010 ];
};
};
greg = {
tailscale.enable = true;
gnome.enable = true;
kde.enable = false;
sway.enable = false;
gnome.enable = false;
kde.enable = true;
};
environment.systemPackages = with pkgs; [
bind # For things like nslookup
create_ssl
darktable
expect
gimp
gnucash
graphviz
flock
ffmpeg
handbrake
imagemagick
libtheora
libxml2
linode-cli
makemkv
nix-du
nix-tree
oathToolkit
synology-drive-client
terraform
vagrant
ventoy
boot.extraModulePackages = [ config.boot.kernelPackages.v4l2loopback ];
# Video/Audio data composition framework tools like "gst-inspect", "gst-launch" ...
gst_all_1.gstreamer
gst_all_1.gst-plugins-base
gst_all_1.gst-plugins-good
gst_all_1.gst-plugins-bad
gst_all_1.gst-plugins-ugly
gst_all_1.gst-libav
gst_all_1.gst-vaapi
environment.systemPackages = with pkgs; lib.mkMerge [
[ # for Immersed
cudatoolkit
immersed-vr
libva
]
[
bind # For things like nslookup
create_ssl
darktable
distrobox
expect
gimp
gparted
gnucash
graphviz
flock
ffmpeg
handbrake
imagemagick
libtheora
libxml2
linode-cli
makemkv
nix-du
nix-tree
oathToolkit
synology-drive-client
terraform
vagrant
ventoy
]
[
# Video/Audio data composition framework tools like "gst-inspect", "gst-launch" ...
gst_all_1.gstreamer
gst_all_1.gst-plugins-base
gst_all_1.gst-plugins-good
gst_all_1.gst-plugins-bad
gst_all_1.gst-plugins-ugly
gst_all_1.gst-libav
gst_all_1.gst-vaapi
]
];
fileSystems = {
"/boot" = {
@@ -89,6 +107,7 @@
pulse.enable = true;
wireplumber.enable = true;
};
locate.enable = true;
xserver.videoDrivers = [ "nvidia" ];
};
hardware = {
+1 -1
View File
@@ -5,10 +5,10 @@
./git.nix
./hardware-configuration.nix
./podman.nix
./matrix.nix
./nextcloud.nix
./nginx.nix
./postgres.nix
./synapse.nix
];
greg = {
+62
View File
@@ -0,0 +1,62 @@
# Registration of new users is disabled for the public, but I can create
# them by the following commands:
# nix run nixpkgs.matrix-synapse
# register_new_matrix_user -k "B9EoPr2WV9hzwc7uL2Sx1JmvCeKDEOGCpB0uginQcQtEH4wzRtkSIdo7lltrjSQa" http://localhost:8448
{ config, pkgs, ... }:
let
domain = "${config.networking.domain}";
fqdn = "matrix.${domain}";
conn = "postgresql:///dendrite?sslmode=disable&host=/run/postgresql";
in
{
services.nginx = {
virtualHosts = {
# Server the '.well-known' files to find the Matrix API server
"${domain}" = {
enableACME = true;
forceSSL = true;
# This is needed so that servers contacting hellings.com can find
# the actual application server at matrix.thehellings.com
locations."= /.well-known/matrix/server".extraConfig =
let
server = { "m.server" = "${fqdn}:443"; };
in ''
add_header Content-Type application/json;
return 200 '${builtins.toJSON server}';
'';
locations."= /.well-known/matrix/client".extraConfig =
let
client = {
"m.homeserver" = { "base_url" = "https://${fqdn}"; };
"m.identity_server" = { "base_url" = "https://vector.im"; };
};
in ''
add_header Content-Type application/json;
add_header Access-Control-Allow-Origin *;
return 200 '${builtins.toJSON client}';
'';
};
# Reverse proxy in front of the actual Matrix server
"${fqdn}" = {
enableACME = true;
forceSSL = true;
# Not the appropriate place for the chat client
locations."/".extraConfig = "return 404;";
locations."/_matrix" = {
proxyPass = "http://matrix.shire-zebra.ts.net:8448"; # Lacking the trailing / is correct
};
};
};
};
# Open networking ports for the server
networking.firewall = {
enable = true;
allowedTCPPorts = [ 80 443 ];
};
}
+1 -6
View File
@@ -5,7 +5,6 @@
enable = true;
checkConfig = true;
ensureDatabases = [
"dendrite"
"nextcloud"
];
#initialScript = pkgs.writeText "create-matrix-db.sql" ''
@@ -16,10 +15,7 @@
ensureUsers = [ {
name = "nextcloud";
ensureDBOwnership = true;
} {
name = "dendrite";
ensureDBOwnership = true;
} ];
} ];
settings = {
log_connections = true;
log_statement = "all";
@@ -34,7 +30,6 @@ root root postgres
services.postgresqlBackup = {
enable = true;
databases = [
"dendrite"
"nextcloud"
];
};
-137
View File
@@ -1,137 +0,0 @@
# Registration of new users is disabled for the public, but I can create
# them by the following commands:
# nix run nixpkgs.matrix-synapse
# register_new_matrix_user -k "B9EoPr2WV9hzwc7uL2Sx1JmvCeKDEOGCpB0uginQcQtEH4wzRtkSIdo7lltrjSQa" http://localhost:8448
{ config, pkgs, ... }:
let
domain = "${config.networking.domain}";
fqdn = "matrix.${domain}";
conn = "postgresql:///dendrite?sslmode=disable&host=/run/postgresql";
in
{
services.nginx = {
virtualHosts = {
# Server the '.well-known' files to find the Matrix API server
"${domain}" = {
enableACME = true;
forceSSL = true;
# This is needed so that servers contacting hellings.com can find
# the actual application server at matrix.thehellings.com
locations."= /.well-known/matrix/server".extraConfig =
let
server = { "m.server" = "${fqdn}:443"; };
in ''
add_header Content-Type application/json;
return 200 '${builtins.toJSON server}';
'';
locations."= /.well-known/matrix/client".extraConfig =
let
client = {
"m.homeserver" = { "base_url" = "https://${fqdn}"; };
"m.identity_server" = { "base_url" = "https://vector.im"; };
};
in ''
add_header Content-Type application/json;
add_header Access-Control-Allow-Origin *;
return 200 '${builtins.toJSON client}';
'';
};
# Reverse proxy in front of the actual Matrix server
"${fqdn}" = {
enableACME = true;
forceSSL = true;
# Not the appropriate place for the chat client
locations."/".extraConfig = "return 404;";
locations."/_matrix" = {
proxyPass = "http://127.0.0.1:8448"; # Lacking the trailing / is correct
};
};
# Run Element web
"chat.${fqdn}" = {
enableACME = true;
forceSSL = true;
serverAliases = [
"chat.${domain}"
];
root = pkgs.element-web.override {
conf.default_server_config."m.homeserver" = {
"base_url" = "https://${fqdn}";
"server_name" = "${fqdn}";
};
};
};
};
};
# Environment secrets
age.secrets.dendrite = {
file = ../../secrets/dendrite.age;
owner = "dendrite";
};
users.users.dendrite = {
isSystemUser = true;
group = "dendrite";
};
users.groups.dendrite = {};
systemd.services.dendrite.serviceConfig = {
User = "dendrite";
};
services.dendrite = {
enable = true;
environmentFile = "/run/agenix/dendrite";
httpPort = 8448;
# Identify ourselves as the root of our own domain
settings = (
(builtins.listToAttrs (
(map (x: { name = x; value = { database.connection_string = conn; }; }) [
"app_service_api"
"federation_api"
"key_server"
"media_api"
"mscs"
"relay_api"
"room_server"
"sync_api"
])
) ) //
{
user_api.account_database.connection_string = conn;
user_api.device_database.connection_string = conn;
global = {
database = {
connection_string = conn;
max_open_conns = 90;
max_idle_conns = 5;
conn_max_lifetime = -1;
};
server_name = "thehellings.com";
trusted_third_party_id_servers = [
"matrix.org"
"vector.im"
"jupiterbroadcasting.com"
];
# Generate this with {path-to-dendrite}/bin/generate-keys --private-key /etc/dendrite.pem
private_key = "/etc/dendrite.pem";
};
client_api = {
registration_enabled = false;
registration_shared_secret = "\${REGISTRATION_SHARED_SECRET}";
};
});
};
# Open networking ports for the server
networking.firewall = {
enable = true;
allowedTCPPorts = [ 80 443 ];
};
}
+2 -2
View File
@@ -183,9 +183,9 @@ in
};
};
# Configure keymap in X11
xserver = {
xserver.xkb = {
layout = "us";
xkbVariant = "";
variant = "";
};
};
+2 -18
View File
@@ -1,20 +1,11 @@
{ inputs, ...}:
{ config, pkgs, lib, ... }: let
registryPort = 5000;
vpnIp = "100.78.226.76";
containerIp = "192.168.200.2";
in {
imports = [
inputs.agenix.nixosModules.default
inputs.self.modules.nixosModule
];
nixpkgs.overlays = inputs.self.overlays.all;
age.identityPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
age.secretsMountPoint = "/run/derp";
age.secrets = let
cfg = n: { file = ../../secrets/gitlab/${n}.age; owner = "github"; mode = "0444"; };
cfg = n: { file = ../../secrets/gitlab/${n}.age; owner = "gitlab"; group = "gitlab"; mode = "0444"; };
in {
gitlab-secret = cfg "secret";
gitlab-otp = cfg "otp";
@@ -24,13 +15,7 @@ in {
gitlab-cert = cfg "cert";
};
networking = {
firewall = {
enable = true;
allowedTCPPorts = [ 80 registryPort ];
};
useHostResolvConf = lib.mkForce false;
};
networking.firewall.allowedTCPPorts = [ 80 registryPort ];
greg.proxies = let
t = {
@@ -45,7 +30,6 @@ in {
"${vpnIp}" = t;
"git.thehellings.lan" = t;
};
greg.tailscale.enable = true;
virtualisation.docker.enable = true;
+2 -2
View File
@@ -1,4 +1,4 @@
{ inputs, name, extra ? {}, packages ? [] }:
{ inputs, name, extra ? {}, packages ? [], overlays }:
({ config, pkgs, lib, ... }:
let
@@ -15,7 +15,7 @@ lib.attrsets.recursiveUpdate {
inputs.self.modules.nixosModule
];
nixpkgs.overlays = inputs.self.overlays.all;
nixpkgs.overlays = overlays;
age = {
identityPaths = [ "/etc/ssh/ssh_host_ed25519_key" ];
+5 -1
View File
@@ -1,8 +1,9 @@
{ config, pkgs, lib, ... }:
{
imports = [
imports = [
./hardware-configuration.nix
./git.nix
./matrix.nix
];
environment.systemPackages = with pkgs; [
@@ -65,6 +66,9 @@
configurationLimit = 10;
};
};
binfmt.emulatedSystems = [
"aarch64-linux"
];
};
nixpkgs.config = {
allowUnfree = true;
+8 -28
View File
@@ -1,4 +1,4 @@
{ config, pkgs, lib, inputs, ... }:
{ config, pkgs, lib, inputs, overlays, ... }:
let
@@ -31,25 +31,10 @@ in {
system.activationScripts.makeGitlabDir = lib.stringAfter [ "var" ] "mkdir -p ${gitlabStateDir} && touch ${gitlabStateDir}/touch";
containers.gitlab = container {
autoStart = true;
bindMounts = {
"/var/gitlab/state" = {
hostPath = gitlabStateDir;
isReadOnly = false;
};
"/dev/net/tun" = {
hostPath = "/dev/net/tun";
isReadOnly = false;
};
};
forwardPorts = [{
hostPort = 2222;
containerPort = 22;
}];
hostAddress = "192.168.200.1";
localAddress = "192.168.200.2";
config = ((import ./container-git.nix) { inherit inputs; });
greg.containers.gitlab = {
tailscale = true;
subnet = "200";
builder = (import ./container-git.nix);
};
systemd.services = {
@@ -80,11 +65,6 @@ in {
];
};
};
"container@gitlab".serviceConfig = {
DeviceAllow = [ "/dev/net/tun" ];
ProtectKernelModules = false;
PrivateDevices = false;
};
gitlab-runner.serviceConfig.EnvironmentFile = config.age.secrets.docker-auth.path;
};
@@ -108,7 +88,7 @@ in {
hostAddress = "192.168.201.1";
localAddress = "192.168.201.2";
config = ((import ./container-runner.nix) {
inherit inputs;
inherit inputs overlays;
name = "qemu";
packages = with pkgs; [ qemu_full qemu_kvm ];
extra = {
@@ -142,7 +122,7 @@ in {
hostAddress = "192.168.202.1";
localAddress = "192.168.202.2";
config = ((import ./container-runner.nix) {
inherit inputs;
inherit inputs overlays;
name = "vbox";
extra = {
systemd.services.gitlab-runner.serviceConfig = {
@@ -168,7 +148,7 @@ in {
hostAddress = "192.168.203.1";
localAddress = "192.168.203.2";
config = ((import ./container-runner.nix) {
inherit inputs;
inherit inputs overlays;
name = "shell";
});
};
+88
View File
@@ -0,0 +1,88 @@
{ config, pkgs, inputs, lib, ... }:
let
domain = "thehellings.com";
fqdn = "matrix.${domain}";
conn = "postgresql:///dendrite?sslmode=disable&host=/run/postgresql";
in
{
greg.containers.matrix = {
tailscale = true;
subnet = "204";
builder = { pkgs, config, ... }: {
networking.firewall.allowedTCPPorts = [ config.services.dendrite.httpPort ];
# Environment secrets
age = {
secrets.dendrite = {
file = ../../secrets/dendrite.age;
owner = "dendrite";
};
secrets.dendrite_key = {
file = ../../secrets/dendrite_key.age;
owner = "dendrite";
};
};
users.users.dendrite = {
isSystemUser = true;
group = "dendrite";
};
users.groups.dendrite = {};
systemd.services.dendrite.serviceConfig = {
User = "dendrite";
};
greg.databases.dendrite = {};
services.dendrite = {
enable = true;
environmentFile = config.age.secrets.dendrite.path;
httpPort = 8448;
# Identify ourselves as the root of our own domain
settings = (
(builtins.listToAttrs (
(map (x: { name = x; value = { database.connection_string = conn; }; }) [
"app_service_api"
"federation_api"
"key_server"
"media_api"
"mscs"
"relay_api"
"room_server"
"sync_api"
])
) ) //
{
user_api.account_database.connection_string = conn;
user_api.device_database.connection_string = conn;
global = {
database = {
connection_string = conn;
max_open_conns = 25;
max_idle_conns = 5;
conn_max_lifetime = -1;
};
server_name = "thehellings.com";
trusted_third_party_id_servers = [
"matrix.org"
"vector.im"
"jupiterbroadcasting.com"
];
# Generate this with {path-to-dendrite}/bin/generate-keys --private-key /etc/dendrite.pem
private_key = config.age.secrets.dendrite_key.path;
};
client_api = {
registration_enabled = false;
registration_shared_secret = "\${REGISTRATION_SHARED_SECRET}";
};
});
};
systemd.services.dendrite = {
after = [ "postgresql.service" ];
requires = [ "postgresql.service" ];
};
};
};
}