diff options
author | sinanmohd <sinan@sinanmohd.com> | 2024-01-08 23:09:42 +0530 |
---|---|---|
committer | sinanmohd <sinan@sinanmohd.com> | 2024-01-08 23:29:53 +0530 |
commit | f8cea6f6c8a8ce35533d7fa978dbff8cd5427b7c (patch) | |
tree | b87d5da18c6f86d3a931a88370f41421833e9814 | |
parent | 119d8d504f435b552e548a9130ae96a2a3721dff (diff) |
modules/userdata: refactor
-rw-r--r-- | common.nix | 22 | ||||
-rw-r--r-- | hosts/cez/configuration.nix | 15 | ||||
-rw-r--r-- | hosts/cez/modules/wayland.nix | 31 | ||||
-rw-r--r-- | hosts/kay/modules/sftp.nix | 5 | ||||
-rw-r--r-- | modules/userdata.nix | 39 |
5 files changed, 51 insertions, 61 deletions
@@ -2,6 +2,7 @@ let host = config.networking.hostName; + user = config.userdata.user; in { disabledModules = [ @@ -32,6 +33,27 @@ in }; }; + users.users.${user} = { + extraGroups = [ "wheel" ]; + packages = with pkgs; [ + bc + unzip + htop + curl + file + dig + mtr + nnn + ps_mem + brightnessctl + ]; + + openssh.authorizedKeys.keys = [ + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDCeMXhkjm9CabbA/1xdtP9bvFEm8pVXPk66NmI9/VvQ sinan@vex" + "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIL8LnyOuPmtKRqAZeHueNN4kfYvpRQVwCivSTq+SZvDU sinan@cez" + ]; + }; + time.timeZone = "Asia/Kolkata"; networking.useDHCP = false; environment = { diff --git a/hosts/cez/configuration.nix b/hosts/cez/configuration.nix index 2df69ef..05c3b9f 100644 --- a/hosts/cez/configuration.nix +++ b/hosts/cez/configuration.nix @@ -39,12 +39,13 @@ in getty.autologinUser = user; }; - userdata.packages = with pkgs; [ - geoipWithDatabase - ffmpeg - (pass.withExtensions (exts: [ exts.pass-otp ])) - ]; - programs.adb.enable = true; - userdata.groups = [ "adbusers" ]; + users.users.${user} = { + extraGroups = [ "adbusers" ]; + packages = with pkgs; [ + geoipWithDatabase + ffmpeg + (pass.withExtensions (exts: [ exts.pass-otp ])) + ]; + }; } diff --git a/hosts/cez/modules/wayland.nix b/hosts/cez/modules/wayland.nix index 69e738a..085c950 100644 --- a/hosts/cez/modules/wayland.nix +++ b/hosts/cez/modules/wayland.nix @@ -9,7 +9,6 @@ in bemenu sway i3status - pinentry-bemenu swaylock swayidle swaybg @@ -19,18 +18,23 @@ in xdg-utils libnotify ]; - users.users.${user}.packages = with pkgs; [ - zathura - mpv - imv - wtype - qemu - OVMFFull - grim - slurp - tor-browser-bundle-bin - element-desktop-wayland - ]; + + users.users.${user} = { + extraGroups = [ "seat" ]; + packages = with pkgs; [ + zathura + mpv + imv + wtype + qemu + OVMFFull + grim + slurp + tor-browser-bundle-bin + element-desktop-wayland + pinentry-bemenu + ]; + }; # font fonts = { @@ -73,7 +77,6 @@ in }; }; - userdata.groups = [ "seat" ]; security.pam.services.swaylock.text = "auth include login"; hardware.opengl.enable = true; } diff --git a/hosts/kay/modules/sftp.nix b/hosts/kay/modules/sftp.nix index b969652..07b1449 100644 --- a/hosts/kay/modules/sftp.nix +++ b/hosts/kay/modules/sftp.nix @@ -2,7 +2,8 @@ let storage = "/hdd/users"; - pubkeys = config.userdata.pubKeys; + user = config.userdata.user; + pubKeys = config.users.users.${user}.openssh.authorizedKeys.keys; in { users = { @@ -15,7 +16,7 @@ in openssh.authorizedKeys.keys = [ "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIFmA1dyV+o9gfoxlbVG0Y+dn3lVqdFs5fMqfxyNc5/Lr sftp@cez" "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDCbgjAfyDNtLNyOS+sfLirYtfEAkGqV54LOwabpWkvf sftp@veu" - ] ++ pubkeys; + ] ++ pubKeys; }; users."nazer" = { diff --git a/modules/userdata.nix b/modules/userdata.nix index 136d807..46c7377 100644 --- a/modules/userdata.nix +++ b/modules/userdata.nix @@ -1,26 +1,8 @@ -{ config, lib, pkgs, ... }: +{ config, lib, ... }: let inherit (lib) mkOption types mdDoc; cfg = config.userdata; - - defaultPackages = with pkgs; [ - bc - unzip - htop - curl - file - dig - mtr - nnn - ps_mem - brightnessctl - ]; - defaultPubKeys = [ - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDCeMXhkjm9CabbA/1xdtP9bvFEm8pVXPk66NmI9/VvQ sinan@vex" - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIL8LnyOuPmtKRqAZeHueNN4kfYvpRQVwCivSTq+SZvDU sinan@cez" - ]; - defaultGroups = [ "wheel" ]; in { options.userdata = { @@ -29,11 +11,6 @@ in default = "sinan"; description = mdDoc "Owner's username"; }; - groups = mkOption { - type = types.listOf types.str; - default = []; - description = mdDoc "Groups the owner should be in"; - }; domain = mkOption { type = types.str; default = "sinanmohd.com"; @@ -44,25 +21,11 @@ in default = "sinan@firemail.cc"; description = mdDoc "Owner's email"; }; - packages = mkOption { - type = types.listOf types.package; - default = []; - description = mdDoc "Packages in owner's environment"; - }; - pubKeys = mkOption { - type = types.listOf types.str; - description = mdDoc "Owner's public ssh keys"; - default = []; - }; }; config.users.users.${cfg.user} = { uid = 1000; isNormalUser = true; description = cfg.email; - - extraGroups = defaultGroups ++ cfg.groups; - packages = defaultPackages ++ cfg.packages; - openssh.authorizedKeys.keys = defaultPubKeys ++ cfg.pubKeys; }; } |