treewide: cleanup config with enable options

This commit is contained in:
Leonardo Eugênio 2025-02-20 22:01:03 -03:00
parent d469c5fa79
commit 0a387960a2
28 changed files with 420 additions and 358 deletions

View file

@ -102,10 +102,17 @@
inputs.agenix.nixosModules.default inputs.agenix.nixosModules.default
inputs.home-manager.nixosModules.home-manager inputs.home-manager.nixosModules.home-manager
inputs.disko.nixosModules.disko inputs.disko.nixosModules.disko
(
{ config, ... }:
{ {
home-manager.useGlobalPkgs = true; home-manager.useGlobalPkgs = true;
home-manager.useUserPackages = true; home-manager.useUserPackages = true;
home-manager.users.lelgenio = import ./user/home.nix; home-manager.users.lelgenio = {
my = config.my;
imports = [
./user/home.nix
];
};
home-manager.backupFileExtension = "bkp"; home-manager.backupFileExtension = "bkp";
# Optionally, use home-manager.extraSpecialArgs to pass # Optionally, use home-manager.extraSpecialArgs to pass
# arguments to home.nix # arguments to home.nix
@ -113,6 +120,7 @@
inherit inputs; inherit inputs;
}; };
} }
)
] ]
++ lib.optional (desktop == "gnome") ./system/gnome.nix ++ lib.optional (desktop == "gnome") ./system/gnome.nix
++ lib.optional (desktop == "kde") ./system/kde.nix; ++ lib.optional (desktop == "kde") ./system/kde.nix;
@ -133,7 +141,6 @@
./system/monolith-gitlab-runner.nix ./system/monolith-gitlab-runner.nix
./system/monolith-forgejo-runner.nix ./system/monolith-forgejo-runner.nix
./system/nix-serve.nix ./system/nix-serve.nix
./system/steam.nix
] ++ common_modules; ] ++ common_modules;
}; };
double-rainbow = lib.nixosSystem { double-rainbow = lib.nixosSystem {
@ -151,7 +158,6 @@
++ [ ++ [
{ {
packages.media-packages.enable = lib.mkOverride 0 false; packages.media-packages.enable = lib.mkOverride 0 false;
programs.steam.enable = lib.mkOverride 0 false;
services.flatpak.enable = lib.mkOverride 0 false; services.flatpak.enable = lib.mkOverride 0 false;
} }
]; ];

View file

@ -41,6 +41,8 @@ in
package = pkgs.unstable.opentabletdriver; package = pkgs.unstable.opentabletdriver;
}; };
my.gaming.enable = true;
boot.extraModulePackages = with config.boot.kernelPackages; [ zenpower ]; boot.extraModulePackages = with config.boot.kernelPackages; [ zenpower ];
boot.initrd.kernelModules = [ "amdgpu" ]; boot.initrd.kernelModules = [ "amdgpu" ];

View file

@ -1,6 +1,18 @@
{ lib, ... }: { lib, ... }:
{ {
options = { options = {
my = lib.mkOption { }; my = {
themes = lib.mkOption { };
key = lib.mkOption { };
theme = lib.mkOption { };
accent = lib.mkOption { };
font = lib.mkOption { };
username = lib.mkOption { type = lib.types.str; };
mail = lib.mkOption { };
dmenu = lib.mkOption { type = lib.types.str; };
desktop = lib.mkOption { type = lib.types.str; };
browser = lib.mkOption { type = lib.types.str; };
editor = lib.mkOption { type = lib.types.str; };
};
}; };
} }

17
system/android.nix Normal file
View file

@ -0,0 +1,17 @@
{
config,
pkgs,
lib,
...
}:
{
options.my.android.enable = lib.mkEnableOption { };
config = lib.mkIf config.my.android.enable {
# Open kde connect ports
programs.kdeconnect.enable = true;
programs.adb.enable = true;
services.udev.packages = [ pkgs.android-udev-rules ];
};
}

View file

@ -2,7 +2,6 @@
config, config,
pkgs, pkgs,
lib, lib,
inputs,
... ...
}: }:
{ {

View file

@ -1,15 +1,11 @@
# Edit this configuration file to define what should be installed on # Edit this configuration file to define what should be installed on
# your system. Help is available in the configuration.nix(5) man page # your system. Help is available in the configuration.nix(5) man page
# and in the NixOS manual (accessible by running nixos-help). # and in the NixOS manual (accessible by running nixos-help).
{ { pkgs, ... }:
config,
pkgs,
inputs,
...
}:
{ {
imports = [ imports = [
./gamemode.nix ./android.nix
./gaming.nix
./media-packages.nix ./media-packages.nix
./boot.nix ./boot.nix
./thunar.nix ./thunar.nix
@ -25,39 +21,27 @@
../settings ../settings
]; ];
my = import ../user/variables.nix; my = import ../user/variables.nix // {
android.enable = true;
media-packages.enable = true;
containers.enable = true;
};
zramSwap.enable = true; zramSwap.enable = true;
programs.adb.enable = true;
services.udev.packages = [ pkgs.android-udev-rules ];
# Enable touchpad support (enabled default in most desktopManager). # Enable touchpad support (enabled default in most desktopManager).
services.libinput.enable = true; services.libinput.enable = true;
packages.media-packages.enable = true;
environment.systemPackages = with pkgs; [ environment.systemPackages = with pkgs; [
pavucontrol pavucontrol
glib # gsettings glib # gsettings
usbutils usbutils
# dracula-theme # gtk theme
adwaita-icon-theme # default gnome cursors adwaita-icon-theme # default gnome cursors
nix-output-monitor
]; ];
services.geoclue2.enable = true; services.geoclue2.enable = true;
# Workaround for nm-wait-online hanging??
# Ref: https://github.com/NixOS/nixpkgs/issues/180175
systemd.services.NetworkManager-wait-online = {
serviceConfig.ExecStart = [
""
"${pkgs.networkmanager}/bin/nm-online -q"
];
};
systemd.extraConfig = '' systemd.extraConfig = ''
DefaultTimeoutStopSec=10s DefaultTimeoutStopSec=10s
''; '';

View file

@ -1,5 +1,13 @@
{ pkgs, lib, ... }:
{ {
pkgs,
lib,
config,
...
}:
{
options.my.containers.enable = lib.mkEnableOption { };
config = lib.mkIf config.my.containers.enable {
services.flatpak.enable = true; services.flatpak.enable = true;
virtualisation.docker = { virtualisation.docker = {
@ -27,4 +35,5 @@
programs.extra-container.enable = true; programs.extra-container.enable = true;
programs.firejail.enable = true; programs.firejail.enable = true;
};
} }

View file

@ -1,27 +0,0 @@
{
config,
pkgs,
inputs,
...
}:
{
programs.gamemode.enable = true;
programs.gamemode.enableRenice = true;
programs.gamemode.settings = {
general = {
renice = 10;
};
# Warning: GPU optimisations have the potential to damage hardware
gpu = {
apply_gpu_optimisations = "accept-responsibility";
gpu_device = 0;
amd_performance_level = "high";
};
custom = {
start = "${pkgs.libnotify}/bin/notify-send 'GameMode started'";
end = "${pkgs.libnotify}/bin/notify-send 'GameMode ended'";
};
};
}

63
system/gaming.nix Normal file
View file

@ -0,0 +1,63 @@
{
config,
pkgs,
lib,
inputs,
...
}:
{
options.my.gaming.enable = lib.mkEnableOption { };
config = lib.mkIf config.my.gaming.enable {
programs.steam.enable = true;
programs.steam.extraPackages =
config.fonts.packages
++ (with pkgs; [
capitaine-cursors
bibata-cursors
mangohud
xdg-user-dirs
gamescope
# gamescope compatibility??
xorg.libXcursor
xorg.libXi
xorg.libXinerama
xorg.libXScrnSaver
libpng
libpulseaudio
libvorbis
stdenv.cc.cc.lib
libkrb5
keyutils
]);
environment.systemPackages = with pkgs; [
protontricks
bottles
inputs.dzgui-nix.packages.${pkgs.system}.default
];
programs.gamemode = {
enable = true;
enableRenice = true;
settings = {
general = {
renice = 10;
};
# Warning: GPU optimisations have the potential to damage hardware
gpu = {
apply_gpu_optimisations = "accept-responsibility";
gpu_device = 0;
amd_performance_level = "high";
};
custom = {
start = "${pkgs.libnotify}/bin/notify-send 'GameMode started'";
end = "${pkgs.libnotify}/bin/notify-send 'GameMode ended'";
};
};
};
};
}

View file

@ -5,10 +5,10 @@
... ...
}: }:
let let
cfg = config.packages.media-packages; cfg = config.my.media-packages;
in in
{ {
options.packages.media-packages = { options.my.media-packages = {
enable = lib.mkEnableOption "media packages"; enable = lib.mkEnableOption "media packages";
}; };
config = lib.mkIf cfg.enable { config = lib.mkIf cfg.enable {

View file

@ -6,8 +6,6 @@
# networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain"; # networking.proxy.noProxy = "127.0.0.1,localhost,internal.domain";
# Enable networking # Enable networking
networking.networkmanager.enable = true; networking.networkmanager.enable = true;
# Open kde connect ports
programs.kdeconnect.enable = true;
networking.firewall = { networking.firewall = {
enable = true; enable = true;
@ -15,7 +13,7 @@
}; };
# Enable CUPS to print documents. # Enable CUPS to print documents.
# services.printing.enable = true; services.printing.enable = true;
security.rtkit.enable = true; security.rtkit.enable = true;
services.openssh = { services.openssh = {
@ -27,4 +25,13 @@
KbdInteractiveAuthentication = false; KbdInteractiveAuthentication = false;
}; };
}; };
# Workaround for nm-wait-online hanging??
# Ref: https://github.com/NixOS/nixpkgs/issues/180175
systemd.services.NetworkManager-wait-online = {
serviceConfig.ExecStart = [
""
"${pkgs.networkmanager}/bin/nm-online -q"
];
};
} }

View file

@ -1,36 +0,0 @@
{
config,
pkgs,
inputs,
...
}:
{
programs.steam.enable = true;
programs.steam.extraPackages =
config.fonts.packages
++ (with pkgs; [
capitaine-cursors
bibata-cursors
mangohud
xdg-user-dirs
gamescope
# gamescope compatibility??
xorg.libXcursor
xorg.libXi
xorg.libXinerama
xorg.libXScrnSaver
libpng
libpulseaudio
libvorbis
stdenv.cc.cc.lib
libkrb5
keyutils
]);
environment.systemPackages = with pkgs; [
protontricks
bottles
inputs.dzgui-nix.packages.${pkgs.system}.default
];
}

8
user/dummy.nix Normal file
View file

@ -0,0 +1,8 @@
{ lib, ... }:
{
options.my = {
android.enable = lib.mkEnableOption { };
media-packages.enable = lib.mkEnableOption { };
containers.enable = lib.mkEnableOption { };
};
}

View file

@ -6,9 +6,12 @@
}: }:
let let
inherit (config.my) accent editor desktop; inherit (config.my) accent editor desktop;
cfg = config.my.fish;
in in
{ {
config = { options.my.fish.enable = lib.mkEnableOption { };
config = lib.mkIf cfg.enable {
programs.fish = { programs.fish = {
enable = true; enable = true;
shellInit = '' shellInit = ''

View file

@ -2,16 +2,10 @@
config, config,
pkgs, pkgs,
lib, lib,
inputs,
... ...
}: }:
let let
inherit (config.my) inherit (config.my) theme accent;
key
theme
accent
font
;
inherit (theme) color; inherit (theme) color;
colors = { colors = {

24
user/gaming.nix Normal file
View file

@ -0,0 +1,24 @@
{
config,
lib,
pkgs,
...
}:
let
cfg = config.my.gaming;
in
{
options.my.gaming.enable = lib.mkEnableOption { };
config = lib.mkIf cfg.enable {
my.mangohud.enable = true;
home.packages = with pkgs; [
# lutris-unwrapped
# steam # It's enabled in the system config
tlauncher
gamescope
glxinfo
vulkan-tools
];
};
}

View file

@ -7,9 +7,13 @@
let let
inherit (config.my) accent theme editor; inherit (config.my) accent theme editor;
inherit (theme) color; inherit (theme) color;
cfg = config.my.helix;
in in
{ {
config = { options.my.helix.enable = lib.mkEnableOption "Enable helix config";
config = lib.mkIf cfg.enable {
programs.helix = { programs.helix = {
enable = true; enable = true;
settings = { settings = {

View file

@ -8,6 +8,7 @@
}: }:
{ {
imports = [ imports = [
./dummy.nix
./waybar ./waybar
./helix.nix ./helix.nix
./kakoune ./kakoune
@ -21,6 +22,7 @@
./rofi.nix ./rofi.nix
./mpv.nix ./mpv.nix
./mangohud.nix ./mangohud.nix
./gaming.nix
./pipewire.nix ./pipewire.nix
./mimeapps.nix ./mimeapps.nix
./desktop-entries.nix ./desktop-entries.nix
@ -44,7 +46,11 @@
./powerplay-led-idle.nix ./powerplay-led-idle.nix
]; ];
my = import ./variables.nix; my = import ./variables.nix // {
sway.enable = true;
pass.enable = true;
fish.enable = true;
};
# Home Manager needs a bit of information about you and the # Home Manager needs a bit of information about you and the
# paths it should manage. # paths it should manage.
@ -91,14 +97,6 @@
mate.engrampa mate.engrampa
# gnome.nautilus # gnome.nautilus
## games
# lutris-unwrapped
# steam # It's enabled in the system config
tlauncher
gamescope
glxinfo
vulkan-tools
## Theming ## Theming
orchis_theme_compact orchis_theme_compact
papirus_red papirus_red
@ -130,6 +128,8 @@
unstable.blade-formatter unstable.blade-formatter
nixfmt-rfc-style nixfmt-rfc-style
nix-output-monitor
]; ];
fonts.fontconfig.enable = true; fonts.fontconfig.enable = true;

View file

@ -1,22 +1,11 @@
{ { config, lib, ... }:
config,
pkgs,
lib,
font,
...
}:
let let
inherit (config.my) cfg = config.my.mangohud;
key
theme
color
accent
font
;
in in
{ {
config = { options.my.mangohud.enable = lib.mkEnableOption { };
programs.mangohud = {
config.programs.mangohud = lib.mkIf cfg.enable {
enable = true; enable = true;
enableSessionWide = true; enableSessionWide = true;
settings = { settings = {
@ -76,5 +65,4 @@ in
# output_folder = "/home/lelgenio"; # output_folder = "/home/lelgenio";
}; };
}; };
};
} }

View file

@ -4,8 +4,13 @@
config, config,
... ...
}: }:
let
cfg = config.my.mpd;
in
{ {
config = lib.mkIf (config.my.desktop != "gnome") { options.my.mpd.enable = lib.mkEnableOption { };
config = lib.mkIf cfg.enable {
services.mpd = { services.mpd = {
enable = true; enable = true;
musicDirectory = config.home.homeDirectory + "/Música"; musicDirectory = config.home.homeDirectory + "/Música";

View file

@ -2,11 +2,15 @@
config, config,
pkgs, pkgs,
lib, lib,
inputs,
... ...
}: }:
let
cfg = config.my.pass;
in
{ {
config = { options.my.pass.enable = lib.mkEnableOption { };
config = lib.mkIf cfg.enable {
programs.password-store = { programs.password-store = {
enable = true; enable = true;
package = pkgs.pass.withExtensions ( package = pkgs.pass.withExtensions (

View file

@ -5,13 +5,10 @@
... ...
}: }:
let let
inherit (config.my) inherit (config.my) accent font theme;
key
accent
font
theme
;
inherit (theme) color; inherit (theme) color;
cfg = config.my.sway;
in in
{ {
imports = [ imports = [
@ -24,10 +21,17 @@ in
./swaylock.nix ./swaylock.nix
./theme.nix ./theme.nix
]; ];
config = lib.mkIf (config.my.desktop == "sway") {
services.mako.enable = true; options.my.sway.enable = lib.mkEnableOption { };
services.swayidle.enable = true;
services.kanshi.enable = true; config = lib.mkIf cfg.enable {
my.mako.enable = true;
my.kanshi.enable = true;
my.swayidle.enable = true;
my.swaylock.enable = true;
my.mpd.enable = true;
my.zathura.enable = true;
my.waybar.enable = true;
wayland.windowManager.sway = { wayland.windowManager.sway = {
enable = true; enable = true;
@ -36,7 +40,7 @@ in
bars = [ ]; bars = [ ];
floating.modifier = "Mod4"; floating.modifier = "Mod4";
terminal = pkgs.alacritty.executable; terminal = lib.getExe pkgs.alacritty;
window.titlebar = false; window.titlebar = false;
gaps = { gaps = {
@ -69,7 +73,7 @@ in
}; };
output = { output = {
"*" = { "*" = {
adaptive_sync = "off"; adaptive_sync = "on";
bg = "${theme.background} fill"; bg = "${theme.background} fill";
mode = "1920x1080@144.000Hz"; mode = "1920x1080@144.000Hz";
}; };
@ -132,7 +136,6 @@ in
swaylock swaylock
wdisplays wdisplays
waybar
dhist dhist
demoji demoji
bmenu bmenu

View file

@ -1,20 +1,12 @@
{ { config, lib, ... }:
config,
pkgs,
lib,
...
}:
let let
inherit (config.my) cfg = config.my.kanshi;
key
accent
font
theme
;
inherit (theme) color;
in in
{ {
services.kanshi = { options.my.kanshi.enable = lib.mkEnableOption { };
config.services.kanshi = lib.mkIf cfg.enable {
enable = true;
settings = [ settings = [
{ {
profile = { profile = {

View file

@ -6,15 +6,20 @@
}: }:
let let
inherit (config.my) inherit (config.my)
key
accent accent
font font
theme theme
; ;
inherit (theme) color; inherit (theme) color;
cfg = config.my.mako;
in in
{ {
options.my.mako.enable = lib.mkEnableOption { };
config = lib.mkIf cfg.enable {
services.mako = { services.mako = {
enable = true;
borderSize = 2; borderSize = 2;
padding = "5"; padding = "5";
margin = "15"; margin = "15";
@ -62,4 +67,5 @@ in
WantedBy = [ "sway-session.target" ]; WantedBy = [ "sway-session.target" ];
}; };
}; };
};
} }

View file

@ -5,18 +5,15 @@
... ...
}: }:
let let
inherit (config.my)
key
accent
font
theme
;
inherit (theme) color;
asScript = filename: text: toString (pkgs.writeShellScript filename text); asScript = filename: text: toString (pkgs.writeShellScript filename text);
cfg = config.my.swayidle;
in in
{ {
services.swayidle = { options.my.swayidle.enable = lib.mkEnableOption { };
config.services.swayidle = {
enable = cfg.enable;
timeouts = [ timeouts = [
{ {
timeout = 360; timeout = 360;

View file

@ -1,20 +1,14 @@
{ { config, lib, ... }:
config,
pkgs,
lib,
...
}:
let let
inherit (config.my) inherit (config.my) accent font theme;
key
accent
font
theme
;
inherit (theme) color; inherit (theme) color;
cfg = config.my.swaylock;
in in
{ {
programs.swaylock.settings = { options.my.swaylock.enable = lib.mkEnableOption { };
config.programs.swaylock.settings = lib.mkIf cfg.enable {
image = toString theme.background; image = toString theme.background;
font = font.interface; font = font.interface;
font-size = font.size.medium; font-size = font.size.medium;

View file

@ -14,9 +14,13 @@ let
font font
; ;
inherit (theme) color; inherit (theme) color;
cfg = config.my.waybar;
in in
{ {
config = { options.my.waybar.enable = lib.mkEnableOption { };
config = lib.mkIf cfg.enable {
programs.waybar = { programs.waybar = {
enable = true; enable = true;
systemd.enable = true; systemd.enable = true;

View file

@ -1,10 +1,4 @@
{ { config, lib, ... }:
config,
pkgs,
lib,
font,
...
}:
let let
inherit (config.my) inherit (config.my)
key key
@ -13,11 +7,16 @@ let
theme theme
; ;
inherit (theme) color; inherit (theme) color;
cfg = config.my.zathura;
in in
{ {
config = { options.my.zathura.enable = lib.mkEnableOption { };
programs.zathura.enable = true;
programs.zathura.options = { config = lib.mkIf cfg.enable {
programs.zathura = {
enable = true;
options = {
font = "${font.mono} ${toString font.size.small}"; font = "${font.mono} ${toString font.size.small}";
guioptions = "s"; guioptions = "s";
@ -49,7 +48,7 @@ in
index-active-bg = accent.color; index-active-bg = accent.color;
index-active-fg = accent.fg; index-active-fg = accent.fg;
}; };
programs.zathura.mappings = { mappings = {
"<C-b>" = "toggle_statusbar"; "<C-b>" = "toggle_statusbar";
${key.left} = "scroll left"; ${key.left} = "scroll left";
${key.down} = "scroll down"; ${key.down} = "scroll down";
@ -65,4 +64,5 @@ in
${lib.toUpper key.next} = "search backward"; ${lib.toUpper key.next} = "search backward";
}; };
}; };
};
} }