Enable widgets on per host basis

This commit is contained in:
SebastianStork 2024-04-02 19:43:29 +02:00
parent af5e9e85d7
commit 7e59fd1426
4 changed files with 54 additions and 16 deletions

View file

@ -28,13 +28,6 @@
pkgs = nixpkgs.legacyPackages.${system}; pkgs = nixpkgs.legacyPackages.${system};
in { in {
nixosConfigurations = { nixosConfigurations = {
dell-laptop = nixpkgs.lib.nixosSystem {
specialArgs = {inherit inputs;};
modules = [
./hosts/dell-laptop
./users/seb
];
};
seb-desktop = nixpkgs.lib.nixosSystem { seb-desktop = nixpkgs.lib.nixosSystem {
specialArgs = {inherit inputs;}; specialArgs = {inherit inputs;};
modules = [ modules = [
@ -42,6 +35,13 @@
./users/seb ./users/seb
]; ];
}; };
dell-laptop = nixpkgs.lib.nixosSystem {
specialArgs = {inherit inputs;};
modules = [
./hosts/dell-laptop
"${./.}/users/seb/@dell-laptop.nix"
];
};
}; };
formatter.${system} = nixpkgs.legacyPackages.${system}.alejandra.overrideAttrs { formatter.${system} = nixpkgs.legacyPackages.${system}.alejandra.overrideAttrs {

View file

@ -9,10 +9,22 @@ in {
imports = [./qtile.nix]; imports = [./qtile.nix];
options.myConfig.de = { options.myConfig.de = {
theming.enable = lib.mkEnableOption "";
wallpaper = lib.mkOption { wallpaper = lib.mkOption {
type = lib.types.path; type = lib.types.path;
}; };
theming.enable = lib.mkEnableOption "";
widget = {
backlight = {
enable = lib.mkEnableOption "";
device = lib.mkOption {
type = lib.types.str;
};
};
battery.enable = lib.mkEnableOption "";
};
tray = { tray = {
syncthing.enable = lib.mkEnableOption ""; syncthing.enable = lib.mkEnableOption "";
networkmanager.enable = lib.mkEnableOption ""; networkmanager.enable = lib.mkEnableOption "";

View file

@ -3,10 +3,12 @@
pkgs, pkgs,
lib, lib,
... ...
}: { }: let
cfg = config.myConfig.de;
in {
options.myConfig.de.qtile.enable = lib.mkEnableOption ""; options.myConfig.de.qtile.enable = lib.mkEnableOption "";
config = lib.mkIf config.myConfig.de.qtile.enable { config = lib.mkIf cfg.qtile.enable {
home.packages = [ home.packages = [
# Widget dependencies # Widget dependencies
pkgs.python311Packages.iwlib pkgs.python311Packages.iwlib
@ -18,7 +20,7 @@
pkgs.brightnessctl pkgs.brightnessctl
]; ];
home.file.".background-image".source = config.myConfig.de.wallpaper; home.file.".background-image".source = cfg.wallpaper;
xsession.enable = true; xsession.enable = true;
@ -34,7 +36,22 @@
services.dunst.enable = true; services.dunst.enable = true;
xdg.configFile."qtile/config.py".text = '' xdg.configFile."qtile/config.py".text = let
backlightWidget =
if cfg.widget.backlight.enable
then ''
widget.Sep(),
widget.Backlight(fmt="󰃠 {}", backlight_name='${cfg.widget.backlight.device}'),
''
else "";
batteryWidget =
if cfg.widget.battery.enable
then ''
widget.Sep(),
widget.Battery(format="󰁹 {percent:2.0%}"),
''
else "";
in ''
import os import os
import subprocess import subprocess
@ -160,10 +177,8 @@
]), ]),
widget.Sep(), widget.Sep(),
widget.PulseVolume(fmt="󰕾 {}"), widget.PulseVolume(fmt="󰕾 {}"),
widget.Sep(), ${backlightWidget}
widget.Backlight(fmt="󰃠 {}", backlight_name='amdgpu_bl1'), ${batteryWidget}
widget.Sep(),
widget.Battery(format="󰁹 {percent:2.0%}"),
], ],
26, 26,
), ),

View file

@ -0,0 +1,11 @@
{...}: {
imports = [./default.nix];
home-manager.users.seb.myConfig.de.widget = {
backlight = {
enable = true;
device = "amdgpu_bl1";
};
battery.enable = true;
};
}