Compare commits

...

10 commits

Author SHA1 Message Date
Maciej Jur c2112ea153
add forgejo 2024-05-13 21:25:59 +02:00
Maciej Jur 6a3e77e142
Refactor 2024-04-07 00:58:22 +02:00
Maciej Jur f7e2f579d6
Add kotori module 2024-04-07 00:38:51 +02:00
Maciej Jur c34fa1674f
Modular server configs 2024-04-07 00:31:22 +02:00
Maciej Jur c6f92e0504
disable syncthing 2024-04-02 00:33:16 +02:00
Maciej Jur beefeed823
disable kotori 2024-04-02 00:17:44 +02:00
Maciej Jur 0abaeefc04
Disable unneeded stuff for now 2023-07-19 19:24:18 +02:00
Maciej Jur 9ee2cab5cb
Missing group for git user 2023-07-19 19:04:15 +02:00
Maciej Jur 1a7d636a77
swap kotori backend 2023-07-19 18:58:53 +02:00
Maciej Jur af1ca1b3a0
Extract kotori from configuration.nix 2023-07-19 18:20:27 +02:00
7 changed files with 238 additions and 85 deletions

49
git.nix Normal file
View file

@ -0,0 +1,49 @@
{ config, pkgs, lib, ... }:
let
domain = "git.kamoshi.org";
user = "forgejo";
state = "/var/lib/forgejo";
in
{
users = {
users.${user} = {
description = "Forgejo Service";
home = state;
group = user;
useDefaultShell = true;
isSystemUser = true;
};
groups.${user} = {};
};
services = {
forgejo = {
enable = true;
user = user;
group = user;
stateDir = state;
# https://forgejo.org/docs/latest/admin/config-cheat-sheet/
settings = {
server = {
HTTP_PORT = 3200;
HTTP_ADDR = "127.0.0.1";
DOMAIN = domain;
ROOT_URL = "https://${domain}/";
LANDING_PAGE = "explore";
};
service = {
DISABLE_REGISTRATION = lib.mkForce true;
};
};
};
nginx.virtualHosts.${domain} = {
enableACME = true;
forceSSL = true;
locations."/" = {
proxyPass = "http://localhost:3200/";
};
};
};
}

View file

@ -3,8 +3,9 @@
imports = imports =
[ [
/etc/nixos/hardware-configuration.nix /etc/nixos/hardware-configuration.nix
./profiles/freshrss.nix # /profiles/freshrss.nix
./profiles/cgit.nix # ./profiles/cgit.nix
# ./profiles/kotori.nix
]; ];
# Use the GRUB 2 boot loader. # Use the GRUB 2 boot loader.
@ -33,11 +34,11 @@
networking = { networking = {
hostName = "kamoshi"; hostName = "kamoshi";
nat = { # nat = {
enable = true; # enable = true;
externalInterface = "eth0"; # externalInterface = "eth0";
internalInterfaces = [ "wg0" ]; # internalInterfaces = [ "wg0" ];
}; # };
firewall = { firewall = {
enable = true; enable = true;
allowedTCPPorts = [ allowedTCPPorts = [
@ -45,46 +46,46 @@
80 # nginx 80 # nginx
443 # nginx TLS 443 # nginx TLS
2222 # ssh 2222 # ssh
22070 22067 # syncthing relay # 22070 22067 # syncthing relay
];
allowedUDPPorts = [
42069 # wireguard
];
interfaces = {
"wg0" = {
allowedTCPPorts = [
8384 22000 # syncthing
];
allowedUDPPorts = [
22000 21027 # syncthing
]; ];
# allowedUDPPorts = [
# 42069 # wireguard
# ];
# interfaces = {
# "wg0" = {
# allowedTCPPorts = [
# 8384 22000 # syncthing
# ];
# allowedUDPPorts = [
# 22000 21027 # syncthing
# ];
# };
# };
}; };
}; # wireguard.interfaces = {
}; # "wg0" = {
wireguard.interfaces = { # ips = [ "10.100.0.1/24" ];
"wg0" = { # listenPort = 42069;
ips = [ "10.100.0.1/24" ]; # postSetup = ''
listenPort = 42069; # ${pkgs.iptables}/bin/iptables -t nat -A POSTROUTING -s 10.100.0.0/24 -o eth0 -j MASQUERADE
postSetup = '' # '';
${pkgs.iptables}/bin/iptables -t nat -A POSTROUTING -s 10.100.0.0/24 -o eth0 -j MASQUERADE # postShutdown = ''
''; # ${pkgs.iptables}/bin/iptables -t nat -D POSTROUTING -s 10.100.0.0/24 -o eth0 -j MASQUERADE
postShutdown = '' # '';
${pkgs.iptables}/bin/iptables -t nat -D POSTROUTING -s 10.100.0.0/24 -o eth0 -j MASQUERADE # privateKeyFile = "/root/secrets/wireguard/kamoshi";
''; #
privateKeyFile = "/root/secrets/wireguard/kamoshi"; # peers = [
# {
peers = [ # publicKey = "26lQ3qCZrZ3hAqLIDfQNrmFQSQv983TeyXpJUY59QkI=";
{ # allowedIPs = [ "10.100.0.2/32" ];
publicKey = "26lQ3qCZrZ3hAqLIDfQNrmFQSQv983TeyXpJUY59QkI="; # }
allowedIPs = [ "10.100.0.2/32" ]; # {
} # publicKey = "W3HCbtf/m/MUZSTTq/Dr9w0mfHjH5eYfOxWtq+eLFXw=";
{ # allowedIPs = [ "10.100.0.3/32" ];
publicKey = "W3HCbtf/m/MUZSTTq/Dr9w0mfHjH5eYfOxWtq+eLFXw="; # }
allowedIPs = [ "10.100.0.3/32" ]; # ];
} # };
]; # };
};
};
}; };
time.timeZone = "Europe/Warsaw"; time.timeZone = "Europe/Warsaw";
@ -101,9 +102,9 @@
vim vim
wget wget
neovim neovim
neofetch # neofetch
nushell # nushell
wireguard-tools # wireguard-tools
]; ];
services = { services = {
@ -133,25 +134,25 @@
}; };
}; };
}; };
syncthing = { # syncthing = {
enable = true; # enable = true;
user = "kamov"; # user = "kamov";
dataDir = "/home/kamov/sync"; # dataDir = "/home/kamov/sync";
configDir = "/home/kamov/sync/.config"; # configDir = "/home/kamov/sync/.config";
guiAddress = "0.0.0.0:8384"; # guiAddress = "0.0.0.0:8384";
extraOptions.gui = { # extraOptions.gui = {
user = "admin"; # user = "admin";
password = "admin"; # password = "admin";
}; # };
# public relay options # # public relay options
relay = { # relay = {
enable = true; # enable = true;
providedBy = "kamoshi.org"; # providedBy = "kamoshi.org";
statusPort = 22070; # statusPort = 22070;
port = 22067; # port = 22067;
globalRateBps = 25000; # globalRateBps = 25000;
}; # };
}; # };
}; };
security.acme = { security.acme = {
@ -159,20 +160,6 @@
defaults.email = "maciej@kamoshi.org"; defaults.email = "maciej@kamoshi.org";
}; };
virtualisation = {
docker.enable = true;
oci-containers = {
backend = "docker";
containers = {
kotori = {
image = "kamov/kotori";
environmentFiles = [ /root/secrets/kotori.env ];
autoStart = true;
};
};
};
};
# This value determines the NixOS release from which the default # This value determines the NixOS release from which the default
# settings for stateful data, like file locations and database versions # settings for stateful data, like file locations and database versions
# on your system were taken. It's perfectly fine and recommended to leave # on your system were taken. It's perfectly fine and recommended to leave

View file

@ -8,6 +8,7 @@ in
isSystemUser = true; isSystemUser = true;
description = "git user"; description = "git user";
home = home; home = home;
group = "users";
shell = "${pkgs.git}/bin/git-shell"; shell = "${pkgs.git}/bin/git-shell";
openssh.authorizedKeys.keyFiles = [ openssh.authorizedKeys.keyFiles = [
/root/secrets/ssh/kamov.pub /root/secrets/ssh/kamov.pub

19
kotori.nix Normal file
View file

@ -0,0 +1,19 @@
{ config, pkgs, ... }:
{
virtualisation = {
podman = {
enable = true;
dockerCompat = true;
};
oci-containers = {
backend = "podman";
containers = {
kotori = {
image = "kamov/kotori:latest";
environmentFiles = [ /root/.secrets/kotori.env ];
autoStart = true;
};
};
};
};
}

31
nix.nix Normal file
View file

@ -0,0 +1,31 @@
{ config, pkgs, ... }:
{
system = {
autoUpgrade = {
enable = true;
allowReboot = true;
};
};
nix = {
optimise.automatic = true;
gc = {
automatic = true;
dates = "weekly";
options = "--delete-older-than 30d";
};
};
networking = {
firewall = {
enable = true;
};
};
environment.systemPackages = with pkgs; [
git
vim
wget
neovim
];
}

25
ssh.nix Normal file
View file

@ -0,0 +1,25 @@
{ config, pkgs, ... }:
{
users.users.kamov = {
isNormalUser = true;
extraGroups = [ "wheel" "www" ];
openssh.authorizedKeys.keyFiles = [ /root/.ssh/kamov.pub ];
};
networking.firewall.allowedTCPPorts = [ 22 2222 ];
services = {
endlessh = {
enable = true;
port = 22;
};
openssh = {
enable = true;
ports = [ 2222 ];
settings = {
PasswordAuthentication = false;
KbdInteractiveAuthentication = false;
};
};
};
}

41
web.nix Normal file
View file

@ -0,0 +1,41 @@
{ config, pkgs, ... }:
{
# Group for people who can edit the website
users.groups.www = {};
# Directory for web content
systemd.tmpfiles.rules = [
"d /var/www/kamoshi.org 775 root www"
];
# Automatically renew certs
security.acme = {
acceptTerms = true;
defaults.email = "maciej@kamoshi.org";
};
networking.firewall.allowedTCPPorts = [ 80 443 ];
services = {
nginx = {
enable = true;
recommendedTlsSettings = true;
recommendedGzipSettings = true;
recommendedOptimisation = true;
recommendedProxySettings = true;
virtualHosts."kamoshi.org" = {
root = "/var/www/kamoshi.org";
forceSSL = true;
enableACME = true;
listen = [
{ addr = "[::]"; port = 80; ssl = false; }
{ addr = "0.0.0.0"; port = 80; ssl = false; }
{ addr = "[::]"; port = 443; ssl = true; }
{ addr = "0.0.0.0"; port = 443; ssl = true; }
];
};
};
};
}