X-Git-Url: https://git.immae.eu/?p=perso%2FImmae%2FConfig%2FNix.git;a=blobdiff_plain;f=nixops%2Feldiron.nix;h=d62f022b759ca14879fa70d92816f52b29e0bccb;hp=337ea2f376bfd8a5ae7172bc14d1ed82f2980adf;hb=f5efae0f8c4c53798f8f9fc88c5f92f38a223320;hpb=01f21083a897b86bf148f1d2bb9c8edca4d3786a diff --git a/nixops/eldiron.nix b/nixops/eldiron.nix index 337ea2f..d62f022 100644 --- a/nixops/eldiron.nix +++ b/nixops/eldiron.nix @@ -1,3 +1,4 @@ +{ privateFiles ? ./. }: { network = { description = "Immae's network"; @@ -5,45 +6,69 @@ }; eldiron = { config, pkgs, mylibs, myconfig, ... }: - with mylibs; { + nixpkgs.overlays = builtins.attrValues (import ../overlays); _module.args = { - mylibs = import ../libs.nix; + pkgsNext = import {}; + pkgsPrevious = import {}; + mylibs = import ../libs.nix { inherit pkgs; }; myconfig = { - env = import ./environment.nix; - ips = { - main = "176.9.151.89"; - production = "176.9.151.154"; - integration = "176.9.151.155"; - }; + inherit privateFiles; + env = import "${privateFiles}/environment.nix"; }; }; + boot.kernelPackages = pkgs.linuxPackages_latest; + + networking = { + firewall.enable = true; + # 176.9.151.89 declared in nixops -> infra / tools + interfaces."eth0".ipv4.addresses = pkgs.lib.attrsets.mapAttrsToList + (n: ips: { address = ips.ip4; prefixLength = 32; }) + (pkgs.lib.attrsets.filterAttrs (n: v: n != "main") myconfig.env.servers.eldiron.ips); + interfaces."eth0".ipv6.addresses = pkgs.lib.flatten (pkgs.lib.attrsets.mapAttrsToList + (n: ips: map (ip: { address = ip; prefixLength = (if n == "main" && ip == pkgs.lib.head ips.ip6 then 64 else 128); }) (ips.ip6 or [])) + myconfig.env.servers.eldiron.ips); + }; + imports = [ + ./modules/ssh ./modules/certificates.nix ./modules/gitolite ./modules/databases + ./modules/mpd ./modules/websites + ./modules/mail + ./modules/ftp + ./modules/pub + ./modules/task + ./modules/irc + ./modules/buildbot + ./modules/dns + ./modules/secrets ]; services.myGitolite.enable = true; services.myDatabases.enable = true; services.myWebsites.production.enable = true; services.myWebsites.integration.enable = true; services.myWebsites.tools.enable = true; + services.pure-ftpd.enable = true; + services.irc.enable = true; + services.pub.enable = true; + services.myTasks.enable = true; + services.buildbot.enable = true; - networking = { - firewall = { - enable = true; - allowedTCPPorts = [ 22 ]; - }; - }; + services.journald.extraConfig = '' + MaxLevelStore="warning" + MaxRetentionSec="1year" + ''; deployment = { targetEnv = "hetzner"; hetzner = { robotUser = myconfig.env.hetzner.user; robotPass = myconfig.env.hetzner.pass; - mainIPv4 = myconfig.ips.main; + mainIPv4 = myconfig.env.servers.eldiron.ips.main.ip4; partitions = '' clearpart --all --initlabel --drives=sda,sdb @@ -58,35 +83,30 @@ }; }; - environment.systemPackages = [ + users.users.root.packages = [ pkgs.telnet pkgs.htop - pkgs.vim + pkgs.iftop ]; - services.openssh.extraConfig = '' - AuthorizedKeysCommand /etc/ssh/ldap_authorized_keys - AuthorizedKeysCommandUser nobody - ''; + environment.systemPackages = [ + pkgs.vim + ]; - environment.etc."ssh/ldap_authorized_keys" = let - ldap_authorized_keys = - wrap { - name = "ldap_authorized_keys"; - file = ./ldap_authorized_keys.sh; - vars = { - LDAP_PASS = myconfig.env.sshd.ldap.password; - GITOLITE_SHELL = "${pkgs.gitolite}/bin/gitolite-shell"; - ECHO = "${pkgs.coreutils}/bin/echo"; - }; - paths = [ pkgs.openldap pkgs.stdenv.shellPackage pkgs.gnugrep pkgs.gnused pkgs.coreutils ]; - }; - in { + services.cron = { enable = true; - mode = "0755"; - user = "root"; - source = ldap_authorized_keys; + systemCronJobs = [ + '' + # The star after /var/lib/* avoids deleting all folders in case of problem + 0 3,9,15,21 * * * root rsync -e "ssh -i /root/.ssh/id_charon_vpn" -aAXvz --delete --numeric-ids --super --rsync-path="sudo rsync" /var/lib/* immae@immae.eu: > /dev/null + '' + ]; }; + # This value determines the NixOS release with which your system is + # to be compatible, in order to avoid breaking some software such as + # database servers. You should change this only after NixOS release + # notes say you should. + system.stateVersion = "18.09"; # Did you read the comment? }; }