nixify knot1 #6

open
opened by anirudh.fi targeting master from push-oqkkllmzurup
Changed files
+170
hosts
+11
flake.nix
···
];
target = "spindle.alpha.tangled.sh";
};
+
+
knot1 = {
+
modules = [
+
tangled.nixosModules.knot
+
./hosts/knot1/services/knot.nix
+
./hosts/knot1/services/nginx.nix
+
];
+
target = "knot1.alpha.tangled.sh";
+
};
};
in
{
···
pds = mkHost "pds" hosts.pds.modules;
nixery = mkHost "nixery" hosts.nixery.modules;
spindle = mkHost "spindle" hosts.spindle.modules;
+
knot1 = mkHost "knot1" hosts.knot1.modules;
};
# colmena uses this
···
pds = mkColmenaHost "pds" hosts.pds.target hosts.pds.modules;
nixery = mkColmenaHost "nixery" hosts.nixery.target hosts.nixery.modules;
spindle = mkColmenaHost "spindle" hosts.spindle.target hosts.spindle.modules;
+
knot1 = mkColmenaHost "knot1" hosts.knot1.target hosts.knot1.modules;
};
};
}
+57
hosts/knot1/configuration.nix
···
+
{ modulesPath
+
, lib
+
, pkgs
+
, ...
+
} @ args:
+
{
+
imports = [
+
(modulesPath + "/installer/scan/not-detected.nix")
+
(modulesPath + "/profiles/qemu-guest.nix")
+
./disk-config.nix
+
];
+
boot.loader.grub = {
+
# no need to set devices, disko will add all devices that have a EF02 partition to the list already
+
# devices = [ ];
+
efiSupport = true;
+
efiInstallAsRemovable = true;
+
};
+
+
networking.hostName = "knot1-ams";
+
services = {
+
openssh.enable = true;
+
};
+
+
+
nix = {
+
extraOptions = ''
+
experimental-features = nix-command flakes ca-derivations
+
warn-dirty = false
+
keep-outputs = false
+
'';
+
};
+
+
environment.systemPackages = map lib.lowPrio [
+
pkgs.curl
+
pkgs.gitMinimal
+
];
+
+
users.users.tangler = {
+
extraGroups = [ "networkmanager" "wheel" "docker" ];
+
openssh.authorizedKeys.keys = args.commonArgs.sshKeys;
+
isNormalUser = true;
+
};
+
+
security.sudo.extraRules = [
+
{
+
users = [ "tangler" ];
+
commands = [
+
{
+
command = "ALL";
+
options = [ "NOPASSWD" ];
+
}
+
];
+
}
+
];
+
+
system.stateVersion = "25.05";
+
}
+56
hosts/knot1/disk-config.nix
···
+
# Example to create a bios compatible gpt partition
+
{ lib, ... }:
+
{
+
disko.devices = {
+
disk.disk1 = {
+
device = lib.mkDefault "/dev/vda";
+
type = "disk";
+
content = {
+
type = "gpt";
+
partitions = {
+
boot = {
+
name = "boot";
+
size = "1M";
+
type = "EF02";
+
};
+
esp = {
+
name = "ESP";
+
size = "500M";
+
type = "EF00";
+
content = {
+
type = "filesystem";
+
format = "vfat";
+
mountpoint = "/boot";
+
};
+
};
+
root = {
+
name = "root";
+
size = "100%";
+
content = {
+
type = "lvm_pv";
+
vg = "pool";
+
};
+
};
+
};
+
};
+
};
+
lvm_vg = {
+
pool = {
+
type = "lvm_vg";
+
lvs = {
+
root = {
+
size = "100%FREE";
+
content = {
+
type = "filesystem";
+
format = "ext4";
+
mountpoint = "/";
+
mountOptions = [
+
"defaults"
+
];
+
};
+
};
+
};
+
};
+
};
+
};
+
}
+11
hosts/knot1/services/knot.nix
···
+
{
+
services.tangled.knot = {
+
enable = true;
+
stateDir = "/home/git";
+
server = {
+
listenAddr = "127.0.0.1:5555";
+
owner = "did:plc:hwevmowznbiukdf6uk5dwrrq";
+
hostname = "knot1.alpha.tangled.sh";
+
};
+
};
+
}
+35
hosts/knot1/services/nginx.nix
···
+
{
+
services.nginx = {
+
enable = true;
+
virtualHosts = {
+
"knot1.alpha.tangled.sh" = {
+
forceSSL = true;
+
enableACME = true;
+
locations."/" = {
+
proxyPass = "http://127.0.0.1:5555";
+
+
extraConfig = ''
+
proxy_set_header X-Forwarded-For $remote_addr;
+
proxy_set_header Host $host;
+
proxy_set_header X-Real-IP $remote_addr;
+
proxy_set_header X-Forwarded-Proto $scheme;
+
'';
+
};
+
locations."/events" = {
+
proxyPass = "http://127.0.0.1:5555";
+
extraConfig = ''
+
proxy_set_header X-Forwarded-For $remote_addr;
+
proxy_set_header Host $host;
+
proxy_set_header Upgrade $http_upgrade;
+
proxy_set_header Connection "upgrade";
+
'';
+
};
+
};
+
};
+
};
+
security.acme = {
+
acceptTerms = true;
+
defaults.email = "team@tangled.org";
+
};
+
networking.firewall.allowedTCPPorts = [ 80 443 ];
+
}