diff --git a/flake.nix b/flake.nix index 164c241..96ff644 100644 --- a/flake.nix +++ b/flake.nix @@ -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; [ diff --git a/machines/default.nix b/machines/default.nix index b5e95fd..6714a1d 100644 --- a/machines/default.nix +++ b/machines/default.nix @@ -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; + }; }; } diff --git a/users/jan/default.nix b/users/jan/default.nix index e06f4f3..8ecdc7d 100644 --- a/users/jan/default.nix +++ b/users/jan/default.nix @@ -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; }; }; diff --git a/users/modules/window_manager/polybar.nix b/users/modules/window_manager/polybar.nix index 4f7713b..79013ad 100644 --- a/users/modules/window_manager/polybar.nix +++ b/users/modules/window_manager/polybar.nix @@ -3,6 +3,7 @@ with lib; let + cfg = config.local.polybar; inherit (config.services.polybar) package; # TODO: create a theme @@ -11,152 +12,156 @@ let red = "#ff5555"; green = "#50fa7b"; }; - in { - systemd.user.services.polybar = { - # Add additional /usr/bin to run custom scripts - Service.Environment = mkForce "PATH=${package}/bin:/run/current-system/sw/bin"; + options.local.polybar = with lib; { + wifiDevice = mkOption { + type = types.str; + example = "wlp11s0f3u2"; + description = "Set your wifi device"; + }; }; - services.polybar = { - 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 = "%"; - }; - }; + config = { + systemd.user.services.polybar = { + # Add additional /usr/bin to run custom scripts + Service.Environment = mkForce "PATH=${package}/bin:/run/current-system/sw/bin"; + }; - padding = 1; - in - { - "bar/main" = { - monitor = "\${env:MONITOR:DisplayPort-1}"; - width = "100%"; - height = "20px"; - font = [ - "Fira Code:size=9:antialias=true" - "Fira Code:bold:size=9:antialias=true" - "FiraCode Nerd Font Mono:size=9:antialias=true" - "FiraCode Nerd Font Mono:size=14:antialias=true" - ]; - radius = 0; - modules = { - left = "xmonad"; - center = "date wifi_home wifi_laptop"; - 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.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-} "; - foreground = colors.green; + services.polybar = { + enable = true; + script = "MONITOR=$(xrandr | grep \"connected primary\" | awk '{print $1;}') polybar &"; + settings = + let padding = 1; in + { + "bar/main" = { + monitor = "\${env:MONITOR:DisplayPort-1}"; + width = "100%"; + height = "20px"; + font = [ + "Fira Code:size=9:antialias=true" + "Fira Code:bold:size=9:antialias=true" + "FiraCode Nerd Font Mono:size=9:antialias=true" + "FiraCode Nerd Font Mono:size=14:antialias=true" + ]; + radius = 0; + modules = { + left = "xmonad"; + center = "date wifi"; + right = "exchangerate volume battery lang time"; + }; }; - format.discharging = { - inherit padding; - text = "%{T3}%{T-} "; - foreground = colors.orange; + "module/date" = { + type = "internal/date"; + interval = 10; + date = "%a %d %b %Y"; + label = "%date%"; + format = { inherit padding; }; }; - format.full = { - inherit padding; - text = "%{T3}%{T-} "; - foreground = colors.green; + "module/time" = { + type = "internal/date"; + time = "%H:%M:%S"; + label = { + text = "%time%"; + font = 2; + foreground = colors.orange; + }; }; - format.low = { - inherit padding; - text = "%{T3}%{T-} "; - foreground = colors.red; + "module/lang" = { + type = "internal/xkeyboard"; + format = { + inherit padding; + text = ""; + }; + label.layout.font = 2; }; - # Only applies if is used - ramp.capacity = [ "" "" "" "" "" ]; - }; - - "module/wifi_home" = mkWifi "wlp11s0f3u2"; - "module/wifi_laptop" = mkWifi "wlp2s0"; - - "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: "; + "module/volume" = { + type = "custom/script"; + exec = "~/scripts/get_volume.sh"; + interval = 1; + format = { + inherit padding; + prefix = "%{T4}%{T-} "; + }; }; - }; - "global/wm" = { - margin = { - bottom = 0; - top = 0; + "module/battery" = { + type = "internal/battery"; + full-at = 99; + low-at = 10; + battery = "BAT0"; + adapter = "AC0"; + + format.charging = { + inherit padding; + text = "%{T3}%{T-} "; + foreground = colors.green; + }; + + format.discharging = { + inherit padding; + text = "%{T3}%{T-} "; + foreground = colors.orange; + }; + + format.full = { + inherit padding; + text = "%{T3}%{T-} "; + foreground = colors.green; + }; + + format.low = { + inherit padding; + text = "%{T3}%{T-} "; + foreground = colors.red; + }; + + # Only applies if 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; + }; + }; + } + ; + }; }; }