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
, specialArgs ? { }
, extraModules ? [ ]
, extraHomeModule ? null
, nixpkgs ? inputs.nixpkgs
}:
nixpkgs.lib.nixosSystem {
inherit system;
specialArgs = { inherit inputs; } // specialArgs;
specialArgs = { inherit inputs extraHomeModule; } // specialArgs;
modules =
(with inputs; [

View file

@ -11,19 +11,24 @@ in
../modules/garbage-collector.nix
../users/jan
];
extraHomeModule = { ... }: {
local.polybar.wifiDevice = "wlp11s0f3u2";
};
};
asus-gl553vd = {
system = "x86_64-linux";
specialArgs = {
fontSize = 6.0;
};
extraModules = [
hardware.common-cpu-intel
../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 [
@ -29,10 +29,9 @@
imports = [
inputs.wired.homeManagerModules.default
./home.nix
extraHomeModule
];
local.alacritty.fontSize = lib.mkIf (fontSize != null) fontSize;
home.stateVersion = config.system.stateVersion;
};
};

View file

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