diff --git a/nix/configuration/configuration.nix b/nix/configuration/configuration.nix
index 1b44775..2c6a258 100644
--- a/nix/configuration/configuration.nix
+++ b/nix/configuration/configuration.nix
@@ -146,6 +146,22 @@
# })
# ];
+ nixpkgs.overlays = [
+ (final: prev: {
+ imagemagick = prev.imagemagick.overrideAttrs (old: rec {
+ # 7.1.2-6 seems to no longer exist, so use 7.1.2-7
+ version = "7.1.2-7";
+
+ src = final.fetchFromGitHub {
+ owner = "ImageMagick";
+ repo = "ImageMagick";
+ tag = version;
+ hash = "sha256-9ARCYftoXiilpJoj+Y+aLCEqLmhHFYSrHfgA5DQHbGo=";
+ };
+ });
+ })
+ ];
+
# This option defines the first version of NixOS you have installed on this particular machine,
# and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions.
#
diff --git a/nix/configuration/flake.lock b/nix/configuration/flake.lock
index 3788e19..e5bb4b8 100644
--- a/nix/configuration/flake.lock
+++ b/nix/configuration/flake.lock
@@ -22,11 +22,11 @@
]
},
"locked": {
- "lastModified": 1758287904,
- "narHash": "sha256-IGmaEf3Do8o5Cwp1kXBN1wQmZwQN3NLfq5t4nHtVtcU=",
+ "lastModified": 1760701190,
+ "narHash": "sha256-y7UhnWlER8r776JsySqsbTUh2Txf7K30smfHlqdaIQw=",
"owner": "nix-community",
"repo": "disko",
- "rev": "67ff9807dd148e704baadbd4fd783b54282ca627",
+ "rev": "3a9450b26e69dcb6f8de6e2b07b3fc1c288d85f5",
"type": "github"
},
"original": {
@@ -137,11 +137,11 @@
},
"nixpkgs": {
"locked": {
- "lastModified": 1760038930,
- "narHash": "sha256-Oncbh0UmHjSlxO7ErQDM3KM0A5/Znfofj2BSzlHLeVw=",
+ "lastModified": 1760524057,
+ "narHash": "sha256-EVAqOteLBFmd7pKkb0+FIUyzTF61VKi7YmvP1tw4nEw=",
"owner": "NixOS",
"repo": "nixpkgs",
- "rev": "0b4defa2584313f3b781240b29d61f6f9f7e0df3",
+ "rev": "544961dfcce86422ba200ed9a0b00dd4b1486ec5",
"type": "github"
},
"original": {
@@ -169,11 +169,11 @@
},
"nixpkgs-unoptimized": {
"locked": {
- "lastModified": 1760038930,
- "narHash": "sha256-Oncbh0UmHjSlxO7ErQDM3KM0A5/Znfofj2BSzlHLeVw=",
+ "lastModified": 1760524057,
+ "narHash": "sha256-EVAqOteLBFmd7pKkb0+FIUyzTF61VKi7YmvP1tw4nEw=",
"owner": "NixOS",
"repo": "nixpkgs",
- "rev": "0b4defa2584313f3b781240b29d61f6f9f7e0df3",
+ "rev": "544961dfcce86422ba200ed9a0b00dd4b1486ec5",
"type": "github"
},
"original": {
diff --git a/nix/configuration/hosts/quark/default.nix b/nix/configuration/hosts/quark/default.nix
index b6cdc9d..feebfaa 100644
--- a/nix/configuration/hosts/quark/default.nix
+++ b/nix/configuration/hosts/quark/default.nix
@@ -10,6 +10,7 @@
./distributed_build.nix
./hardware-configuration.nix
./power_management.nix
+ ./waybar.nix
];
config = {
diff --git a/nix/configuration/hosts/quark/waybar.nix b/nix/configuration/hosts/quark/waybar.nix
new file mode 100644
index 0000000..cdb98a3
--- /dev/null
+++ b/nix/configuration/hosts/quark/waybar.nix
@@ -0,0 +1,75 @@
+{
+ config,
+ lib,
+ pkgs,
+ ...
+}:
+{
+ imports = [ ];
+
+ config = {
+ me.waybar.config = lib.mkForce {
+ # "height": 10, # Waybar height (to be removed for auto height)
+ "modules-left" = [
+ "sway/workspaces"
+ "sway/mode"
+ ];
+ "modules-center" = [ "sway/window" ];
+ "modules-right" = [
+ "custom/night_mode"
+ # "custom/temperature" # /sys/class/thermal/thermal_zone* does not currently exist on quark
+ "custom/sound"
+ "custom/available_memory"
+ "idle_inhibitor"
+ "custom/clock"
+ "tray"
+ ];
+ "sway/workspaces" = {
+ "disable-scroll" = true;
+ };
+ "sway/mode" = {
+ "format" = "{}";
+ };
+ "sway/window" = {
+ "format" = "{title}";
+ };
+ "idle_inhibitor" = {
+ "format" = "{icon}";
+ "format-icons" = {
+ "activated" = "☕"; # ☕
+ "deactivated" = "💤"; # ☾☁⛾⛔⏾⌛⏳💤
+ };
+ };
+ "tray" = {
+ # "icon-size" = 21;
+ "spacing" = 10;
+ };
+ "custom/clock" = {
+ "exec" = "waybar_custom_clock";
+ "return-type" = "json";
+ "restart-interval" = 30;
+ };
+ "custom/available_memory" = {
+ "exec" = "waybar_custom_available_memory";
+ "return-type" = "json";
+ "restart-interval" = 30;
+ };
+ "custom/sound" = {
+ "exec" = "waybar_custom_sound";
+ "return-type" = "json";
+ "restart-interval" = 30;
+ };
+ # "custom/temperature" = {
+ # "exec" = "waybar_custom_temperature";
+ # "return-type" = "json";
+ # "restart-interval" = 30;
+ # };
+ "custom/night_mode" = {
+ "exec" = "waybar_night_mode";
+ "return-type" = "json";
+ "restart-interval" = 30;
+ "on-click" = "pkill -USR1 -f waybar_night_mode";
+ };
+ };
+ };
+}
diff --git a/nix/configuration/roles/waybar/default.nix b/nix/configuration/roles/waybar/default.nix
index 2cd5b08..705e0fe 100644
--- a/nix/configuration/roles/waybar/default.nix
+++ b/nix/configuration/roles/waybar/default.nix
@@ -6,6 +6,11 @@
}:
let
+ settings_format = pkgs.formats.json { };
+ waybar_config_json = settings_format.generate "config" config.me.waybar.config;
+ launch_waybar = pkgs.writeShellScript "launch_waybar" ''
+ exec waybar --config '${waybar_config_json}' --style '${./files/style.css}'
+ '';
waybar_sway_config = pkgs.writeTextFile {
name = "waybar.conf";
text = ''
@@ -17,7 +22,7 @@ let
position top
font pango:Cascadia Mono, FontAwesome 10
- swaybar_command waybar
+ swaybar_command ${launch_waybar}
colors {
statusline #ffffff
@@ -28,54 +33,39 @@ let
'';
};
- waybar_available_memory =
- (pkgs.writeScriptBin "waybar_custom_available_memory" (
+ patchScriptBin =
+ filename: contents:
+ ((pkgs.writeScriptBin filename contents).overrideAttrs (old: {
+ buildCommand = "${old.buildCommand}\n patchShebangs $out";
+ }));
+ waybar_available_memory = (
+ patchScriptBin "waybar_custom_available_memory" (
builtins.readFile ./files/waybar_scripts/waybar_available_memory_linux.bash
- )).overrideAttrs
- (old: {
- buildCommand = "${old.buildCommand}\n patchShebangs $out";
-
- });
- waybar_battery =
- (pkgs.writeScriptBin "waybar_custom_battery" (
+ )
+ );
+ waybar_battery = (
+ patchScriptBin "waybar_custom_battery" (
builtins.readFile ./files/waybar_scripts/waybar_battery_linux.bash
- )).overrideAttrs
- (old: {
- buildCommand = "${old.buildCommand}\n patchShebangs $out";
-
- });
- waybar_clock =
- (pkgs.writeScriptBin "waybar_custom_clock" (
+ )
+ );
+ waybar_clock = (
+ patchScriptBin "waybar_custom_clock" (
builtins.readFile ./files/waybar_scripts/waybar_custom_clock.py
- )).overrideAttrs
- (old: {
- buildCommand = "${old.buildCommand}\n patchShebangs $out";
-
- });
- waybar_night_mode =
- (pkgs.writeScriptBin "waybar_night_mode" (
- builtins.readFile ./files/waybar_scripts/waybar_night_mode.bash
- )).overrideAttrs
- (old: {
- buildCommand = "${old.buildCommand}\n patchShebangs $out";
-
- });
- waybar_sound =
- (pkgs.writeScriptBin "waybar_custom_sound" (
+ )
+ );
+ waybar_night_mode = (
+ patchScriptBin "waybar_night_mode" (builtins.readFile ./files/waybar_scripts/waybar_night_mode.bash)
+ );
+ waybar_sound = (
+ patchScriptBin "waybar_custom_sound" (
builtins.readFile ./files/waybar_scripts/waybar_sound_linux.bash
- )).overrideAttrs
- (old: {
- buildCommand = "${old.buildCommand}\n patchShebangs $out";
-
- });
- waybar_temperature =
- (pkgs.writeScriptBin "waybar_custom_temperature" (
+ )
+ );
+ waybar_temperature = (
+ patchScriptBin "waybar_custom_temperature" (
builtins.readFile ./files/waybar_scripts/waybar_temperature_linux.bash
- )).overrideAttrs
- (old: {
- buildCommand = "${old.buildCommand}\n patchShebangs $out";
-
- });
+ )
+ );
in
{
imports = [ ];
@@ -87,22 +77,87 @@ in
example = true;
description = "Whether we want to install waybar.";
};
+
+ waybar.config = lib.mkOption rec {
+ apply = lib.recursiveUpdate default;
+ inherit (settings_format) type;
+ default = {
+ # "height": 10, # Waybar height (to be removed for auto height)
+ "modules-left" = [
+ "sway/workspaces"
+ "sway/mode"
+ ];
+ "modules-center" = [ "sway/window" ];
+ "modules-right" = [
+ "custom/night_mode"
+ "custom/temperature"
+ "custom/sound"
+ "custom/available_memory"
+ "custom/battery"
+ "idle_inhibitor"
+ "custom/clock"
+ "tray"
+ ];
+ "sway/workspaces" = {
+ "disable-scroll" = true;
+ };
+ "sway/mode" = {
+ "format" = "{}";
+ };
+ "sway/window" = {
+ "format" = "{title}";
+ };
+ "idle_inhibitor" = {
+ "format" = "{icon}";
+ "format-icons" = {
+ "activated" = "☕"; # ☕
+ "deactivated" = "💤"; # ☾☁⛾⛔⏾⌛⏳💤
+ };
+ };
+ "tray" = {
+ # "icon-size" = 21;
+ "spacing" = 10;
+ };
+ "custom/clock" = {
+ "exec" = "waybar_custom_clock";
+ "return-type" = "json";
+ "restart-interval" = 30;
+ };
+ "custom/battery" = {
+ "exec" = "waybar_custom_battery";
+ "return-type" = "json";
+ "restart-interval" = 30;
+ };
+ "custom/available_memory" = {
+ "exec" = "waybar_custom_available_memory";
+ "return-type" = "json";
+ "restart-interval" = 30;
+ };
+ "custom/sound" = {
+ "exec" = "waybar_custom_sound";
+ "return-type" = "json";
+ "restart-interval" = 30;
+ };
+ "custom/temperature" = {
+ "exec" = "waybar_custom_temperature";
+ "return-type" = "json";
+ "restart-interval" = 30;
+ };
+ "custom/night_mode" = {
+ "exec" = "waybar_night_mode";
+ "return-type" = "json";
+ "restart-interval" = 30;
+ "on-click" = "pkill -USR1 -f waybar_night_mode";
+ };
+ };
+ example = null;
+ description = "Waybar's config in nix form.";
+ };
};
config = lib.mkIf (config.me.waybar.enable && config.me.graphical) {
environment.systemPackages = with pkgs; [
waybar
- waybar_available_memory
- waybar_battery
- waybar_clock
- waybar_night_mode
- waybar_sound
- waybar_temperature
- python3 # for clock TODO python should not be in the system packages, maybe switch to a venv? ref https://nixos.wiki/wiki/Python
- bc # for temperature and sound
- jq # for memory, battery, sound, night mode, and temperature
- upower # for battery
- wlsunset # for night mode
];
me.swayIncludes = [
@@ -111,13 +166,31 @@ in
services.upower.enable = true; # for battery
- me.install.user.talexander.file = {
- ".config/waybar/config" = {
- source = ./files/waybar_config.json;
- };
- ".config/waybar/style.css" = {
- source = ./files/style.css;
- };
- };
+ nixpkgs.overlays = [
+ (final: prev: {
+ waybar = pkgs.symlinkJoin {
+ name = prev.waybar.name;
+ paths = [ prev.waybar ];
+ buildInputs = [ pkgs.makeWrapper ];
+ postBuild = ''
+ wrapProgram $out/bin/waybar --prefix PATH : ${
+ lib.makeBinPath [
+ waybar_available_memory
+ waybar_battery
+ waybar_clock
+ waybar_night_mode
+ waybar_sound
+ waybar_temperature
+ final.python3 # for clock TODO python should not be in the system packages, maybe switch to a venv? ref https://nixos.wiki/wiki/Python
+ final.bc # for temperature and sound
+ final.jq # for memory, battery, sound, night mode, and temperature
+ final.upower # for battery
+ final.wlsunset # for night mode
+ ]
+ }
+ '';
+ };
+ })
+ ];
};
}
diff --git a/nix/configuration/util/install_files/default.nix b/nix/configuration/util/install_files/default.nix
index adc937d..171e038 100644
--- a/nix/configuration/util/install_files/default.nix
+++ b/nix/configuration/util/install_files/default.nix
@@ -180,6 +180,7 @@ in
options.me.install = {
user = lib.mkOption {
+ default = { };
type = lib.types.attrsOf (
lib.types.submodule (
{ name, config, ... }: