From d91ce600ab53da44ee5919d038707e2690b1f6a9 Mon Sep 17 00:00:00 2001 From: sinanmohd Date: Mon, 8 Jan 2024 22:25:37 +0530 Subject: modules/userdata: refactor, init userdata.package --- modules/userdata.nix | 36 +++++++++++++++++++++++++++++++----- 1 file changed, 31 insertions(+), 5 deletions(-) (limited to 'modules') diff --git a/modules/userdata.nix b/modules/userdata.nix index ab14a01..9cd8139 100644 --- a/modules/userdata.nix +++ b/modules/userdata.nix @@ -1,7 +1,21 @@ -{ lib, ... }: +{ config, lib, pkgs, ... }: let inherit (lib) mkOption types mdDoc; + cfg = config.userdata; + + defaultPackages = with pkgs; [ + 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 = { @@ -25,13 +39,25 @@ 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 = [ - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIDCeMXhkjm9CabbA/1xdtP9bvFEm8pVXPk66NmI9/VvQ sinan@vex" - "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIL8LnyOuPmtKRqAZeHueNN4kfYvpRQVwCivSTq+SZvDU sinan@cez" - ]; + 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; + }; } -- cgit v1.2.3