S5GPMMOWQ7AAMERJR4CAOU3QEINCLCSG5OAI4R2HJE3NF6DJSWRQC
CM2R5CCC4BV75P2MBA4X6OS2H6GQ5BAS34LSU6Y5X3SVKBAFT24AC
F26DJCZ7RLGRDZSYACB6MGMNTW7L5FE332EBYEIJTBRK7QJ6ZIYAC
H3GYCX27WTONFBIJN7UIV26LJSCENQJC4XXIOEYINXJLEDGKYJJQC
BYZGRIFZY253OFK442SR6X743U4LAX4NLFBQ4XPKXEDPPXNNUM4AC
YVZDXEX34EVRGBLOY4LIDKPFZVMTINZQ5UCAJVDMYSBWIDFPNBQQC
ZGEGHEOD2S77CSNWOOFVB7Q3RGOU3WOWDOXJ4S2LKAS2JMS3UAZAC
HYAPQQOH67GIKQFGP45GE2DFC3WCQTAJUXHQDDK6FZQUGMZ2CZQQC
532JIID6XB4NFSIFUA64VEBKWSEJB4AY5OUBIEFUDMWXO7UAZW2QC
2EFJUR2TVLHO4R4YRZFLOJKC742HPFI5MOA7II3Y3Z3KOHDNE5JAC
FH5X6FMOHRX5CZVY6P6X6BVQH5Q5C3XV6DGWR4QJZORAMFEXQHUQC
{
config,
lib,
pkgs,
modulesPath,
user,
...
}: let
formatJson = pkgs.formats.json {};
in {
imports = [./common.nix ./scaleway-module.nix (modulesPath + "/profiles/qemu-guest.nix") ./ssh.nix];
boot.supportedFilesystems = ["btrfs"];
boot.loader.grub.device = "/dev/vda";
boot.initrd.availableKernelModules = ["ata_piix" "uhci_hcd" "xen_blkfront"];
boot.initrd.kernelModules = ["nvme"];
fileSystems."/" = {
device = "/dev/vda1";
fsType = "ext4";
};
fileSystems."/nix" = {
device = "/dev/sda";
fsType = "btrfs";
options = ["compress=zstd" "noatime"];
};
boot.cleanTmpDir = true;
zramSwap.enable = true;
networking.hostName = "satelite";
networking.firewall.allowedTCPPorts = [80 443 8448 2222];
boot.scaleway = true;
environment.systemPackages = with pkgs; [
vim
foot.terminfo
alacritty.terminfo
];
mailserver = {
enable = true;
fqdn = "mail.nrab.lol";
domains = ["nrab.lol"];
# nix run nixpkgs.apacheHttpd -c htpasswd -nbB "" "super secret password" | cut -d: -f2
loginAccounts = {
"1337@nrab.lol" = {
hashedPasswordFile = pkgs.copyPathToStore ../assets/leetpassword;
};
};
certificateScheme = 3;
};
services.matrix-conduit = {
enable = true;
settings.global = {
server_name = "nrab.lol";
database_backend = "rocksdb";
allow_registration = false;
};
};
security.acme = {
acceptTerms = true;
defaults.email = "nikodem@rabulinski.com";
};
users.users.nginx.extraGroups = ["acme"];
services.nginx = {
enable = true;
recommendedProxySettings = true;
virtualHosts = {
"nrab.lol" = {
forceSSL = true;
enableACME = true;
locations."=/.well-known/matrix/server" = {
alias = formatJson.generate "well-known-matrix-server" {
"m.server" = "matrix.nrab.lol";
};
extraConfig = ''
default_type application/json;
add_header Access-Control-Allow-Origin "*";
'';
};
locations."=/.well-known/matrix/client" = {
alias = formatJson.generate "well-known-matrix-client" {
"m.homeserver" = {
"base_url" = "https://matrix.nrab.lol";
};
};
extraConfig = ''
default_type application/json;
add_header Access-Control-Allow-Origin "*";
'';
};
};
"matrix.nrab.lol" = {
forceSSL = true;
enableACME = true;
listen = [
{
addr = "0.0.0.0";
port = 80;
}
{
addr = "0.0.0.0";
port = 443;
ssl = true;
}
{
addr = "0.0.0.0";
port = 8448;
ssl = true;
}
];
extraConfig = ''
merge_slashes off;
'';
locations."/_matrix/" = {
proxyPass = "http://backend_conduit$request_uri";
proxyWebsockets = true;
extraConfig = ''
proxy_set_header Host $host;
proxy_buffering off;
'';
};
};
};
upstreams."backend_conduit".servers = {
"localhost:${toString config.services.matrix-conduit.settings.global.port}" = {};
};
};
}
{
options = with lib.types; {
boot.scaleway = with lib.types;
lib.mkOption {
description = "Automatically configure the system from scaleway's metadata";
type = bool;
default = false;
};
};
config = lib.mkIf config.boot.scaleway {
boot.kernelParams = ["console=ttyS0,115200n8"];
boot.loader.grub.extraConfig = ''
serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1
terminal_input console
terminal_output console
'';
networking.useDHCP = false;
networking.useNetworkd = true;
networking.interfaces.ens2 = {
useDHCP = true;
ipv4.routes = [
{
address = "169.254.42.42";
prefixLength = 32;
}
];
};
services.openssh.authorizedKeysFiles = [
"/run/scw-autoconf/ssh-keys/%u"
];
systemd.services.scw-autoconfig = {
serviceConfig.Type = "oneshot";
after = ["network.target"];
script = ''
install -o 0 -g 0 -m 755 -d /run/scw-autoconf
install -o 0 -g 0 -m 755 -d /run/scw-autoconf/ssh-keys
${pkgs.curl}/bin/curl --local-port 1-1024 http://169.254.42.42/conf?format=json >/run/scw-autoconf/config.json
${pkgs.jq}/bin/jq -r '.ssh_public_keys | .[] | .key' </run/scw-autoconf/config.json >/run/scw-autoconf/ssh-keys/root
'';
wantedBy = ["multi-user.target"];
};
};
}
config,
pkgs,
lib,
...
}: {
{
config,
pkgs,
lib,
...
}: {
options = with lib.types; {
boot.scaleway = with lib.types;
lib.mkOption {
description = "Automatically configure the system from scaleway's metadata";
type = bool;
default = false;
};
};
config = lib.mkIf config.boot.scaleway {
boot.kernelParams = ["console=ttyS0,115200n8"];
boot.loader.grub.extraConfig = ''
serial --speed=115200 --unit=0 --word=8 --parity=no --stop=1
terminal_input console
terminal_output console
'';
networking.useDHCP = false;
networking.useNetworkd = true;
networking.interfaces.ens2 = {
useDHCP = true;
ipv4.routes = [
{
address = "169.254.42.42";
prefixLength = 32;
}
];
};
services.openssh.authorizedKeysFiles = [
"/run/scw-autoconf/ssh-keys/%u"
];
systemd.services.scw-autoconfig = {
serviceConfig.Type = "oneshot";
after = ["network.target"];
script = ''
install -o 0 -g 0 -m 755 -d /run/scw-autoconf
install -o 0 -g 0 -m 755 -d /run/scw-autoconf/ssh-keys
${pkgs.curl}/bin/curl --local-port 1-1024 http://169.254.42.42/conf?format=json >/run/scw-autoconf/config.json
${pkgs.jq}/bin/jq -r '.ssh_public_keys | .[] | .key' </run/scw-autoconf/config.json >/run/scw-autoconf/ssh-keys/root
'';
wantedBy = ["multi-user.target"];
};
};
}
flake.nixosConfigurations.satelite = withSystem "x86_64-linux" ({
system,
self',
...
}: let
inherit (inputs) nixpkgs home-manager mailserver;
user = self'.lib.const.user;
in
nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = {inherit user;};
flake.nixosConfigurations.satelite = withSystem "x86_64-linux" (
{
system,
self',
...
}: let
inherit (inputs) nixpkgs home-manager mailserver;
user = self'.lib.const.user;
in
self'.lib.mkSystem {
system = {
imports = [
mailserver.nixosModule
self.nixosModules.scaleway
../../nixos/ssh.nix
./configuration.nix
];
};
home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true;
home-manager.users.${user} = self'.lib.mkHome {
imports = [
../../home-manager/pijul.nix
];
};
services.matrix-conduit.package = self'.packages.conduit-latest;
}
];
});
};
}
);
{
config,
lib,
pkgs,
modulesPath,
user,
...
}: {
imports = [
./conduit.nix
(modulesPath + "/profiles/qemu-guest.nix")
];
boot.supportedFilesystems = ["btrfs"];
boot.loader.grub.device = "/dev/vda";
boot.initrd.availableKernelModules = ["ata_piix" "uhci_hcd" "xen_blkfront"];
boot.initrd.kernelModules = ["nvme"];
fileSystems."/" = {
device = "/dev/vda1";
fsType = "ext4";
};
fileSystems."/nix" = {
device = "/dev/sda";
fsType = "btrfs";
options = ["compress=zstd" "noatime"];
};
boot.cleanTmpDir = true;
zramSwap.enable = true;
networking.hostName = "satelite";
networking.firewall.allowedTCPPorts = [80 443 8448 2222];
boot.scaleway = true;
environment.systemPackages = with pkgs; [
vim
foot.terminfo
alacritty.terminfo
];
mailserver = {
enable = true;
fqdn = "mail.nrab.lol";
domains = ["nrab.lol"];
# nix shell nixpkgs#apacheHttpd -c htpasswd -nbB "" "super secret password" | cut -d: -f2
loginAccounts = {
"1337@nrab.lol" = {
hashedPasswordFile = pkgs.copyPathToStore ../../assets/leetpassword;
};
};
certificateScheme = 3;
};
}
{
config,
pkgs,
self',
...
}: let
formatJson = pkgs.formats.json {};
in {
services.matrix-conduit = {
enable = true;
package = self'.packages.conduit-latest;
settings.global = {
server_name = "nrab.lol";
database_backend = "rocksdb";
allow_registration = false;
};
};
security.acme = {
acceptTerms = true;
defaults.email = "nikodem@rabulinski.com";
};
users.users.nginx.extraGroups = ["acme"];
services.nginx = {
enable = true;
recommendedProxySettings = true;
virtualHosts = {
"nrab.lol" = {
forceSSL = true;
enableACME = true;
locations."=/.well-known/matrix/server" = {
alias = formatJson.generate "well-known-matrix-server" {
"m.server" = "matrix.nrab.lol";
};
extraConfig = ''
default_type application/json;
add_header Access-Control-Allow-Origin "*";
'';
};
locations."=/.well-known/matrix/client" = {
alias = formatJson.generate "well-known-matrix-client" {
"m.homeserver" = {
"base_url" = "https://matrix.nrab.lol";
};
};
extraConfig = ''
default_type application/json;
add_header Access-Control-Allow-Origin "*";
'';
};
};
"matrix.nrab.lol" = {
forceSSL = true;
enableACME = true;
listen = [
{
addr = "0.0.0.0";
port = 80;
}
{
addr = "0.0.0.0";
port = 443;
ssl = true;
}
{
addr = "0.0.0.0";
port = 8448;
ssl = true;
}
];
extraConfig = ''
merge_slashes off;
'';
locations."/_matrix/" = {
proxyPass = "http://backend_conduit$request_uri";
proxyWebsockets = true;
extraConfig = ''
proxy_set_header Host $host;
proxy_buffering off;
'';
};
};
};
upstreams."backend_conduit".servers = {
"localhost:${toString config.services.matrix-conduit.settings.global.port}" = {};
};
};
}
system = {
pkgs,
lib,
...
}: {
imports = [./configuration.nix];
nixpkgs = {
overlays = [
nur.overlay
niko-nur.overlay
(final: prev: {
x86-compat = import nixpkgs {system = "x86_64-darwin";};
qutebrowser = final.qutebrowser-bin;
})
firefox-darwin.overlay
];
config.allowUnfreePredicate = pkg:
builtins.elem (lib.getName pkg) [
"slack"
];
};
};
system = ./configuration.nix;