about summary refs log tree commit diff
path: root/machines/profpatsch/base-server.nix
diff options
context:
space:
mode:
authorProfpatsch <mail@profpatsch.de>2020-12-30 18:30:53 +0100
committerProfpatsch <mail@profpatsch.de>2020-12-30 18:33:31 +0100
commit47a8bf4dd2cb1f6778b38bc2f4990ba72366d5a9 (patch)
tree51b7b6e249c32b8d466de66b1e421ebf89d1999d /machines/profpatsch/base-server.nix
parent2c24ba1d864d98d4c2c3a50501a41b61b43f854a (diff)
machines/profpatsch/base-server: convert module to toml definition
This is a working PoC of specifying module configs as toml
configuration with simple to understand semantics.

Both the option definitions and the actual config values can be
specified via the toml DSL.

This is extremely happy-path for now, so errors are gonna be horrible.
Diffstat (limited to 'machines/profpatsch/base-server.nix')
-rw-r--r--machines/profpatsch/base-server.nix51
1 files changed, 29 insertions, 22 deletions
diff --git a/machines/profpatsch/base-server.nix b/machines/profpatsch/base-server.nix
index 921e5d8d..7b0a714a 100644
--- a/machines/profpatsch/base-server.nix
+++ b/machines/profpatsch/base-server.nix
@@ -1,36 +1,43 @@
 { config, pkgs, lib, ... }:
 
 let
-  cfg = config.vuizvui.user.profpatsch.server;
+  cfgImports = (import ../../pkgs/profpatsch/nixos-toml-modules.nix { inherit lib; }).readAnyToml ./base-server.toml
+    config;
 
 in
 {
-  imports = [
-    ./base.nix
-  ];
+  inherit (cfgImports) imports;
 
-  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;
-  };
+  # TODO: cannot read options from pkgs because it would lead to an infinite recursion
+  # in the module system, since the pkgs passed into this module already requires all options.
+  options = ((import ../../pkgs/profpatsch/nixos-toml-modules.nix { inherit lib; }).readAnyToml ./base-server-options.toml).options
+    ;
 
-  config = {
+  config = cfgImports.config;
 
-    programs.mosh.enable = true;
 
-    services.openssh = {
-      enable = true;
-      listenAddresses = [ { addr = "0.0.0.0"; port = cfg.sshPort; } ];
-    };
+  # options.vuizvui.user.profpatsch.server.sshPort = lib.traceValSeqN 3 (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;
+  # });
 
-    networking.firewall = {
-      enable = true;
-      allowPing = true;
-      allowedTCPPorts = [ cfg.sshPort ];
-    };
+  # config = {
 
-  };
+  #   programs.mosh.enable = true;
+
+  #   services.openssh = {
+  #     enable = true;
+  #     listenAddresses = [ { addr = "0.0.0.0"; port = cfg.sshPort; } ];
+  #   };
+
+  #   networking.firewall = {
+  #     enable = true;
+  #     allowPing = true;
+  #     allowedTCPPorts = [ cfg.sshPort ];
+  #   };
+
+  # };
 
 }