nixos/modules/home/ags/default.nix

95 lines
2.1 KiB
Nix

{
config,
lib,
pkgs,
...
}:
with lib;
let
cfg = config.modules.ags;
hyprlandCfg = config.modules.hyprland;
colors = config.lib.stylix.colors.withHashtag;
base16Names = [
"base00"
"base01"
"base02"
"base03"
"base04"
"base05"
"base06"
"base07"
"base08"
"base09"
"base0A"
"base0B"
"base0C"
"base0D"
"base0E"
"base0F"
];
palette = pkgs.writeText "palette.scss" (
concatStringsSep "\n" (
map (name: "$" + name + ": " + colors.${name} + ";") base16Names
++ [
''$font-family: "${config.stylix.fonts.sansSerif.name}";''
"$font-size: ${toString config.stylix.fonts.sizes.desktop}px;"
]
)
);
notifConfig = pkgs.writeText "notif-config.ts" ''
export const MAX_TIMEOUT = ${toString cfg.timeout};
'';
astalDeps =
with pkgs.astal;
[
astal3
io
hyprland
network
battery
wireplumber
notifd
]
++ [ pkgs.networkmanager ];
ags-bar = pkgs.ags.bundle {
pname = "ags-bar";
version = "0.1.0";
src = ./app;
entry = "app.ts";
dependencies = astalDeps;
postUnpack = ''
cp ${palette} "$sourceRoot/palette.scss"
cp ${notifConfig} "$sourceRoot/notif-config.ts"
'';
};
in
{
config = mkIf cfg.enable {
home.packages = [
ags-bar
pkgs.ags
pkgs.dart-sass
pkgs.nixos-icons
];
# clock face with hands at 12 and 3; adwaita has no such icon.
# fill-only paths: gtk symbolic recoloring turns stroke shapes into solids
xdg.dataFile."icons/hicolor/scalable/actions/clock-hands-symbolic.svg".text = ''
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16">
<path fill="currentColor" fill-rule="evenodd" d="M8 1.5A6.5 6.5 0 1 0 8 14.5A6.5 6.5 0 1 0 8 1.5ZM8 3A5 5 0 1 0 8 13A5 5 0 1 0 8 3Z"/>
<rect x="7.4" y="3.8" width="1.2" height="4.8" rx="0.6" fill="currentColor"/>
<rect x="7.4" y="7.4" width="3.4" height="1.2" rx="0.6" fill="currentColor"/>
</svg>
'';
wayland.windowManager.hyprland = mkIf hyprlandCfg.enable {
settings.exec-once = [ "ags-bar" ];
};
};
}