Specify waybar config in nix.
This is to facilitate having different waybar configs for each machine.
This commit is contained in:
parent
7c82036bd7
commit
65593765df
@ -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,
|
# 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.
|
# and is used to maintain compatibility with application data (e.g. databases) created on older NixOS versions.
|
||||||
#
|
#
|
||||||
|
|||||||
18
nix/configuration/flake.lock
generated
18
nix/configuration/flake.lock
generated
@ -22,11 +22,11 @@
|
|||||||
]
|
]
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1758287904,
|
"lastModified": 1760701190,
|
||||||
"narHash": "sha256-IGmaEf3Do8o5Cwp1kXBN1wQmZwQN3NLfq5t4nHtVtcU=",
|
"narHash": "sha256-y7UhnWlER8r776JsySqsbTUh2Txf7K30smfHlqdaIQw=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "disko",
|
"repo": "disko",
|
||||||
"rev": "67ff9807dd148e704baadbd4fd783b54282ca627",
|
"rev": "3a9450b26e69dcb6f8de6e2b07b3fc1c288d85f5",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -137,11 +137,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1760038930,
|
"lastModified": 1760524057,
|
||||||
"narHash": "sha256-Oncbh0UmHjSlxO7ErQDM3KM0A5/Znfofj2BSzlHLeVw=",
|
"narHash": "sha256-EVAqOteLBFmd7pKkb0+FIUyzTF61VKi7YmvP1tw4nEw=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "0b4defa2584313f3b781240b29d61f6f9f7e0df3",
|
"rev": "544961dfcce86422ba200ed9a0b00dd4b1486ec5",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
@ -169,11 +169,11 @@
|
|||||||
},
|
},
|
||||||
"nixpkgs-unoptimized": {
|
"nixpkgs-unoptimized": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1760038930,
|
"lastModified": 1760524057,
|
||||||
"narHash": "sha256-Oncbh0UmHjSlxO7ErQDM3KM0A5/Znfofj2BSzlHLeVw=",
|
"narHash": "sha256-EVAqOteLBFmd7pKkb0+FIUyzTF61VKi7YmvP1tw4nEw=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "0b4defa2584313f3b781240b29d61f6f9f7e0df3",
|
"rev": "544961dfcce86422ba200ed9a0b00dd4b1486ec5",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
@ -10,6 +10,7 @@
|
|||||||
./distributed_build.nix
|
./distributed_build.nix
|
||||||
./hardware-configuration.nix
|
./hardware-configuration.nix
|
||||||
./power_management.nix
|
./power_management.nix
|
||||||
|
./waybar.nix
|
||||||
];
|
];
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
|
|||||||
75
nix/configuration/hosts/quark/waybar.nix
Normal file
75
nix/configuration/hosts/quark/waybar.nix
Normal file
@ -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" = "<span style=\"italic\">{}</span>";
|
||||||
|
};
|
||||||
|
"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";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@ -6,6 +6,11 @@
|
|||||||
}:
|
}:
|
||||||
|
|
||||||
let
|
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 {
|
waybar_sway_config = pkgs.writeTextFile {
|
||||||
name = "waybar.conf";
|
name = "waybar.conf";
|
||||||
text = ''
|
text = ''
|
||||||
@ -17,7 +22,7 @@ let
|
|||||||
position top
|
position top
|
||||||
|
|
||||||
font pango:Cascadia Mono, FontAwesome 10
|
font pango:Cascadia Mono, FontAwesome 10
|
||||||
swaybar_command waybar
|
swaybar_command ${launch_waybar}
|
||||||
|
|
||||||
colors {
|
colors {
|
||||||
statusline #ffffff
|
statusline #ffffff
|
||||||
@ -28,54 +33,39 @@ let
|
|||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
waybar_available_memory =
|
patchScriptBin =
|
||||||
(pkgs.writeScriptBin "waybar_custom_available_memory" (
|
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
|
builtins.readFile ./files/waybar_scripts/waybar_available_memory_linux.bash
|
||||||
)).overrideAttrs
|
)
|
||||||
(old: {
|
);
|
||||||
buildCommand = "${old.buildCommand}\n patchShebangs $out";
|
waybar_battery = (
|
||||||
|
patchScriptBin "waybar_custom_battery" (
|
||||||
});
|
|
||||||
waybar_battery =
|
|
||||||
(pkgs.writeScriptBin "waybar_custom_battery" (
|
|
||||||
builtins.readFile ./files/waybar_scripts/waybar_battery_linux.bash
|
builtins.readFile ./files/waybar_scripts/waybar_battery_linux.bash
|
||||||
)).overrideAttrs
|
)
|
||||||
(old: {
|
);
|
||||||
buildCommand = "${old.buildCommand}\n patchShebangs $out";
|
waybar_clock = (
|
||||||
|
patchScriptBin "waybar_custom_clock" (
|
||||||
});
|
|
||||||
waybar_clock =
|
|
||||||
(pkgs.writeScriptBin "waybar_custom_clock" (
|
|
||||||
builtins.readFile ./files/waybar_scripts/waybar_custom_clock.py
|
builtins.readFile ./files/waybar_scripts/waybar_custom_clock.py
|
||||||
)).overrideAttrs
|
)
|
||||||
(old: {
|
);
|
||||||
buildCommand = "${old.buildCommand}\n patchShebangs $out";
|
waybar_night_mode = (
|
||||||
|
patchScriptBin "waybar_night_mode" (builtins.readFile ./files/waybar_scripts/waybar_night_mode.bash)
|
||||||
});
|
);
|
||||||
waybar_night_mode =
|
waybar_sound = (
|
||||||
(pkgs.writeScriptBin "waybar_night_mode" (
|
patchScriptBin "waybar_custom_sound" (
|
||||||
builtins.readFile ./files/waybar_scripts/waybar_night_mode.bash
|
|
||||||
)).overrideAttrs
|
|
||||||
(old: {
|
|
||||||
buildCommand = "${old.buildCommand}\n patchShebangs $out";
|
|
||||||
|
|
||||||
});
|
|
||||||
waybar_sound =
|
|
||||||
(pkgs.writeScriptBin "waybar_custom_sound" (
|
|
||||||
builtins.readFile ./files/waybar_scripts/waybar_sound_linux.bash
|
builtins.readFile ./files/waybar_scripts/waybar_sound_linux.bash
|
||||||
)).overrideAttrs
|
)
|
||||||
(old: {
|
);
|
||||||
buildCommand = "${old.buildCommand}\n patchShebangs $out";
|
waybar_temperature = (
|
||||||
|
patchScriptBin "waybar_custom_temperature" (
|
||||||
});
|
|
||||||
waybar_temperature =
|
|
||||||
(pkgs.writeScriptBin "waybar_custom_temperature" (
|
|
||||||
builtins.readFile ./files/waybar_scripts/waybar_temperature_linux.bash
|
builtins.readFile ./files/waybar_scripts/waybar_temperature_linux.bash
|
||||||
)).overrideAttrs
|
)
|
||||||
(old: {
|
);
|
||||||
buildCommand = "${old.buildCommand}\n patchShebangs $out";
|
|
||||||
|
|
||||||
});
|
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
imports = [ ];
|
imports = [ ];
|
||||||
@ -87,22 +77,87 @@ in
|
|||||||
example = true;
|
example = true;
|
||||||
description = "Whether we want to install waybar.";
|
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" = "<span style=\"italic\">{}</span>";
|
||||||
|
};
|
||||||
|
"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) {
|
config = lib.mkIf (config.me.waybar.enable && config.me.graphical) {
|
||||||
environment.systemPackages = with pkgs; [
|
environment.systemPackages = with pkgs; [
|
||||||
waybar
|
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 = [
|
me.swayIncludes = [
|
||||||
@ -111,13 +166,31 @@ in
|
|||||||
|
|
||||||
services.upower.enable = true; # for battery
|
services.upower.enable = true; # for battery
|
||||||
|
|
||||||
me.install.user.talexander.file = {
|
nixpkgs.overlays = [
|
||||||
".config/waybar/config" = {
|
(final: prev: {
|
||||||
source = ./files/waybar_config.json;
|
waybar = pkgs.symlinkJoin {
|
||||||
};
|
name = prev.waybar.name;
|
||||||
".config/waybar/style.css" = {
|
paths = [ prev.waybar ];
|
||||||
source = ./files/style.css;
|
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
|
||||||
|
]
|
||||||
|
}
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
})
|
||||||
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@ -180,6 +180,7 @@ in
|
|||||||
|
|
||||||
options.me.install = {
|
options.me.install = {
|
||||||
user = lib.mkOption {
|
user = lib.mkOption {
|
||||||
|
default = { };
|
||||||
type = lib.types.attrsOf (
|
type = lib.types.attrsOf (
|
||||||
lib.types.submodule (
|
lib.types.submodule (
|
||||||
{ name, config, ... }:
|
{ name, config, ... }:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user