refactor(modules): make sure nothing is added without setting enable

This commit is contained in:
matt1432 2025-01-04 19:02:30 -05:00
parent 4a2ad39114
commit 49dc072b81
56 changed files with 684 additions and 506 deletions

View file

@ -6,6 +6,19 @@ self: {
}: let
inherit (self.inputs) hyprland;
inherit (self.lib.hypr) mkBind;
inherit (lib) concatStringsSep mkIf optionals;
cfg = config.roles.desktop;
hyprCfg =
config
.home-manager
.users
.${cfg.user}
.wayland
.windowManager
.hyprland;
in {
imports = [
(import ../../ags self)
@ -18,20 +31,7 @@ in {
(import ./modules/security.nix self)
];
config = let
inherit (lib) concatStringsSep optionals;
cfg = config.roles.desktop;
hyprCfg =
config
.home-manager
.users
.${cfg.user}
.wayland
.windowManager
.hyprland;
in {
config = mkIf cfg.enable {
services = {
dbus.enable = true;
gvfs.enable = true;

View file

@ -1,5 +1,14 @@
{pkgs, ...}: {
config = {
{
lib,
osConfig,
pkgs,
...
}: let
inherit (lib) mkIf;
cfg = osConfig.roles.desktop;
in {
config = mkIf cfg.enable {
programs.bash.shellAliases = {
# https://wiki.hyprland.org/Contributing-and-Debugging/#lsp-and-formatting
"mkCMakeFiles" = "${pkgs.cmake}/bin/cmake -S . -B build/ -G Ninja -DCMAKE_EXPORT_COMPILE_COMMANDS=ON";

View file

@ -2,10 +2,12 @@
lib,
osConfig,
...
}: {
config = let
cfg = osConfig.roles.desktop;
in {
}: let
inherit (lib) mkIf;
cfg = osConfig.roles.desktop;
in {
config = mkIf cfg.enable {
programs = {
# https://codeberg.org/dnkl/foot/wiki#spawning-new-terminal-instances-in-the-current-working-directory
bash.bashrcExtra =

View file

@ -1,7 +1,16 @@
self: {pkgs, ...}: let
self: {
lib,
osConfig,
pkgs,
...
}: let
inherit (self.lib.hypr) mkBind;
inherit (lib) mkIf;
cfg = osConfig.roles.desktop;
in {
config = {
config = mkIf cfg.enable {
wayland.windowManager.hyprland = {
plugins = [self.inputs.hyprland-plugins.packages.${pkgs.system}.hyprexpo];

View file

@ -4,12 +4,13 @@ self: {
pkgs,
...
}: let
inherit (lib) map mkIf;
inherit (self.lib.hypr) mkBind;
inherit (lib) map mkIf;
cfg = osConfig.roles.desktop;
in {
config = mkIf cfg.isTouchscreen {
config = mkIf (cfg.enable && cfg.isTouchscreen) {
wayland.windowManager.hyprland = {
plugins = [self.inputs.hyprgrass.packages.${pkgs.system}.default];

View file

@ -2,25 +2,27 @@ self: {
osConfig,
lib,
...
}: {
config = let
inherit (lib) map;
inherit (self.lib.hypr) mkBind;
}: let
inherit (self.lib.hypr) mkBind;
inherit (osConfig.services.xserver) xkb;
inherit (osConfig.roles.desktop) mainMonitor;
inherit (lib) mkIf;
miceNames = [
"logitech-g502-x"
"logitech-g502-hero-gaming-mouse"
];
cfg = osConfig.roles.desktop;
mkConf = name: {
inherit name;
sensitivity = 0;
accel_profile = "flat";
};
in {
inherit (osConfig.services.xserver) xkb;
miceNames = [
"logitech-g502-x"
"logitech-g502-hero-gaming-mouse"
];
mkConf = name: {
inherit name;
sensitivity = 0;
accel_profile = "flat";
};
in {
config = mkIf cfg.enable {
wayland.windowManager.hyprland = {
settings = {
device = map mkConf miceNames;
@ -31,8 +33,8 @@ self: {
};
exec-once =
if mainMonitor != null
then ["hyprctl dispatch focusmonitor ${mainMonitor}"]
if cfg.mainMonitor != null
then ["hyprctl dispatch focusmonitor ${cfg.mainMonitor}"]
else [];
input = {

View file

@ -1,7 +1,16 @@
self: {pkgs, ...}: {
config = let
inherit (self.scopedPackages.${pkgs.system}) mpvScripts;
in {
self: {
lib,
osConfig,
pkgs,
...
}: let
inherit (self.scopedPackages.${pkgs.system}) mpvScripts;
inherit (lib) mkIf;
cfg = osConfig.roles.desktop;
in {
config = mkIf cfg.enable {
# For kdialog-open-files
home.packages = [
pkgs.kdialog

View file

@ -1,9 +1,18 @@
self: {pkgs, ...}: let
self: {
lib,
osConfig,
pkgs,
...
}: let
inherit (self.inputs) nixpkgs-wayland;
waypkgs = nixpkgs-wayland.packages.${pkgs.system};
inherit (lib) mkIf;
cfg = osConfig.roles.desktop;
in {
config = let
waypkgs = nixpkgs-wayland.packages.${pkgs.system};
in {
config = mkIf cfg.enable {
programs = {
obs-studio = {
enable = true;

View file

@ -1,9 +1,17 @@
self: {...}: let
self: {
config,
lib,
...
}: let
inherit (self.inputs) nix-gaming;
inherit (lib) mkIf;
cfg = config.roles.desktop;
in {
imports = [nix-gaming.nixosModules.pipewireLowLatency];
config = {
config = mkIf cfg.enable {
services = {
pulseaudio.enable = false;

View file

@ -1,7 +1,13 @@
{config, ...}: {
config = let
cfg = config.roles.desktop;
in {
{
config,
lib,
...
}: let
inherit (lib) mkIf;
cfg = config.roles.desktop;
in {
config = mkIf cfg.enable {
programs.dconf.enable = true;
home-manager.users.${cfg.user} = {

View file

@ -1,11 +1,14 @@
{
config,
lib,
pkgs,
...
}: {
config = let
cfg = config.roles.desktop;
in {
}: let
inherit (lib) mkIf;
cfg = config.roles.desktop;
in {
config = mkIf cfg.enable {
environment.systemPackages = [
pkgs.plasma5Packages.kio-admin
];

View file

@ -6,21 +6,22 @@ self: {
}: let
inherit (self.lib.hypr) mkBind;
inherit (self.inputs) jellyfin-flake;
inherit (lib) getExe mkIf optionals;
inherit (pkgs.writers) writeTOML;
cfg = config.roles.desktop;
flakeDir = config.environment.variables.FLAKE;
isNvidia = config.nvidia.enable;
restartTailscale = pkgs.writeShellScriptBin "restartTailscale" ''
sudo ${pkgs.systemd}/bin/systemctl restart tailscaled.service
'';
in {
imports = [./dolphin.nix];
config = let
inherit (lib) getExe map optionals;
inherit (pkgs.writers) writeTOML;
flakeDir = config.environment.variables.FLAKE;
cfg = config.roles.desktop;
isNvidia = config.nvidia.enable;
restartTailscale = pkgs.writeShellScriptBin "restartTailscale" ''
sudo ${pkgs.systemd}/bin/systemctl restart tailscaled.service
'';
in {
config = mkIf cfg.enable {
programs.kdeconnect.enable = true;
security.sudo.extraRules = [

View file

@ -1,5 +1,14 @@
{pkgs, ...}: {
config = {
{
config,
lib,
pkgs,
...
}: let
inherit (lib) mkIf;
cfg = config.roles.desktop;
in {
config = mkIf cfg.enable {
services = {
# Enable CUPS to print documents.
printing = {

View file

@ -1,7 +1,15 @@
self: {pkgs, ...}: let
self: {
config,
lib,
pkgs,
...
}: let
inherit (self.packages.${pkgs.system}) libratbag piper;
inherit (lib) mkIf;
cfg = config.roles.desktop;
in {
config = {
config = mkIf cfg.enable {
services.ratbagd = {
enable = true;

View file

@ -3,44 +3,45 @@ self: {
lib,
pkgs,
...
}: {
config = let
inherit (self.lib.hypr) mkBind;
inherit (lib) getExe map mkIf;
}: let
inherit (self.lib.hypr) mkBind;
cfg = config.roles.desktop;
inherit (lib) getExe map mkIf;
hmCfg = config.home-manager.users.${cfg.user};
hyprPkg = hmCfg.wayland.windowManager.hyprland.finalPackage;
cfg = config.roles.desktop;
# See modules/ags/packages.nix
lockPkg = hmCfg.programs.ags.lockPkg;
hmCfg = config.home-manager.users.${cfg.user};
hyprPkg = hmCfg.wayland.windowManager.hyprland.finalPackage;
runInDesktop = pkgs.writeShellApplication {
name = "runInDesktop";
runtimeInputs = [
pkgs.sudo
hyprPkg
];
# See modules/ags/packages.nix
lockPkg = hmCfg.programs.ags.lockPkg;
text = ''
params=( "$@" )
user="$(id -u ${cfg.user})"
readarray -t SIGS <<< "$(ls "/run/user/$user/hypr/")"
runInDesktop = pkgs.writeShellApplication {
name = "runInDesktop";
runtimeInputs = [
pkgs.sudo
hyprPkg
];
run() {
export HYPRLAND_INSTANCE_SIGNATURE="$1"
sudo -Eu ${cfg.user} hyprctl dispatch exec "''${params[@]}"
}
text = ''
params=( "$@" )
user="$(id -u ${cfg.user})"
readarray -t SIGS <<< "$(ls "/run/user/$user/hypr/")"
i=0
run() {
export HYPRLAND_INSTANCE_SIGNATURE="$1"
sudo -Eu ${cfg.user} hyprctl dispatch exec "''${params[@]}"
}
while ! run "''${SIGS[$i]}"; do
((i+=1))
done
'';
};
in {
i=0
while ! run "''${SIGS[$i]}"; do
((i+=1))
done
'';
};
in {
config = mkIf cfg.enable {
services.acpid = mkIf cfg.isLaptop {
enable = true;