Update users NixOS module

Welp, that's one step for more convenient and separate user-specific
configuration. It's a tad simpler than
https://github.com/divnix/devos but I want to work my way towards a
similar setup. It's just a little overwhelming starting with that
framework.
This commit is contained in:
Gabriel Arazas 2021-11-27 19:21:08 +08:00
parent a34674f672
commit 516f465185
4 changed files with 25 additions and 17 deletions

View File

@ -16,6 +16,7 @@
desktop = { desktop = {
enable = true; enable = true;
audio.enable = true; audio.enable = true;
fonts.enable = true;
}; };
dev = { dev = {
enable = true; enable = true;
@ -23,6 +24,7 @@
}; };
editors = { editors = {
emacs.enable = true; emacs.enable = true;
emacs.doom.enable = true;
neovim.enable = true; neovim.enable = true;
}; };
themes.a-happy-gnome.enable = true; themes.a-happy-gnome.enable = true;
@ -54,8 +56,6 @@
# Enable touchpad support (enabled default in most desktopManager). # Enable touchpad support (enabled default in most desktopManager).
hardware.opentabletdriver.enable = true; hardware.opentabletdriver.enable = true;
# List packages installed in system profile. To search, run:
# $ nix search wget
environment.systemPackages = with pkgs; [ git wget brave lf fd ripgrep ]; environment.systemPackages = with pkgs; [ git wget brave lf fd ripgrep ];
# Some programs need SUID wrappers, can be configured further or are # Some programs need SUID wrappers, can be configured further or are
@ -80,7 +80,7 @@
system.stateVersion = "21.11"; # Did you read the comment? system.stateVersion = "21.11"; # Did you read the comment?
# This is my external hard disk so it has to be non-blocking. # This is my external hard disk so it has to be non-blocking.
fileSystems."/mnt/archive" = { fileSystems."/mnt/external-storage" = {
device = "/dev/disk/by-uuid/665A391C5A38EB07"; device = "/dev/disk/by-uuid/665A391C5A38EB07";
fsType = "ntfs"; fsType = "ntfs";
noCheck = true; noCheck = true;
@ -88,8 +88,12 @@
"nofail" "nofail"
"noauto" "noauto"
"user" "user"
"x.systemd.automount"
"x.systemd.device.timeout=1ms" # See systemd.mount.5 and systemd.automount.5 manual page for more
# details.
"x-systemd.automount"
"x-systemd.device-timeout=2"
"x-systemd.idle-timeout=2"
]; ];
}; };
@ -110,7 +114,7 @@
]; ];
doInit = false; doInit = false;
removableDevice = true; removableDevice = true;
repo = "/archive/backups"; repo = "/mnt/external-storage/backups";
paths = [ "~/dotfiles" "~/library" "~/writings" ]; paths = [ "~/dotfiles" "~/library" "~/writings" ];
encryption = { encryption = {
mode = "repokey"; mode = "repokey";

View File

@ -31,7 +31,7 @@ in {
# :checkers spell # :checkers spell
aspell aspell
aspellDicts.en aspellDicts.en
aspellDicts.en-computer aspellDicts.en-computers
# :tools lookup # :tools lookup
wordnet wordnet

View File

@ -2,8 +2,11 @@
let let
cfg = config.modules.users; cfg = config.modules.users;
users = lib.attrNames (lib.filesToAttr ../users); userModules = lib.filesToAttr ../users;
users = lib.attrNames userModules;
nonexistentUsers = lib.filter (name: !lib.elem name users) cfg.users; nonexistentUsers = lib.filter (name: !lib.elem name users) cfg.users;
validUsers = lib.filterAttrs (n: v: lib.elem n users) userModules;
in in
{ {
options.modules.users = { options.modules.users = {
@ -14,13 +17,12 @@ in
}; };
}; };
imports = [ inputs.home-manager.nixosModules.home-manager ]; imports = [ inputs.home-manager.nixosModules.home-manager ] ++ (lib.attrValues validUsers);
config = lib.mkMerge [
({ config = {
assertions = [{ assertions = [{
assertion = (builtins.length nonexistentUsers) > 1; assertion = (builtins.length nonexistentUsers) < 1;
message = "${lib.concatStringsSep "," users} ${lib.concatStringsSep "," nonexistentUsers} is not found in the directory."; message = "${lib.concatMapStringsSep ", " (u: "'${u}'") nonexistentUsers} is not found in the `./users` directory.";
}]; }];
}) };
];
} }

View File

@ -1,3 +1,5 @@
{ config, options, lib, pkgs, ... }:
{ {
# Define a user account. Don't forget to set a password with passwd. # Define a user account. Don't forget to set a password with passwd.
users.users.foo-dogsquared = { users.users.foo-dogsquared = {