refac: add extra home module...

to configure polybar wifi device manually for each machine
This commit is contained in:
Dmitriy Pleshevskiy 2022-10-12 02:01:16 +03:00
parent 454f167145
commit 7903732c09
Signed by: pleshevskiy
GPG key ID: 1B59187B161C0215
4 changed files with 149 additions and 139 deletions

View file

@ -82,12 +82,13 @@
(hostname: { system (hostname: { system
, specialArgs ? { } , specialArgs ? { }
, extraModules ? [ ] , extraModules ? [ ]
, extraHomeModule ? null
, nixpkgs ? inputs.nixpkgs , nixpkgs ? inputs.nixpkgs
}: }:
nixpkgs.lib.nixosSystem { nixpkgs.lib.nixosSystem {
inherit system; inherit system;
specialArgs = { inherit inputs; } // specialArgs; specialArgs = { inherit inputs extraHomeModule; } // specialArgs;
modules = modules =
(with inputs; [ (with inputs; [

View file

@ -11,19 +11,24 @@ in
../modules/garbage-collector.nix ../modules/garbage-collector.nix
../users/jan ../users/jan
]; ];
extraHomeModule = { ... }: {
local.polybar.wifiDevice = "wlp11s0f3u2";
};
}; };
asus-gl553vd = { asus-gl553vd = {
system = "x86_64-linux"; system = "x86_64-linux";
specialArgs = {
fontSize = 6.0;
};
extraModules = [ extraModules = [
hardware.common-cpu-intel hardware.common-cpu-intel
../users/jan ../users/jan
]; ];
extraHomeModule = { ... }: {
local.polybar.wifiDevice = "wlp2s0";
local.alacritty.fontSize = 6.0;
};
}; };
} }

View file

@ -1,4 +1,4 @@
{ config, pkgs, lib, inputs, fontSize ? null, ... }: { config, pkgs, lib, inputs, extraHomeModule ? null, ... }:
{ {
nixpkgs.overlays = lib.mkMerge [ nixpkgs.overlays = lib.mkMerge [
@ -29,10 +29,9 @@
imports = [ imports = [
inputs.wired.homeManagerModules.default inputs.wired.homeManagerModules.default
./home.nix ./home.nix
extraHomeModule
]; ];
local.alacritty.fontSize = lib.mkIf (fontSize != null) fontSize;
home.stateVersion = config.system.stateVersion; home.stateVersion = config.system.stateVersion;
}; };
}; };

View file

@ -3,6 +3,7 @@
with lib; with lib;
let let
cfg = config.local.polybar;
inherit (config.services.polybar) package; inherit (config.services.polybar) package;
# TODO: create a theme # TODO: create a theme
@ -11,152 +12,156 @@ let
red = "#ff5555"; red = "#ff5555";
green = "#50fa7b"; green = "#50fa7b";
}; };
in in
{ {
systemd.user.services.polybar = { options.local.polybar = with lib; {
# Add additional /usr/bin to run custom scripts wifiDevice = mkOption {
Service.Environment = mkForce "PATH=${package}/bin:/run/current-system/sw/bin"; type = types.str;
example = "wlp11s0f3u2";
description = "Set your wifi device";
};
}; };
services.polybar = { config = {
enable = true; systemd.user.services.polybar = {
script = "MONITOR=$(xrandr | grep \"connected primary\" | awk '{print $1;}') polybar &"; # Add additional /usr/bin to run custom scripts
settings = Service.Environment = mkForce "PATH=${package}/bin:/run/current-system/sw/bin";
let };
mkWifi = interface: {
type = "internal/network";
interval = 3;
interface = {
text = interface;
type = "wireless";
};
label.connected = "%essid% %signal%";
format.connected = {
prefix = "| ";
suffix = "%";
};
};
padding = 1; services.polybar = {
in enable = true;
{ script = "MONITOR=$(xrandr | grep \"connected primary\" | awk '{print $1;}') polybar &";
"bar/main" = { settings =
monitor = "\${env:MONITOR:DisplayPort-1}"; let padding = 1; in
width = "100%"; {
height = "20px"; "bar/main" = {
font = [ monitor = "\${env:MONITOR:DisplayPort-1}";
"Fira Code:size=9:antialias=true" width = "100%";
"Fira Code:bold:size=9:antialias=true" height = "20px";
"FiraCode Nerd Font Mono:size=9:antialias=true" font = [
"FiraCode Nerd Font Mono:size=14:antialias=true" "Fira Code:size=9:antialias=true"
]; "Fira Code:bold:size=9:antialias=true"
radius = 0; "FiraCode Nerd Font Mono:size=9:antialias=true"
modules = { "FiraCode Nerd Font Mono:size=14:antialias=true"
left = "xmonad"; ];
center = "date wifi_home wifi_laptop"; radius = 0;
right = "exchangerate volume battery lang time"; modules = {
}; left = "xmonad";
}; center = "date wifi";
right = "exchangerate volume battery lang time";
"module/date" = { };
type = "internal/date";
interval = 10;
date = "%a %d %b %Y";
label = "%date%";
format = { inherit padding; };
};
"module/time" = {
type = "internal/date";
time = "%H:%M:%S";
label = {
text = "%time%";
font = 2;
foreground = colors.orange;
};
};
"module/lang" = {
type = "internal/xkeyboard";
format = {
inherit padding;
text = "<label-layout>";
};
label.layout.font = 2;
};
"module/volume" = {
type = "custom/script";
exec = "~/scripts/get_volume.sh";
interval = 1;
format = {
inherit padding;
prefix = "%{T4}%{T-} ";
};
};
"module/battery" = {
type = "internal/battery";
full-at = 99;
low-at = 10;
battery = "BAT0";
adapter = "AC0";
format.charging = {
inherit padding;
text = "%{T3}%{T-} <label-charging>";
foreground = colors.green;
}; };
format.discharging = { "module/date" = {
inherit padding; type = "internal/date";
text = "%{T3}<ramp-capacity>%{T-} <label-discharging>"; interval = 10;
foreground = colors.orange; date = "%a %d %b %Y";
label = "%date%";
format = { inherit padding; };
}; };
format.full = { "module/time" = {
inherit padding; type = "internal/date";
text = "%{T3}%{T-} <label-full>"; time = "%H:%M:%S";
foreground = colors.green; label = {
text = "%time%";
font = 2;
foreground = colors.orange;
};
}; };
format.low = { "module/lang" = {
inherit padding; type = "internal/xkeyboard";
text = "%{T3}%{T-} <label-low>"; format = {
foreground = colors.red; inherit padding;
text = "<label-layout>";
};
label.layout.font = 2;
}; };
# Only applies if <ramp-capacity> is used "module/volume" = {
ramp.capacity = [ "" "" "" "" "" ]; type = "custom/script";
}; exec = "~/scripts/get_volume.sh";
interval = 1;
"module/wifi_home" = mkWifi "wlp11s0f3u2"; format = {
"module/wifi_laptop" = mkWifi "wlp2s0"; inherit padding;
prefix = "%{T4}%{T-} ";
"module/xmonad" = mkIf config.xsession.windowManager.xmonad.enable { };
type = "custom/script";
exec = "${pkgs.xmonad-log}/bin/xmonad-log";
tail = true;
};
"module/exchangerate" = {
type = "custom/script";
exec = "~/scripts/exchangerate.sh";
interval = 60;
format = {
inherit padding;
prefix = "USD: ";
}; };
};
"global/wm" = { "module/battery" = {
margin = { type = "internal/battery";
bottom = 0; full-at = 99;
top = 0; low-at = 10;
battery = "BAT0";
adapter = "AC0";
format.charging = {
inherit padding;
text = "%{T3}%{T-} <label-charging>";
foreground = colors.green;
};
format.discharging = {
inherit padding;
text = "%{T3}<ramp-capacity>%{T-} <label-discharging>";
foreground = colors.orange;
};
format.full = {
inherit padding;
text = "%{T3}%{T-} <label-full>";
foreground = colors.green;
};
format.low = {
inherit padding;
text = "%{T3}%{T-} <label-low>";
foreground = colors.red;
};
# Only applies if <ramp-capacity> is used
ramp.capacity = [ "" "" "" "" "" ];
}; };
};
} "module/wifi" = {
; type = "internal/network";
interval = 3;
interface = {
type = "wireless";
text = cfg.wifiDevice;
};
label.connected = "%essid% %signal%";
format.connected = {
prefix = "| ";
suffix = "%";
};
};
"module/xmonad" = mkIf config.xsession.windowManager.xmonad.enable {
type = "custom/script";
exec = "${pkgs.xmonad-log}/bin/xmonad-log";
tail = true;
};
"module/exchangerate" = {
type = "custom/script";
exec = "~/scripts/exchangerate.sh";
interval = 60;
format = {
inherit padding;
prefix = "USD: ";
};
};
"global/wm" = {
margin = {
bottom = 0;
top = 0;
};
};
}
;
};
}; };
} }