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 = {
enable = true;
audio.enable = true;
fonts.enable = true;
};
dev = {
enable = true;
@ -23,6 +24,7 @@
};
editors = {
emacs.enable = true;
emacs.doom.enable = true;
neovim.enable = true;
};
themes.a-happy-gnome.enable = true;
@ -54,8 +56,6 @@
# Enable touchpad support (enabled default in most desktopManager).
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 ];
# Some programs need SUID wrappers, can be configured further or are
@ -80,7 +80,7 @@
system.stateVersion = "21.11"; # Did you read the comment?
# 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";
fsType = "ntfs";
noCheck = true;
@ -88,8 +88,12 @@
"nofail"
"noauto"
"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;
removableDevice = true;
repo = "/archive/backups";
repo = "/mnt/external-storage/backups";
paths = [ "~/dotfiles" "~/library" "~/writings" ];
encryption = {
mode = "repokey";

View File

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

View File

@ -2,8 +2,11 @@
let
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;
validUsers = lib.filterAttrs (n: v: lib.elem n users) userModules;
in
{
options.modules.users = {
@ -14,13 +17,12 @@ in
};
};
imports = [ inputs.home-manager.nixosModules.home-manager ];
config = lib.mkMerge [
({
assertions = [{
assertion = (builtins.length nonexistentUsers) > 1;
message = "${lib.concatStringsSep "," users} ${lib.concatStringsSep "," nonexistentUsers} is not found in the directory.";
}];
})
];
imports = [ inputs.home-manager.nixosModules.home-manager ] ++ (lib.attrValues validUsers);
config = {
assertions = [{
assertion = (builtins.length nonexistentUsers) < 1;
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.
users.users.foo-dogsquared = {