about summary refs log tree commit diff
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2017-07-08 14:41:57 +0200
committerProfpatsch <mail@profpatsch.de>2017-07-08 14:42:19 +0200
commita232772ebb63c27b530c9bac5fd53b3584dc7fc5 (patch)
tree64fcbbc19bd4983b5f22d96ad7b3d735ad65b8b4
parent8380a6435e03d75e23840cc66d7b669df40dc7bf (diff)
machines/haku: refactor a bit to include into base server config
Until now, the config on the actual server was deviating because I changed it
locally.
-rw-r--r--machines/profpatsch/base-server.nix15
-rw-r--r--machines/profpatsch/base.nix10
-rw-r--r--machines/profpatsch/haku.nix25
-rw-r--r--modules/user/openlab/stackenblocken.nix1
4 files changed, 44 insertions, 7 deletions
diff --git a/machines/profpatsch/base-server.nix b/machines/profpatsch/base-server.nix
index 893df1ae..9d0a6819 100644
--- a/machines/profpatsch/base-server.nix
+++ b/machines/profpatsch/base-server.nix
@@ -1,7 +1,7 @@
-{ config, pkgs, ... }:
+{ config, pkgs, lib, ... }:
 
 let
-  sshPort = 6879;
+  cfg = config.vuizvui.user.profpatsch.server;
 
 in
 {
@@ -9,6 +9,13 @@ in
     ./base.nix
   ];
 
+  options.vuizvui.user.profpatsch.server.sshPort = lib.mkOption {
+    description = "ssh port";
+    # TODO: replace with types.intBetween https://github.com/NixOS/nixpkgs/pull/27239
+    type = with lib.types; addCheck int (x: x >= 0 && x <= 65535);
+    default = 6879;
+  };
+
   config = {
 
     boot.cleanTmpDir = true;
@@ -17,13 +24,13 @@ in
 
     services.openssh = {
       enable = true;
-      listenAddresses = [ { addr = "0.0.0.0"; port = sshPort; } ];
+      listenAddresses = [ { addr = "0.0.0.0"; port = cfg.sshPort; } ];
     };
 
     networking.firewall = {
       enable = true;
       allowPing = true;
-      allowedTCPPorts = [ sshPort ];
+      allowedTCPPorts = [ cfg.sshPort ];
     };
 
   };
diff --git a/machines/profpatsch/base.nix b/machines/profpatsch/base.nix
index 7a450d2e..5c4082f0 100644
--- a/machines/profpatsch/base.nix
+++ b/machines/profpatsch/base.nix
@@ -14,7 +14,7 @@ in
 
     programs.bash = {
       loginShellInit = ''
-        alias c='vim /etc/nixos/configuration.nix'
+        alias c='vim /root/vuizvui/machines/profpatsch'
         alias nsp='nix-shell -p'
         alias nrs='nixos-rebuild switch'
         alias tad='tmux attach -d'
@@ -33,6 +33,14 @@ in
       myPkgs.vim        # slight improvement over vi
     ];
 
+    i18n = {
+      defaultLocale = "en_US.UTF-8";
+      # TODO
+      # extraLocales = {
+      #   LC_TIME = "de_DE.UTF-8"; #"en_DK.UTF-8";
+      # };
+    };
+
     # Nobody wants mutable state. :)
     users.mutableUsers = false;
 
diff --git a/machines/profpatsch/haku.nix b/machines/profpatsch/haku.nix
index c94484aa..64e1472d 100644
--- a/machines/profpatsch/haku.nix
+++ b/machines/profpatsch/haku.nix
@@ -4,6 +4,8 @@ let
   myLib  = import ./lib.nix  { inherit pkgs lib; };
   myPkgs = import ./pkgs.nix { inherit pkgs lib myLib; };
 
+  warpspeedPort = 1338;
+
   myKey = "ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDNMQvmOfon956Z0ZVdp186YhPHtSBrXsBwaCt0JAbkf/U/P+4fG0OROA++fHDiFM4RrRHH6plsGY3W6L26mSsCM2LtlHJINFZtVILkI26MDEIKWEsfBatDW+XNAvkfYEahy16P5CBtTVNKEGsTcPD+VDistHseFNKiVlSLDCvJ0vMwOykHhq+rdJmjJ8tkUWC2bNqTIH26bU0UbhMAtJstWqaTUGnB0WVutKmkZbnylLMICAvnFoZLoMPmbvx8efgLYY2vD1pRd8Uwnq9MFV1EPbkJoinTf1XSo8VUo7WCjL79aYSIvHmXG+5qKB9ed2GWbBLolAoXkZ00E4WsVp9H philip@nyx";
 
 in
@@ -14,7 +16,6 @@ in
   ];
 
   config = {
-
     boot.loader.grub.device = "/dev/sda";
     fileSystems = {
       "/" = {
@@ -29,6 +30,7 @@ in
 
     environment.systemPackages = with pkgs; [
       rtorrent                          # bittorrent client
+      mktorrent                         # torrent file creator
       pkgs.vuizvui.profpatsch.warpspeed # trivial http file server
     ];
 
@@ -51,6 +53,15 @@ in
       };
     };
 
+    systemd.services.warpspeed = 
+      let user = config.users.users.rtorrent;
+      in {
+        description = "internally served public files (see nginx)";
+        wantedBy = [ "default.target" ];
+        environment = { PORT = toString warpspeedPort; };
+        script = "${pkgs.vuizvui.profpatsch.warpspeed}/bin/warpspeed ${user.home}/public";
+        serviceConfig.User = config.users.users.rtorrent.name;
+      };
 
     services.nginx = {
       enable = true;
@@ -58,13 +69,23 @@ in
         forceSSL = true;
         enableACME = true;
         locations."/pub/" = {
-          proxyPass = "http://localhost:1338/";
+          proxyPass = "http://localhost:${toString warpspeedPort}/";
         };
         locations."/".root = pkgs.writeTextDir "index.html" ''hello world'';
         serverAliases = [ "lojbanistan.de" ];
       };
     };
 
+    services.mlmmj = {
+      enable = true;
+      listDomain = "cz.profpatsch.de";
+      mailLists = [ "worship" ];
+    };
+    services.postfix = {
+      # mostly configured by mlmmj
+      hostname = "cz.profpatsch.de";
+      postmasterAlias = "mail@profpatsch.de";
+    };
 
     networking = {
       hostName = "haku";
diff --git a/modules/user/openlab/stackenblocken.nix b/modules/user/openlab/stackenblocken.nix
index 4a5630fe..421b64e9 100644
--- a/modules/user/openlab/stackenblocken.nix
+++ b/modules/user/openlab/stackenblocken.nix
@@ -16,6 +16,7 @@ in
     volume = mkOption {
       description = "Volume in percent";
       default = 50;
+      # TODO: replace with types.intBetween https://github.com/NixOS/nixpkgs/pull/27239
       type = types.addCheck types.int (x: x >= 0 && x <= 100);
     };
   };