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,9 +12,17 @@ let
red = "#ff5555"; red = "#ff5555";
green = "#50fa7b"; green = "#50fa7b";
}; };
in in
{ {
options.local.polybar = with lib; {
wifiDevice = mkOption {
type = types.str;
example = "wlp11s0f3u2";
description = "Set your wifi device";
};
};
config = {
systemd.user.services.polybar = { systemd.user.services.polybar = {
# Add additional /usr/bin to run custom scripts # Add additional /usr/bin to run custom scripts
Service.Environment = mkForce "PATH=${package}/bin:/run/current-system/sw/bin"; Service.Environment = mkForce "PATH=${package}/bin:/run/current-system/sw/bin";
@ -23,23 +32,7 @@ in
enable = true; enable = true;
script = "MONITOR=$(xrandr | grep \"connected primary\" | awk '{print $1;}') polybar &"; script = "MONITOR=$(xrandr | grep \"connected primary\" | awk '{print $1;}') polybar &";
settings = settings =
let let padding = 1; in
mkWifi = interface: {
type = "internal/network";
interval = 3;
interface = {
text = interface;
type = "wireless";
};
label.connected = "%essid% %signal%";
format.connected = {
prefix = "| ";
suffix = "%";
};
};
padding = 1;
in
{ {
"bar/main" = { "bar/main" = {
monitor = "\${env:MONITOR:DisplayPort-1}"; monitor = "\${env:MONITOR:DisplayPort-1}";
@ -54,7 +47,7 @@ in
radius = 0; radius = 0;
modules = { modules = {
left = "xmonad"; left = "xmonad";
center = "date wifi_home wifi_laptop"; center = "date wifi";
right = "exchangerate volume battery lang time"; right = "exchangerate volume battery lang time";
}; };
}; };
@ -131,8 +124,19 @@ in
ramp.capacity = [ "" "" "" "" "" ]; ramp.capacity = [ "" "" "" "" "" ];
}; };
"module/wifi_home" = mkWifi "wlp11s0f3u2"; "module/wifi" = {
"module/wifi_laptop" = mkWifi "wlp2s0"; 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 { "module/xmonad" = mkIf config.xsession.windowManager.xmonad.enable {
type = "custom/script"; type = "custom/script";
@ -159,4 +163,5 @@ in
} }
; ;
}; };
};
} }