about summary refs log tree commit diff
path: root/access.nix
diff options
context:
space:
mode:
authorNguyễn Gia Phong <cnx@loang.net>2024-01-12 02:49:13 +0900
committerNguyễn Gia Phong <cnx@loang.net>2024-01-12 02:49:13 +0900
commitc5c7efb19bf15cd7d191b2c917884bab0fad64e8 (patch)
treeff9965e918d027a1c3f3eebab674a5a8badc4ca6 /access.nix
parentdb927a71c6caafc7db742af88e28a52cecc47b97 (diff)
downloadnixos-conf-c5c7efb19bf15cd7d191b2c917884bab0fad64e8.tar.gz
Split user access control to separate module
Diffstat (limited to 'access.nix')
-rw-r--r--access.nix56
1 files changed, 56 insertions, 0 deletions
diff --git a/access.nix b/access.nix
new file mode 100644
index 0000000..adb1a83
--- /dev/null
+++ b/access.nix
@@ -0,0 +1,56 @@
+# Access configuration
+# Copyright (C) 2024  Nguyễn Gia Phong
+#
+# This file is part of loang configuration.
+#
+# Loang configuration is free software: you can redistribute it and/or modify
+# it under the terms of the GNU Affero General Public License as published
+# by the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# Loang configuration is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+# GNU Affero General Public License for more details.
+#
+# You should have received a copy of the GNU Affero General Public License
+# along with loang configuration.  If not, see <https://www.gnu.org/licenses/>.
+
+{ config, ... }:
+let
+  admins = [ "cnx" "xarvos" ];
+  normalUser = user: {
+    name = user;
+    value = {
+      isNormalUser = true;
+      openssh.authorizedKeys.keyFiles = [ "/etc/ssh/${user}.pub" ];
+    };
+  };
+  members = admins ++ [
+    "axl"
+    "ckie"
+    "epoch"
+    "int2k"
+    "mingnho"
+    "ooze"
+    "owocean"
+    "vnpower"
+  ];
+in {
+  security.sudo = {
+    enable = true;
+    wheelNeedsPassword = false;
+  };
+
+  services.openssh = {
+    enable = true;
+    openFirewall = true;
+    settings.PasswordAuthentication = false;
+    ports = [ 2211 ];
+  };
+
+  users = {
+    groups.wheel.members = admins;
+    users = builtins.listToAttrs (map normalUser members);
+  };
+}