Make miscellaneous updates :)

This commit is contained in:
foo-dogsquared 2021-12-26 16:02:57 +08:00
parent 9f7dc70ab8
commit 405fd9f1e1
7 changed files with 31 additions and 22 deletions

View File

@ -99,8 +99,7 @@ rec {
- `list` is a list of usernames as strings - `list` is a list of usernames as strings
- `attrset` is a set of valid users with the name as the key and the path as the value. - `attrset` is a set of valid users with the name as the key and the path as the value.
Example: Example:
# Assuming only 'foo-dogsquared' is the existing user. # Assuming only 'foo-dogsquared' is the existing user for 'home-manager'.
# Get valid users from home-manager.
getUsers "home-manager" [ "foo-dogsquared" "archie" "brad" ] getUsers "home-manager" [ "foo-dogsquared" "archie" "brad" ]
=> { foo-dogsquared = /home/foo-dogsquared/projects/nixos-config/users/foo-dogsquared; } => { foo-dogsquared = /home/foo-dogsquared/projects/nixos-config/users/foo-dogsquared; }
*/ */
@ -108,7 +107,7 @@ rec {
let let
userModules = filesToAttr ../users/${type}; userModules = filesToAttr ../users/${type};
invalidUsernames = [ "config" "modules" ]; invalidUsernames = [ "config" "modules" ];
in lib.filterAttrs (n: _: !lib.elem n invalidUsernames) userModules; in lib.filterAttrs (n: _: !lib.elem n invalidUsernames && lib.elem n users) userModules;
# Return the path of `secrets` from `../secrets`. # Return the path of `secrets` from `../secrets`.
getSecret = path: ../secrets/${path}; getSecret = path: ../secrets/${path};

View File

@ -8,7 +8,8 @@ in {
graphics.enable = graphics.enable =
lib.mkEnableOption "installations of graphics-related apps"; lib.mkEnableOption "installations of graphics-related apps";
audio.enable = lib.mkEnableOption "installations of audio-related apps"; audio.enable = lib.mkEnableOption "installations of audio-related apps";
multimedia.enable = lib.mkEnableOption "installations for opening multimedia files"; multimedia.enable =
lib.mkEnableOption "installations for opening multimedia files";
}; };
config = lib.mkIf cfg.enable (lib.mkMerge [ config = lib.mkIf cfg.enable (lib.mkMerge [

View File

@ -1,9 +1,12 @@
# Arsenal for development (which is rare nowadays). ;p
# If you're looking for text editors, go to `./editors.nix`.
{ config, options, lib, pkgs, ... }: { config, options, lib, pkgs, ... }:
let cfg = config.modules.dev; let cfg = config.modules.dev;
in { in {
options.modules.dev = { options.modules.dev = {
enable = lib.mkEnableOption "myy user-specific development setup"; enable =
lib.mkEnableOption "foo-dogsquared's user-specific development setup";
shell.enable = shell.enable =
lib.mkEnableOption "configuration of foo-dogsquared's shell of choice"; lib.mkEnableOption "configuration of foo-dogsquared's shell of choice";
}; };
@ -12,6 +15,7 @@ in {
({ ({
home.packages = with pkgs; [ home.packages = with pkgs; [
lazygit # Git interface for the lazy. lazygit # Git interface for the lazy.
github-cli # So you don't have to use much of GitHub on the site, I guess.
fzf # A fuzzy finder that enables fuzzy finding not furry finding, a common misconception. fzf # A fuzzy finder that enables fuzzy finding not furry finding, a common misconception.
gopass # An improved version of the password manager for hipsters. gopass # An improved version of the password manager for hipsters.
perl534Packages.vidir # Bulk rename for your organizing needs. perl534Packages.vidir # Bulk rename for your organizing needs.

View File

@ -26,5 +26,12 @@ in {
fcitx5-mozc # Japanese input addon. fcitx5-mozc # Japanese input addon.
]; ];
}; };
# The i18n module has already set session variables but just to be sure...
systemd.user.sessionVariables = {
GTK_IM_MODULE = "fcitx";
QT_IM_MODULE = "fcitx";
XMODIFIERS = "@im=fcitx";
};
}; };
} }

View File

@ -3,10 +3,10 @@
# TODO: Make this a generic service. # TODO: Make this a generic service.
# There are multiple external storage drives now. # There are multiple external storage drives now.
let let cfg = config.modules.hardware-setup.backup-archive;
cfg = config.modules.hardware-setup.backup-archive;
in { in {
options.modules.hardware-setup.backup-archive.enable = lib.mkEnableOption "external hard drive and automated backup service with BorgBackup"; options.modules.hardware-setup.backup-archive.enable = lib.mkEnableOption
"external hard drive and automated backup service with BorgBackup";
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {
assertions = [{ assertions = [{
@ -14,7 +14,8 @@ in {
message = "Agenix module is not enabled."; message = "Agenix module is not enabled.";
}]; }];
age.secrets.external-backup-borgmatic-settings.file = lib.getSecret "archive/password"; age.secrets.external-backup-borgmatic-settings.file =
lib.getSecret "archive/borgmatic.json";
fileSystems."/mnt/external-storage" = { fileSystems."/mnt/external-storage" = {
device = "/dev/disk/by-uuid/665A391C5A38EB07"; device = "/dev/disk/by-uuid/665A391C5A38EB07";
fsType = "ntfs"; fsType = "ntfs";
@ -37,10 +38,9 @@ in {
Description = "Backup with Borgmatic"; Description = "Backup with Borgmatic";
Wants = [ "network-online.target" ]; Wants = [ "network-online.target" ];
After = [ "network-online.target" ]; After = [ "network-online.target" ];
ConditionACPower = true;
}; };
startAt = "04/3:00:00"; startAt = "04/2:00:00";
serviceConfig = { serviceConfig = {
# Delay start to prevent backups running during boot. Note that systemd-inhibit requires dbus and # Delay start to prevent backups running during boot. Note that systemd-inhibit requires dbus and
# dbus-user-session to be installed. # dbus-user-session to be installed.
@ -54,7 +54,7 @@ in {
ProtectSystem = "full"; ProtectSystem = "full";
MemoryDenyWriteExecute = "no"; MemoryDenyWriteExecute = "no";
NoNewPrivileges = "yes"; NoNewPrivileges = "yes";
PrivateDevices= "yes"; PrivateDevices = "yes";
PrivateTmp = "yes"; PrivateTmp = "yes";
ProtectClock = "yes"; ProtectClock = "yes";
ProtectControlGroups = "yes"; ProtectControlGroups = "yes";

View File

@ -36,9 +36,9 @@ in {
options.modules.users = { options.modules.users = {
users = lib.mkOption { users = lib.mkOption {
default = { }; default = { };
description = description = ''
"A set of users from the `./users/home-manager` directory to be included in the NixOS config. A set of users from the `./users/home-manager` directory to be included in the NixOS config.
This will also create the appropriate user settings in <literal>users.users</literal> in the NixOS configuration."; This will also create the appropriate user settings in <literal>users.users</literal> in the NixOS configuration.'';
example = { example = {
foo-dogsquared.settings = { foo-dogsquared.settings = {
extraGroups = [ "wheel" "audio" "libvirtd" ]; extraGroups = [ "wheel" "audio" "libvirtd" ];
@ -68,10 +68,8 @@ in {
# Mapping each users to the respective user configuration. # Mapping each users to the respective user configuration.
# Setting users for home-manager. # Setting users for home-manager.
home-manager.users = mapUsers (user: _: home-manager.users = mapUsers (user: _:
let let homeManagerUserModulePath = lib.getAttr user homeManagerUserModules;
homeManagerUserModulePath = lib.getAttr user homeManagerUserModules; in import homeManagerUserModulePath);
homeManagerUserConfig = import homeManagerUserModulePath;
in homeManagerUserConfig);
# NixOS users. # NixOS users.
users.users = mapUsers (user: opts: users.users = mapUsers (user: opts:

View File

@ -2,9 +2,9 @@
{ {
home.packages = with pkgs; [ home.packages = with pkgs; [
brave neovim
emacs borgmatic
github-cli borgbackup
ncmpcpp ncmpcpp
]; ];