Add multi-user support for various applications and services

Enhanced the configuration files to support multi-user management by introducing user options for multiple applications, including art, gaming, multimedia, and development tools. Updated existing modules to utilize these new user options, improving flexibility and maintainability in user package installations.
This commit is contained in:
Danilo Reyes
2026-01-16 13:07:56 -06:00
parent 2893487ffc
commit cbe7c25812
30 changed files with 338 additions and 99 deletions

View File

@@ -5,6 +5,32 @@
... ...
}: }:
{ {
my = {
apps = {
art.enable = true;
art.users = "bearded_dragonn";
fonts.enable = true;
fonts.users = "bearded_dragonn";
gaming.enable = true;
gaming.users = "bearded_dragonn";
};
dev = {
nix.enable = true;
nix.users = "bearded_dragonn";
python.enable = true;
python.users = "bearded_dragonn";
sh.enable = true;
sh.users = "bearded_dragonn";
};
shell = {
exercism.enable = true;
exercism.users = "bearded_dragonn";
tools.enable = true;
tools.users = "bearded_dragonn";
multimedia.enable = true;
multimedia.users = "bearded_dragonn";
};
};
sops.secrets = lib.mkIf config.my.secureHost { sops.secrets = lib.mkIf config.my.secureHost {
derek-password.neededForUsers = true; derek-password.neededForUsers = true;
}; };
@@ -44,4 +70,5 @@
"games" "games"
]; ];
}; };
home-manager.users.bearded_dragonn.home.stateVersion = "23.05";
} }

View File

@@ -14,7 +14,14 @@ let
gnomeEnabled = config.services.desktopManager.gnome.enable; gnomeEnabled = config.services.desktopManager.gnome.enable;
in in
{ {
options.my.stylix.enable = lib.mkEnableOption "system-wide theming with Stylix"; options.my.stylix = {
enable = lib.mkEnableOption "system-wide theming with Stylix";
users = lib.mkOption {
type = lib.types.either lib.types.str (lib.types.listOf lib.types.str);
default = config.my.toggleUsers.stylix;
description = "Users to apply Stylix theming for";
};
};
config = { config = {
stylix = { stylix = {
inherit (scheme) image polarity; inherit (scheme) image polarity;
@@ -23,7 +30,7 @@ in
targets.qt.platform = lib.mkForce "qtct"; targets.qt.platform = lib.mkForce "qtct";
} }
// lib.optionalAttrs (scheme ? base16Scheme) { inherit (scheme) base16Scheme; }; // lib.optionalAttrs (scheme ? base16Scheme) { inherit (scheme) base16Scheme; };
home-manager.users = inputs.self.lib.mkHomeManagerUsers lib config.my.toggleUsers.stylix (user: { home-manager.users = inputs.self.lib.mkHomeManagerUsers lib config.my.stylix.users (user: {
gtk = lib.mkIf (!cfg.enable && gnomeEnabled) { gtk = lib.mkIf (!cfg.enable && gnomeEnabled) {
enable = true; enable = true;
iconTheme = { iconTheme = {

View File

@@ -37,12 +37,19 @@ let
in in
{ {
options.my = { options.my = {
apps.art.enable = lib.mkEnableOption "digital art and creative applications"; apps.art = {
enable = lib.mkEnableOption "digital art and creative applications";
users = lib.mkOption {
type = lib.types.either lib.types.str (lib.types.listOf lib.types.str);
default = config.my.toggleUsers.apps;
description = "Users to install art packages for";
};
};
dev.gameDev.enable = lib.mkEnableOption "game development tools and engines"; dev.gameDev.enable = lib.mkEnableOption "game development tools and engines";
}; };
config.users.users = config.users.users =
let let
packages = artPackages ++ gameDevPackages; packages = artPackages ++ gameDevPackages;
in in
inputs.self.lib.mkUserPackages lib config.my.toggleUsers.apps packages; inputs.self.lib.mkUserPackages lib config.my.apps.art.users packages;
} }

View File

@@ -18,8 +18,15 @@ let
}; };
in in
{ {
options.my.apps.dictionaries.enable = lib.mkEnableOption "dictionaries and language tools"; options.my.apps.dictionaries = {
enable = lib.mkEnableOption "dictionaries and language tools";
users = lib.mkOption {
type = lib.types.either lib.types.str (lib.types.listOf lib.types.str);
default = config.my.toggleUsers.apps;
description = "Users to install dictionaries packages for";
};
};
config = lib.mkIf config.my.apps.dictionaries.enable { config = lib.mkIf config.my.apps.dictionaries.enable {
users.users = inputs.self.lib.mkUserPackages lib config.my.toggleUsers.apps packages; users.users = inputs.self.lib.mkUserPackages lib config.my.apps.dictionaries.users packages;
}; };
} }

View File

@@ -23,7 +23,14 @@ in
{ {
imports = [ inputs.nix-gaming.nixosModules.platformOptimizations ]; imports = [ inputs.nix-gaming.nixosModules.platformOptimizations ];
options.my.apps = { options.my.apps = {
gaming.enable = lib.mkEnableOption "gaming applications and emulators"; gaming = {
enable = lib.mkEnableOption "gaming applications and emulators";
users = lib.mkOption {
type = lib.types.either lib.types.str (lib.types.listOf lib.types.str);
default = config.my.toggleUsers.apps;
description = "Users to install gaming packages for";
};
};
switch.enable = lib.mkEnableOption "Nintendo Switch homebrew tools"; switch.enable = lib.mkEnableOption "Nintendo Switch homebrew tools";
}; };
config = lib.mkIf config.my.apps.gaming.enable { config = lib.mkIf config.my.apps.gaming.enable {
@@ -71,6 +78,6 @@ in
; ;
}; };
in in
inputs.self.lib.mkUserPackages lib config.my.toggleUsers.apps packages; inputs.self.lib.mkUserPackages lib config.my.apps.gaming.users packages;
}; };
} }

View File

@@ -28,9 +28,16 @@ let
krisp-patcher = pkgs.writers.writePython3Bin "krisp-patcher" krisp-settings krisp-patch; krisp-patcher = pkgs.writers.writePython3Bin "krisp-patcher" krisp-settings krisp-patch;
in in
{ {
options.my.apps.internet.enable = lib.mkEnableOption "internet browsers and communication apps"; options.my.apps.internet = {
enable = lib.mkEnableOption "internet browsers and communication apps";
users = lib.mkOption {
type = lib.types.either lib.types.str (lib.types.listOf lib.types.str);
default = config.my.toggleUsers.apps;
description = "Users to install internet packages for";
};
};
config = lib.mkIf config.my.apps.internet.enable { config = lib.mkIf config.my.apps.internet.enable {
home-manager.users = inputs.self.lib.mkHomeManagerUsers lib config.my.toggleUsers.apps (_user: { home-manager.users = inputs.self.lib.mkHomeManagerUsers lib config.my.apps.internet.users (_user: {
programs.librewolf = import ./librewolf.nix; programs.librewolf = import ./librewolf.nix;
}); });
programs.geary.enable = true; programs.geary.enable = true;
@@ -54,6 +61,6 @@ in
; ;
}; };
in in
inputs.self.lib.mkUserPackages lib config.my.toggleUsers.apps packages; inputs.self.lib.mkUserPackages lib config.my.apps.internet.users packages;
}; };
} }

View File

@@ -6,7 +6,14 @@
... ...
}: }:
{ {
options.my.apps.misc.enable = lib.mkEnableOption "miscellaneous desktop applications"; options.my.apps.misc = {
enable = lib.mkEnableOption "miscellaneous desktop applications";
users = lib.mkOption {
type = lib.types.either lib.types.str (lib.types.listOf lib.types.str);
default = config.my.toggleUsers.apps;
description = "Users to install misc packages for";
};
};
config = lib.mkIf config.my.apps.misc.enable { config = lib.mkIf config.my.apps.misc.enable {
users.users = users.users =
let let
@@ -19,6 +26,6 @@
; ;
}; };
in in
inputs.self.lib.mkUserPackages lib config.my.toggleUsers.apps packages; inputs.self.lib.mkUserPackages lib config.my.apps.misc.users packages;
}; };
} }

View File

@@ -6,7 +6,14 @@
... ...
}: }:
{ {
options.my.apps.multimedia.enable = lib.mkEnableOption "multimedia applications and media players"; options.my.apps.multimedia = {
enable = lib.mkEnableOption "multimedia applications and media players";
users = lib.mkOption {
type = lib.types.either lib.types.str (lib.types.listOf lib.types.str);
default = config.my.toggleUsers.apps;
description = "Users to install multimedia packages for";
};
};
config = lib.mkIf config.my.apps.multimedia.enable { config = lib.mkIf config.my.apps.multimedia.enable {
users.users = users.users =
let let
@@ -21,6 +28,6 @@
; ;
}; };
in in
inputs.self.lib.mkUserPackages lib config.my.toggleUsers.apps packages; inputs.self.lib.mkUserPackages lib config.my.apps.multimedia.users packages;
}; };
} }

View File

@@ -6,7 +6,14 @@
... ...
}: }:
{ {
options.my.apps.piano.enable = lib.mkEnableOption "piano learning and music theory apps"; options.my.apps.piano = {
enable = lib.mkEnableOption "piano learning and music theory apps";
users = lib.mkOption {
type = lib.types.either lib.types.str (lib.types.listOf lib.types.str);
default = config.my.toggleUsers.apps;
description = "Users to install piano packages for";
};
};
config = lib.mkIf config.my.apps.piano.enable { config = lib.mkIf config.my.apps.piano.enable {
users.users = users.users =
let let
@@ -18,6 +25,6 @@
; ;
}; };
in in
inputs.self.lib.mkUserPackages lib config.my.toggleUsers.apps packages; inputs.self.lib.mkUserPackages lib config.my.apps.piano.users packages;
}; };
} }

View File

@@ -6,7 +6,14 @@
... ...
}: }:
{ {
options.my.apps.office.enable = lib.mkEnableOption "office applications and productivity tools"; options.my.apps.office = {
enable = lib.mkEnableOption "office applications and productivity tools";
users = lib.mkOption {
type = lib.types.either lib.types.str (lib.types.listOf lib.types.str);
default = config.my.toggleUsers.apps;
description = "Users to install office packages for";
};
};
config = lib.mkIf config.my.apps.office.enable { config = lib.mkIf config.my.apps.office.enable {
environment.variables.CALIBRE_USE_SYSTEM_THEME = "1"; environment.variables.CALIBRE_USE_SYSTEM_THEME = "1";
users.users = users.users =
@@ -22,6 +29,6 @@
; ;
}; };
in in
inputs.self.lib.mkUserPackages lib config.my.toggleUsers.apps packages; inputs.self.lib.mkUserPackages lib config.my.apps.office.users packages;
}; };
} }

View File

@@ -18,7 +18,14 @@ let
in in
{ {
options = { options = {
my.dev.cc.enable = lib.mkEnableOption "Install C/C++ tooling globally"; my.dev.cc = {
enable = lib.mkEnableOption "Install C/C++ tooling globally";
users = lib.mkOption {
type = lib.types.either lib.types.str (lib.types.listOf lib.types.str);
default = config.my.toggleUsers.dev;
description = "Users to install C/C++ packages for";
};
};
devShells.cc = lib.mkOption { devShells.cc = lib.mkOption {
type = lib.types.package; type = lib.types.package;
default = pkgs.mkShell { default = pkgs.mkShell {
@@ -32,6 +39,6 @@ in
}; };
}; };
config = lib.mkIf config.my.dev.cc.enable { config = lib.mkIf config.my.dev.cc.enable {
users.users = inputs.self.lib.mkUserAttrs lib config.my.toggleUsers.dev { inherit packages; }; users.users = inputs.self.lib.mkUserAttrs lib config.my.dev.cc.users { inherit packages; };
}; };
} }

View File

@@ -15,7 +15,14 @@ let
in in
{ {
options = { options = {
my.dev.docker.enable = lib.mkEnableOption "Install Docker tooling globally"; my.dev.docker = {
enable = lib.mkEnableOption "Install Docker tooling globally";
users = lib.mkOption {
type = lib.types.either lib.types.str (lib.types.listOf lib.types.str);
default = config.my.toggleUsers.dev;
description = "Users to install Docker packages for";
};
};
devShells.docker = lib.mkOption { devShells.docker = lib.mkOption {
type = lib.types.package; type = lib.types.package;
default = pkgs.mkShell { default = pkgs.mkShell {
@@ -30,7 +37,7 @@ in
}; };
config = lib.mkMerge [ config = lib.mkMerge [
(lib.mkIf config.my.dev.docker.enable { (lib.mkIf config.my.dev.docker.enable {
users.users = inputs.self.lib.mkUserAttrs lib config.my.toggleUsers.dev { inherit packages; }; users.users = inputs.self.lib.mkUserAttrs lib config.my.dev.docker.users { inherit packages; };
}) })
{ {
environment.variables.DOCKER_CONFIG = "\${XDG_CONFIG_HOME}/docker"; environment.variables.DOCKER_CONFIG = "\${XDG_CONFIG_HOME}/docker";

View File

@@ -6,9 +6,16 @@
... ...
}: }:
{ {
options.my.emacs.enable = lib.mkEnableOption "Doom Emacs configuration"; options.my.emacs = {
enable = lib.mkEnableOption "Doom Emacs configuration";
users = lib.mkOption {
type = lib.types.either lib.types.str (lib.types.listOf lib.types.str);
default = config.my.toggleUsers.dev;
description = "Users to install Emacs packages for";
};
};
config = lib.mkIf config.my.emacs.enable { config = lib.mkIf config.my.emacs.enable {
home-manager.users = inputs.self.lib.mkHomeManagerUsers lib config.my.toggleUsers.dev (_user: { home-manager.users = inputs.self.lib.mkHomeManagerUsers lib config.my.emacs.users (_user: {
xdg.dataFile = { xdg.dataFile = {
"doom/templates/events.org".source = ../../dotfiles/doom/templates/events.org; "doom/templates/events.org".source = ../../dotfiles/doom/templates/events.org;
"doom/templates/default.org".source = ../../dotfiles/doom/templates/default.org; "doom/templates/default.org".source = ../../dotfiles/doom/templates/default.org;
@@ -48,7 +55,7 @@
; ;
}; };
in in
inputs.self.lib.mkUserPackages lib config.my.toggleUsers.dev packages; inputs.self.lib.mkUserPackages lib config.my.emacs.users packages;
services.emacs = { services.emacs = {
enable = true; enable = true;
defaultEditor = true; defaultEditor = true;
@@ -60,7 +67,7 @@
epkgs: epkgs:
let let
inherit inherit
(config.home-manager.users.${inputs.self.lib.getFirstUser config.my.toggleUsers.dev}.programs.emacs) (config.home-manager.users.${inputs.self.lib.getFirstUser config.my.emacs.users}.programs.emacs)
extraPackages extraPackages
extraConfig extraConfig
; ;

View File

@@ -21,7 +21,14 @@ let
in in
{ {
options = { options = {
my.dev.go.enable = lib.mkEnableOption "Install Go tooling globally"; my.dev.go = {
enable = lib.mkEnableOption "Install Go tooling globally";
users = lib.mkOption {
type = lib.types.either lib.types.str (lib.types.listOf lib.types.str);
default = config.my.toggleUsers.dev;
description = "Users to install Go packages for";
};
};
devShells.go = lib.mkOption { devShells.go = lib.mkOption {
type = lib.types.package; type = lib.types.package;
default = pkgs.mkShell { default = pkgs.mkShell {
@@ -39,7 +46,7 @@ in
environment.variables = { inherit GOPATH; }; environment.variables = { inherit GOPATH; };
} }
(lib.mkIf config.my.dev.go.enable { (lib.mkIf config.my.dev.go.enable {
users.users = inputs.self.lib.mkUserAttrs lib config.my.toggleUsers.dev { inherit packages; }; users.users = inputs.self.lib.mkUserAttrs lib config.my.dev.go.users { inherit packages; };
}) })
]; ];
} }

View File

@@ -19,7 +19,14 @@ let
in in
{ {
options = { options = {
my.dev.haskell.enable = lib.mkEnableOption "Install Haskell tooling globally"; my.dev.haskell = {
enable = lib.mkEnableOption "Install Haskell tooling globally";
users = lib.mkOption {
type = lib.types.either lib.types.str (lib.types.listOf lib.types.str);
default = config.my.toggleUsers.dev;
description = "Users to install Haskell packages for";
};
};
devShells.haskell = lib.mkOption { devShells.haskell = lib.mkOption {
type = lib.types.package; type = lib.types.package;
default = pkgs.mkShell { default = pkgs.mkShell {
@@ -34,7 +41,7 @@ in
}; };
config = lib.mkMerge [ config = lib.mkMerge [
(lib.mkIf config.my.dev.haskell.enable { (lib.mkIf config.my.dev.haskell.enable {
users.users = inputs.self.lib.mkUserAttrs lib config.my.toggleUsers.dev { inherit packages; }; users.users = inputs.self.lib.mkUserAttrs lib config.my.dev.haskell.users { inherit packages; };
}) })
{ {
environment.variables = { environment.variables = {

View File

@@ -13,7 +13,14 @@ let
in in
{ {
options = { options = {
my.dev.javascript.enable = lib.mkEnableOption "Install JavaScript tooling globally"; my.dev.javascript = {
enable = lib.mkEnableOption "Install JavaScript tooling globally";
users = lib.mkOption {
type = lib.types.either lib.types.str (lib.types.listOf lib.types.str);
default = config.my.toggleUsers.dev;
description = "Users to install JavaScript packages for";
};
};
devShells.javascript = lib.mkOption { devShells.javascript = lib.mkOption {
type = lib.types.package; type = lib.types.package;
default = pkgs.mkShell { default = pkgs.mkShell {
@@ -28,10 +35,10 @@ in
}; };
config = lib.mkMerge [ config = lib.mkMerge [
(lib.mkIf config.my.dev.javascript.enable { (lib.mkIf config.my.dev.javascript.enable {
users.users = inputs.self.lib.mkUserAttrs lib config.my.toggleUsers.dev { inherit packages; }; users.users = inputs.self.lib.mkUserAttrs lib config.my.dev.javascript.users { inherit packages; };
}) })
{ {
home-manager.users = inputs.self.lib.mkHomeManagerUsers lib config.my.toggleUsers.dev (_user: { home-manager.users = inputs.self.lib.mkHomeManagerUsers lib config.my.dev.javascript.users (_user: {
xdg.configFile = { xdg.configFile = {
"npm/npmrc".source = ../../dotfiles/npmrc; "npm/npmrc".source = ../../dotfiles/npmrc;
"configstore/update-notifier-npm-check.json".text = builtins.toJSON { "configstore/update-notifier-npm-check.json".text = builtins.toJSON {

View File

@@ -12,7 +12,14 @@ let
in in
{ {
options = { options = {
my.dev.julia.enable = lib.mkEnableOption "Install Julia globally"; my.dev.julia = {
enable = lib.mkEnableOption "Install Julia globally";
users = lib.mkOption {
type = lib.types.either lib.types.str (lib.types.listOf lib.types.str);
default = config.my.toggleUsers.dev;
description = "Users to install Julia packages for";
};
};
devShells.julia = lib.mkOption { devShells.julia = lib.mkOption {
type = lib.types.package; type = lib.types.package;
default = pkgs.mkShell { default = pkgs.mkShell {
@@ -26,6 +33,6 @@ in
}; };
}; };
config = lib.mkIf config.my.dev.julia.enable { config = lib.mkIf config.my.dev.julia.enable {
users.users = inputs.self.lib.mkUserAttrs lib config.my.toggleUsers.dev { inherit packages; }; users.users = inputs.self.lib.mkUserAttrs lib config.my.dev.julia.users { inherit packages; };
}; };
} }

View File

@@ -19,7 +19,14 @@ let
in in
{ {
options = { options = {
my.dev.nix.enable = lib.mkEnableOption "Install Nix tooling globally"; my.dev.nix = {
enable = lib.mkEnableOption "Install Nix tooling globally";
users = lib.mkOption {
type = lib.types.either lib.types.str (lib.types.listOf lib.types.str);
default = config.my.toggleUsers.dev;
description = "Users to install Nix packages for";
};
};
devShells.nix = lib.mkOption { devShells.nix = lib.mkOption {
type = lib.types.package; type = lib.types.package;
default = pkgs.mkShell { default = pkgs.mkShell {
@@ -33,8 +40,8 @@ in
}; };
}; };
config = lib.mkIf config.my.dev.nix.enable { config = lib.mkIf config.my.dev.nix.enable {
users.users = inputs.self.lib.mkUserAttrs lib config.my.toggleUsers.dev { inherit packages; }; users.users = inputs.self.lib.mkUserAttrs lib config.my.dev.nix.users { inherit packages; };
home-manager.users = inputs.self.lib.mkHomeManagerUsers lib config.my.toggleUsers.dev (_user: { home-manager.users = inputs.self.lib.mkHomeManagerUsers lib config.my.dev.nix.users (_user: {
programs.${shellType}.shellAliases = inputs.self.lib.mergeAliases inputs.self.lib.commonAliases { programs.${shellType}.shellAliases = inputs.self.lib.mergeAliases inputs.self.lib.commonAliases {
nixformat = '' nixformat = ''
deadnix -e && \ deadnix -e && \

View File

@@ -31,7 +31,14 @@ let
in in
{ {
options = { options = {
my.dev.python.enable = lib.mkEnableOption "Install Python tools globally"; my.dev.python = {
enable = lib.mkEnableOption "Install Python tools globally";
users = lib.mkOption {
type = lib.types.either lib.types.str (lib.types.listOf lib.types.str);
default = config.my.toggleUsers.dev;
description = "Users to install Python packages for";
};
};
devShells.python = lib.mkOption { devShells.python = lib.mkOption {
type = lib.types.package; type = lib.types.package;
default = pkgs.mkShell { default = pkgs.mkShell {
@@ -47,10 +54,10 @@ in
}; };
config = lib.mkMerge [ config = lib.mkMerge [
(lib.mkIf config.my.dev.python.enable { (lib.mkIf config.my.dev.python.enable {
users.users = inputs.self.lib.mkUserAttrs lib config.my.toggleUsers.dev { inherit packages; }; users.users = inputs.self.lib.mkUserAttrs lib config.my.dev.python.users { inherit packages; };
}) })
{ {
home-manager.users = inputs.self.lib.mkHomeManagerUsers lib config.my.toggleUsers.dev (_user: { home-manager.users = inputs.self.lib.mkHomeManagerUsers lib config.my.dev.python.users (_user: {
xdg.configFile."python/pythonrc".source = ../../dotfiles/pythonrc; xdg.configFile."python/pythonrc".source = ../../dotfiles/pythonrc;
}); });
environment.variables.PYTHONSTARTUP = "\${XDG_CONFIG_HOME}/python/pythonrc"; environment.variables.PYTHONSTARTUP = "\${XDG_CONFIG_HOME}/python/pythonrc";

View File

@@ -13,7 +13,14 @@ let
in in
{ {
options = { options = {
my.dev.ruby.enable = lib.mkEnableOption "Install Ruby tooling globally"; my.dev.ruby = {
enable = lib.mkEnableOption "Install Ruby tooling globally";
users = lib.mkOption {
type = lib.types.either lib.types.str (lib.types.listOf lib.types.str);
default = config.my.toggleUsers.dev;
description = "Users to install Ruby packages for";
};
};
devShells.ruby = lib.mkOption { devShells.ruby = lib.mkOption {
type = lib.types.package; type = lib.types.package;
default = pkgs.mkShell { default = pkgs.mkShell {
@@ -28,7 +35,7 @@ in
}; };
config = lib.mkMerge [ config = lib.mkMerge [
(lib.mkIf config.my.dev.ruby.enable { (lib.mkIf config.my.dev.ruby.enable {
users.users = inputs.self.lib.mkUserAttrs lib config.my.toggleUsers.dev { inherit packages; }; users.users = inputs.self.lib.mkUserAttrs lib config.my.dev.ruby.users { inherit packages; };
}) })
{ {
environment.variables = { environment.variables = {

View File

@@ -18,7 +18,14 @@ let
in in
{ {
options = { options = {
my.dev.rust.enable = lib.mkEnableOption "Install Rust tooling globally"; my.dev.rust = {
enable = lib.mkEnableOption "Install Rust tooling globally";
users = lib.mkOption {
type = lib.types.either lib.types.str (lib.types.listOf lib.types.str);
default = config.my.toggleUsers.dev;
description = "Users to install Rust packages for";
};
};
devShells.rust = lib.mkOption { devShells.rust = lib.mkOption {
type = lib.types.package; type = lib.types.package;
default = pkgs.mkShell { default = pkgs.mkShell {
@@ -33,7 +40,7 @@ in
}; };
config = lib.mkMerge [ config = lib.mkMerge [
(lib.mkIf config.my.dev.rust.enable { (lib.mkIf config.my.dev.rust.enable {
users.users = inputs.self.lib.mkUserAttrs lib config.my.toggleUsers.dev { inherit packages; }; users.users = inputs.self.lib.mkUserAttrs lib config.my.dev.rust.users { inherit packages; };
}) })
{ {
environment.variables.CARGO_HOME = "\${XDG_DATA_HOME}/cargo"; environment.variables.CARGO_HOME = "\${XDG_DATA_HOME}/cargo";

View File

@@ -17,7 +17,14 @@ let
in in
{ {
options = { options = {
my.dev.sh.enable = lib.mkEnableOption "Install shell scripting tools globally"; my.dev.sh = {
enable = lib.mkEnableOption "Install shell scripting tools globally";
users = lib.mkOption {
type = lib.types.either lib.types.str (lib.types.listOf lib.types.str);
default = config.my.toggleUsers.dev;
description = "Users to install shell scripting packages for";
};
};
devShells.sh = lib.mkOption { devShells.sh = lib.mkOption {
type = lib.types.package; type = lib.types.package;
default = pkgs.mkShell { default = pkgs.mkShell {
@@ -31,6 +38,6 @@ in
}; };
}; };
config = lib.mkIf config.my.dev.sh.enable { config = lib.mkIf config.my.dev.sh.enable {
users.users = inputs.self.lib.mkUserAttrs lib config.my.toggleUsers.dev { inherit packages; }; users.users = inputs.self.lib.mkUserAttrs lib config.my.dev.sh.users { inherit packages; };
}; };
} }

View File

@@ -15,7 +15,14 @@ let
in in
{ {
options = { options = {
my.dev.zig.enable = lib.mkEnableOption "Install Zig tooling globally"; my.dev.zig = {
enable = lib.mkEnableOption "Install Zig tooling globally";
users = lib.mkOption {
type = lib.types.either lib.types.str (lib.types.listOf lib.types.str);
default = config.my.toggleUsers.dev;
description = "Users to install Zig packages for";
};
};
devShells.zig = lib.mkOption { devShells.zig = lib.mkOption {
type = lib.types.package; type = lib.types.package;
default = pkgs.mkShell { default = pkgs.mkShell {
@@ -29,6 +36,6 @@ in
}; };
}; };
config = lib.mkIf config.my.dev.zig.enable { config = lib.mkIf config.my.dev.zig.enable {
users.users = inputs.self.lib.mkUserAttrs lib config.my.toggleUsers.dev { inherit packages; }; users.users = inputs.self.lib.mkUserAttrs lib config.my.dev.zig.users { inherit packages; };
}; };
} }

View File

@@ -13,6 +13,11 @@
enable = lib.mkEnableOption "Whether to enable this script"; enable = lib.mkEnableOption "Whether to enable this script";
install = lib.mkEnableOption "Whether to install the script package"; install = lib.mkEnableOption "Whether to install the script package";
service = lib.mkEnableOption "Whether to enable the script service"; service = lib.mkEnableOption "Whether to enable the script service";
users = lib.mkOption {
type = lib.types.either lib.types.str (lib.types.listOf lib.types.str);
default = config.my.toggleUsers.scripts;
description = "Users to install this script for";
};
name = lib.mkOption { name = lib.mkOption {
type = lib.types.str; type = lib.types.str;
description = "Name of the script."; description = "Name of the script.";
@@ -39,12 +44,27 @@
config = lib.mkIf (lib.any (s: s.enable) (lib.attrValues config.my.scripts)) { config = lib.mkIf (lib.any (s: s.enable) (lib.attrValues config.my.scripts)) {
users.users = users.users =
let let
packages = scriptList =
config.my.scripts config.my.scripts
|> lib.mapAttrsToList (_name: script: lib.optional (script.enable && script.install) script.package) |> lib.mapAttrsToList (_name: script: lib.optional (script.enable && script.install) script)
|> lib.flatten; |> lib.flatten;
userMap = lib.foldl' (
acc: script:
let
users = inputs.self.lib.normalizeUsers script.users;
in in
inputs.self.lib.mkUserPackages lib config.my.toggleUsers.scripts packages; lib.foldl' (
acc': user:
acc'
// {
${user} = (acc'.${user} or [ ]) ++ [ script.package ];
}
) acc users
) { } scriptList;
in
lib.mkMerge (
lib.mapAttrsToList (user: packages: inputs.self.lib.mkUserPackages lib user packages) userMap
);
systemd.user.services = systemd.user.services =
config.my.scripts config.my.scripts
|> lib.mapAttrs' ( |> lib.mapAttrs' (

View File

@@ -11,8 +11,10 @@
cloudflare-api.sopsFile = ../../secrets/env.yaml; cloudflare-api.sopsFile = ../../secrets/env.yaml;
dns = { dns = {
sopsFile = ../../secrets/env.yaml; sopsFile = ../../secrets/env.yaml;
owner = config.users.users.${config.my.toggleUsers.scripts}.name; owner = config.users.users.${inputs.self.lib.getFirstUser config.my.scripts.update-dns.users}.name;
inherit (config.users.users.${config.my.toggleUsers.scripts}) group; inherit (config.users.users.${inputs.self.lib.getFirstUser config.my.scripts.update-dns.users})
group
;
}; };
}; };
services.cloudflare-dyndns = { services.cloudflare-dyndns = {

View File

@@ -12,13 +12,20 @@ let
]; ];
in in
{ {
options.my.services.printing.enable = lib.mkEnableOption "printing services and drivers"; options.my.services.printing = {
enable = lib.mkEnableOption "printing services and drivers";
users = lib.mkOption {
type = lib.types.either lib.types.str (lib.types.listOf lib.types.str);
default = config.my.toggleUsers.services;
description = "Users to install printing packages for";
};
};
config = lib.mkIf config.my.services.printing.enable { config = lib.mkIf config.my.services.printing.enable {
users.users = users.users =
let let
packages = [ pkgs.simple-scan ]; packages = [ pkgs.simple-scan ];
in in
inputs.self.lib.mkUserPackages lib config.my.toggleUsers.services packages; inputs.self.lib.mkUserPackages lib config.my.services.printing.users packages;
services.printing = { services.printing = {
enable = true; enable = true;
drivers = printingDrivers; drivers = printingDrivers;

View File

@@ -6,7 +6,8 @@
... ...
}: }:
{ {
options.my.shell.type = lib.mkOption { options.my.shell = {
type = lib.mkOption {
type = lib.types.enum [ type = lib.types.enum [
"bash" "bash"
"zsh" "zsh"
@@ -14,11 +15,17 @@
default = "bash"; default = "bash";
description = "The shell to use system-wide (bash or zsh)"; description = "The shell to use system-wide (bash or zsh)";
}; };
users = lib.mkOption {
type = lib.types.either lib.types.str (lib.types.listOf lib.types.str);
default = config.my.toggleUsers.shell;
description = "Users to configure shell for";
};
};
config = { config = {
users.users = lib.mkMerge ( users.users = lib.mkMerge (
map (user: { map (user: {
${user}.shell = pkgs.${config.my.shell.type}; ${user}.shell = pkgs.${config.my.shell.type};
}) (inputs.self.lib.normalizeUsers config.my.toggleUsers.shell) }) (inputs.self.lib.normalizeUsers config.my.shell.users)
); );
programs.zsh.enable = config.my.shell.type == "zsh"; programs.zsh.enable = config.my.shell.type == "zsh";
}; };

View File

@@ -6,7 +6,14 @@
... ...
}: }:
{ {
options.my.shell.exercism.enable = lib.mkEnableOption "Exercism coding practice platform"; options.my.shell.exercism = {
enable = lib.mkEnableOption "Exercism coding practice platform";
users = lib.mkOption {
type = lib.types.either lib.types.str (lib.types.listOf lib.types.str);
default = config.my.toggleUsers.shell;
description = "Users to install Exercism for";
};
};
config = lib.mkIf config.my.shell.exercism.enable { config = lib.mkIf config.my.shell.exercism.enable {
users.users = users.users =
let let
@@ -17,6 +24,6 @@
; ;
}; };
in in
inputs.self.lib.mkUserPackages lib config.my.toggleUsers.shell packages; inputs.self.lib.mkUserPackages lib config.my.shell.exercism.users packages;
}; };
} }

View File

@@ -6,19 +6,27 @@
... ...
}: }:
{ {
options.my.shell.multimedia.enable = lib.mkEnableOption "multimedia CLI tools and codecs"; options.my.shell.multimedia = {
enable = lib.mkEnableOption "multimedia CLI tools and codecs";
users = lib.mkOption {
type = lib.types.either lib.types.str (lib.types.listOf lib.types.str);
default = config.my.toggleUsers.shell;
description = "Users to install multimedia shell tools for";
};
};
config = lib.mkIf config.my.shell.multimedia.enable { config = lib.mkIf config.my.shell.multimedia.enable {
sops.secrets."gallery-dl/secrets" = sops.secrets."gallery-dl/secrets" =
let let
# Use first user for secret ownership user = inputs.self.lib.getFirstUser config.my.shell.multimedia.users;
user = inputs.self.lib.getFirstUser config.my.toggleUsers.shell;
in in
{ {
sopsFile = ../../secrets/gallery.yaml; sopsFile = ../../secrets/gallery.yaml;
owner = user; owner = user;
mode = "0400"; mode = "0400";
}; };
home-manager.users = inputs.self.lib.mkHomeManagerUsers lib config.my.toggleUsers.shell (user: { home-manager.users =
inputs.self.lib.mkHomeManagerUsers lib config.my.shell.multimedia.users
(user: {
programs = { programs = {
yt-dlp = { yt-dlp = {
enable = true; enable = true;
@@ -54,6 +62,6 @@
; ;
}; };
in in
inputs.self.lib.mkUserPackages lib config.my.toggleUsers.shell packages; inputs.self.lib.mkUserPackages lib config.my.shell.multimedia.users packages;
}; };
} }

View File

@@ -9,9 +9,16 @@ let
shellType = config.my.shell.type; shellType = config.my.shell.type;
in in
{ {
options.my.shell.tools.enable = lib.mkEnableOption "shell tools and utilities"; options.my.shell.tools = {
enable = lib.mkEnableOption "shell tools and utilities";
users = lib.mkOption {
type = lib.types.either lib.types.str (lib.types.listOf lib.types.str);
default = config.my.toggleUsers.shell;
description = "Users to install shell tools for";
};
};
config = lib.mkIf config.my.shell.tools.enable { config = lib.mkIf config.my.shell.tools.enable {
home-manager.users = inputs.self.lib.mkHomeManagerUsers lib config.my.toggleUsers.shell (user: { home-manager.users = inputs.self.lib.mkHomeManagerUsers lib config.my.shell.tools.users (user: {
programs = { programs = {
hstr.enable = true; hstr.enable = true;
htop = { htop = {
@@ -114,7 +121,7 @@ in
; ;
}; };
in in
inputs.self.lib.mkUserPackages lib config.my.toggleUsers.shell packages; inputs.self.lib.mkUserPackages lib config.my.shell.tools.users packages;
environment.variables = { environment.variables = {
HISTFILE = "\${XDG_STATE_HOME}/bash/history"; HISTFILE = "\${XDG_STATE_HOME}/bash/history";
LESSHISTFILE = "-"; LESSHISTFILE = "-";