From 1bb2ca0edf8043a85c197dd2cd2c29a1ef60e8fc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Motiejus=20Jak=C5=A1tys?= Date: Tue, 3 Jan 2023 12:31:37 +0200 Subject: [PATCH] add configuration.nix --- configuration.nix | 145 ++++++++++++++++++++++++++++++ krops.nix | 4 + secrets/hel1-a.zfs-passphrase.gpg | Bin 0 -> 611 bytes secrets/hel1-a/zfs-passphrase.gpg | Bin 611 -> 0 bytes 4 files changed, 149 insertions(+) create mode 100644 configuration.nix create mode 100644 secrets/hel1-a.zfs-passphrase.gpg delete mode 100644 secrets/hel1-a/zfs-passphrase.gpg diff --git a/configuration.nix b/configuration.nix new file mode 100644 index 0000000..9cac2f5 --- /dev/null +++ b/configuration.nix @@ -0,0 +1,145 @@ +# Edit this configuration file to define what should be installed on +# your system. Help is available in the configuration.nix(5) man page +# and in the NixOS manual (accessible by running ‘nixos-help’). + +{ config, pkgs, ... }: + +let ssh_pubkeys = { + motiejus = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAACAQC+qpaaD+FCYPcUU1ONbw/ff5j0xXu5DNvp/4qZH/vOYwG13uDdfI5ISYPs8zNaVcFuEDgNxWorVPwDw4p6+1JwRLlhO4J/5tE1w8Gt6C7y76LRWnp0rCdva5vL3xMozxYIWVOAiN131eyirV2FdOaqTwPy4ouNMmBFbibLQwBna89tbFMG/jwR7Cxt1I6UiYOuCXIocI5YUbXlsXoK9gr5yBRoTjl2OfH2itGYHz9xQCswvatmqrnteubAbkb6IUFYz184rnlVntuZLwzM99ezcG4v8/485gWkotTkOgQIrGNKgOA7UNKpQNbrwdPAMugqfSTo6g8fEvy0Q+6OXdxw5X7en2TJE+BLVaXp4pVMdOAzKF0nnssn64sRhsrUtFIjNGmOWBOR2gGokaJcM6x9R72qxucuG5054pSibs32BkPEg6Qzp+Bh77C3vUmC94YLVg6pazHhLroYSP1xQjfOvXyLxXB1s9rwJcO+s4kqmInft2weyhfaFE0Bjcoc+1/dKuQYfPCPSB//4zvktxTXud80zwWzMy91Q4ucRrHTBz3PrhO8ys74aSGnKOiG3ccD3HbaT0Ff4qmtIwHcAjrnNlINAcH/A2mpi0/2xA7T8WpFnvgtkQbcMF0kEKGnNS5ULZXP/LC8BlLXxwPdqTzvKikkTb661j4PhJhinhVwnQ=="; + vno1_root = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIMiWb7yeSeuFCMZWarKJD6ZSxIlpEHbU++MfpOIy/2kh"; +}; in { + imports = + [ + /etc/nixos/hardware-configuration.nix /etc/nixos/zfs.nix + ]; + + boot.initrd.network.enable = true; + boot.initrd.network.ssh = { + enable = true; + port = 22; + authorizedKeys = builtins.attrValues ssh_pubkeys; + hostKeys = [ "/etc/secrets/initrd/ssh_host_ed25519_key" ]; + }; + + services.zfs.autoSnapshot = { + enable = true; + frequent = 0; + hourly = 24; + daily = 7; + weekly = 0; + monthly = 0; + }; + + services.zfs.autoScrub.enable = true; + services.zfs.trim.enable = true; + + networking.hostName = "hel1-a"; + time.timeZone = "UTC"; + + users.users.motiejus = { + isNormalUser = true; + extraGroups = [ "wheel" ]; + }; + users.users.motiejus.openssh.authorizedKeys.keys = [ ssh_pubkeys.motiejus ]; + users.mutableUsers = false; + + security.sudo.wheelNeedsPassword = false; + security.sudo.execWheelOnly = true; + + environment.systemPackages = with pkgs; [ + jq + vim + git + tmux + tree + wget + lsof + file + htop + ncdu + ripgrep + binutils + pciutils + headscale + nixos-option + ]; + + programs.mtr.enable = true; + + services.openssh.enable = true; + services.openssh.passwordAuthentication = false; + services.openssh.permitRootLogin = "no"; + + services.locate = { + enable = true; + locate = pkgs.plocate; + 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" ]; + dns_config = { + nameservers = [ "1.1.1.1" "8.8.4.4" ]; + magic_dns = true; + base_domain = "jakst"; + }; + }; + }; + + 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.service.DISABLE_REGISTRATION = 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 ]; + + 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? + +} + diff --git a/krops.nix b/krops.nix index 8ee432c..dc60e1b 100644 --- a/krops.nix +++ b/krops.nix @@ -9,6 +9,10 @@ let { nixpkgs.symlink = "/root/.nix-defexpr/channels/nixos"; nixos-config.file = toString ./configuration.nix; + secrets.pass = { + dir = toString ./secrets; + name = "hel1-a"; + }; } ]; diff --git a/secrets/hel1-a.zfs-passphrase.gpg b/secrets/hel1-a.zfs-passphrase.gpg new file mode 100644 index 0000000000000000000000000000000000000000..fecd6483883cf856f6c7546f7a59b2442494b77e GIT binary patch literal 611 zcmV-p0-XJY0t^EH00000000015C3zU0=nDurOUI!0aeO%eS_0jL`mMW71L~Fgc&CC z57JD{ig~RgEPMZUm8!GL{bWRvuj5E#t+N>Ktv|idSYdc<&^{xyjpWjI)vhr8#5dL~ zW2#57!-`X1_+Fh zTlP-m!}?D(d0dTt*8XXjiokTs0W6EYWjYi(tB5B1fKv7Vqt9yejCf-P?3mNf<2g7o zF$xgg+D12cHdrlY>9ca!3l4ih!B=8J?}HjbeIr0mF@chGN5kcr&ODk4J`1l`(fAka zO&yu3+!t*U9{5Y->@4|arXrS=VwxbEgJp|N9KyWDr0U>B0&sSxQO^grfd&6=6JY z;~onmwPxS4IrnHFr7F@=0TDakULI>guxU^A=wl3A!E{FgC literal 0 HcmV?d00001 diff --git a/secrets/hel1-a/zfs-passphrase.gpg b/secrets/hel1-a/zfs-passphrase.gpg deleted file mode 100644 index e34cf00794d9be356c290b9b2ce75e2f7daf7cb0..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 611 zcmV-p0-XJY0t^EH00000000015B@YF$0pC*<^Ou;ni0qCRj=2T;es3WS5gp#zKxEZ zD{&h@QSLV$a5bPnFg7>LwRs3DJ{{G?BsB8JqZ;E;2$ zwX(vgF!<*Ma#C=5?1xIpf-p=_5Aoa*7^8@|mBCdFBk?kC3@w8o z>PT_%&E-EN&Dc6(JPW+7HEA+9R$Gw~rDE|RPp>t5wLvT15lgv*L&SPfOHjq4sTU92T+Msqkc^01EAM5IXJVt}+!^-pKOm5IJXRLsR*Z16O3m64@M zrcwP z#b&_RSrY_5`k(ig-zd^j0SIm|08iZ!zHG!V4ykNf!Xos!RV9}KlgGFl&-A==u--08 xc3yyZxL>*!by$L*oyndzCv#m^9Df&8h`e-`TvMnphyEdEH-{NS6pl(F)@$