summaryrefslogtreecommitdiff
path: root/sys/seat/default.nix
diff options
context:
space:
mode:
authorAlejandro Soto <alejandro@34project.org>2024-07-14 17:53:13 -0600
committerAlejandro Soto <alejandro@34project.org>2024-07-15 09:34:00 -0600
commit02abf4ed0131237c25e0a10db50fa4c41a902a50 (patch)
tree20904894fc0952806e341cdaff5941e81b3ce51c /sys/seat/default.nix
parent08e746700341dda3e3bdf704332fc3c07053d3e7 (diff)
sys: final merge of dmz, hv into sys
Diffstat (limited to '')
-rw-r--r--sys/seat/default.nix85
1 files changed, 85 insertions, 0 deletions
diff --git a/sys/seat/default.nix b/sys/seat/default.nix
new file mode 100644
index 0000000..d5c5f3d
--- /dev/null
+++ b/sys/seat/default.nix
@@ -0,0 +1,85 @@
+{ config, lib, pkgs, ... }:
+with lib; let
+ cfg = config.local.seat;
+
+ users = filterAttrs;
+in
+{
+ options.local.seat = {
+ enable = mkEnableOption "user seat";
+
+ installUsers = mkOption {
+ type = types.enum [ "none" "single" "all" ];
+ };
+
+ graphical = mkOption {
+ type = types.bool;
+ default = false;
+ };
+
+ videoDrivers = mkOption {
+ type = with types; listOf str;
+ };
+ };
+
+ config = mkIf cfg.enable
+ (mkMerge [
+ (
+ let
+ users =
+ if cfg.installUsers == "all"
+ then config.local.users
+ else if cfg.installUsers == "single"
+ then filterAttrs (_: user: user.sysadmin) config.local.users
+ else { };
+ in
+ {
+ hardware.acpilight.enable = true;
+
+ users = {
+ groups = mapAttrs (_: user: { inherit (user) gid; }) users // {
+ adbusers.gid = 1008;
+ };
+
+ users = mapAttrs
+ (username: user: {
+ isNormalUser = true;
+
+ inherit (user) uid;
+ description = user.gecos;
+
+ group = username;
+ extraGroups = [ "users" ] ++ user.groups;
+
+ shell = if user.allowLogin then pkgs.zsh else null;
+ })
+ users;
+ };
+ }
+ )
+
+ (mkIf cfg.graphical {
+ hardware.pulseaudio.enable = true;
+
+ programs.dconf.enable = true;
+
+ services = {
+ libinput.enable = true;
+
+ udev.packages = [
+ pkgs.android-udev-rules
+ ];
+
+ xserver = {
+ enable = true;
+ videoDrivers = cfg.videoDrivers ++ [ "modesetting" "fbdev" ];
+ displayManager.startx.enable = true;
+ };
+ };
+
+ sound.enable = true;
+
+ users.groups.adbusers.gid = 1008;
+ })
+ ]);
+}