summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsinanmohd <sinan@sinanmohd.com>2024-01-08 22:25:37 +0530
committersinanmohd <sinan@sinanmohd.com>2024-01-08 22:28:19 +0530
commitd91ce600ab53da44ee5919d038707e2690b1f6a9 (patch)
tree1e0cf8758d21fbc2e4267abe3eb563cadb54731a
parent279654d9e5c91413596c2328e6de4dc35d2c4dc5 (diff)
modules/userdata: refactor, init userdata.package
-rw-r--r--common.nix27
-rw-r--r--hosts/cez/configuration.nix6
-rw-r--r--modules/userdata.nix36
3 files changed, 37 insertions, 32 deletions
diff --git a/common.nix b/common.nix
index 5483f63..8ab8e95 100644
--- a/common.nix
+++ b/common.nix
@@ -1,10 +1,6 @@
{ config, pkgs, ... }:
let
- user = config.userdata.user;
- groups = config.userdata.groups;
- description = config.userdata.email;
- pubKeys = config.userdata.pubKeys;
host = config.networking.hostName;
in
{
@@ -29,29 +25,6 @@ in
};
};
- # users
- users.users.${user} = {
- inherit description;
- isNormalUser = true;
- uid = 1000;
- extraGroups = [
- "wheel"
- ] ++ groups;
- packages = with pkgs; [
- yt-dlp
- geoipWithDatabase
- dig
- nnn
- ffmpeg
- rtorrent
- ps_mem
- brightnessctl
- neofetch
- (pass.withExtensions (exts: [ exts.pass-otp ]))
- ];
- openssh.authorizedKeys.keys = pubKeys;
- };
-
# system
environment = {
binsh = "${pkgs.dash}/bin/dash";
diff --git a/hosts/cez/configuration.nix b/hosts/cez/configuration.nix
index 3a2a196..2df69ef 100644
--- a/hosts/cez/configuration.nix
+++ b/hosts/cez/configuration.nix
@@ -39,6 +39,12 @@ in
getty.autologinUser = user;
};
+ userdata.packages = with pkgs; [
+ geoipWithDatabase
+ ffmpeg
+ (pass.withExtensions (exts: [ exts.pass-otp ]))
+ ];
+
programs.adb.enable = true;
userdata.groups = [ "adbusers" ];
}
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;
+ };
}