From 142a45065b83b69ea103b28233bae76bdf775300 Mon Sep 17 00:00:00 2001 From: Arpit Chakladar Date: Sun, 30 Aug 2026 01:54:41 +0530 Subject: desktop: added eww bar launching service, moved scss config to default --- modules/desktop/eww/bar.nix | 122 ++++++++++++++++++++++++++++++++++++++++ modules/desktop/eww/default.nix | 47 +++++++++++++++- modules/desktop/eww/scss.nix | 28 --------- modules/desktop/eww/yuck.nix | 122 ---------------------------------------- 4 files changed, 167 insertions(+), 152 deletions(-) create mode 100644 modules/desktop/eww/bar.nix delete mode 100644 modules/desktop/eww/scss.nix delete mode 100644 modules/desktop/eww/yuck.nix (limited to 'modules/desktop') diff --git a/modules/desktop/eww/bar.nix b/modules/desktop/eww/bar.nix new file mode 100644 index 0000000..4f6c158 --- /dev/null +++ b/modules/desktop/eww/bar.nix @@ -0,0 +1,122 @@ +{ + config, + lib, + pkgs, + ... +}: +{ + config = lib.mkIf config.desktop.enable { + programs.eww.yuckConfig = + let + mkLuaScript = + { + name, + path, + description ? "", + lua ? pkgs.luajit, + luaPackages ? (_: [ ]), + deps ? [ ], + gobjectIntrospection ? false, + }: + let + luaEnv = lua.withPackages luaPackages; + pathPrefix = lib.concatStringsSep ":" ([ "${luaEnv}/bin" ] ++ map (p: "${lib.getBin p}/bin") deps); + in + pkgs.stdenv.mkDerivation { + pname = name; + version = "0.1.0"; + src = path; + dontUnpack = true; + meta = lib.optionalAttrs (description != "") { inherit description; } // { + mainProgram = name; + }; + + nativeBuildInputs = + lib.optionals gobjectIntrospection [ + pkgs.wrapGAppsHook3 + pkgs.gobject-introspection + ] + ++ lib.optional (!gobjectIntrospection) pkgs.makeWrapper; + buildInputs = lib.optionals gobjectIntrospection [ pkgs.gtk3 ]; + + installPhase = '' + mkdir -p $out/bin + install -m755 $src $out/bin/${name} + patchShebangs $out/bin/${name} + ''; + + # wrapGAppsHook3 wraps every executable in $out/bin automatically, + # setting GI_TYPELIB_PATH etc. from buildInputs' closure. With + # gobjectIntrospection = false a plain wrapProgram only extends PATH. + preFixup = + if gobjectIntrospection then + '' + gappsWrapperArgs+=(--prefix PATH : "${pathPrefix}") + '' + else + '' + wrapProgram $out/bin/${name} --prefix PATH : "${pathPrefix}" + ''; + }; + + system-stats = mkLuaScript { + name = "eww-system-stats"; + path = ./system-stats.lua; + description = "Emit {cpu, ram, net} as JSON."; + luaPackages = ( + ps: [ + ps.lua-cjson + ps.luaposix + ] + ); + deps = [ + pkgs.iw + pkgs.iproute2 + pkgs.pamixer + pkgs.inotify-tools + pkgs.dmidecode + ]; + }; + + niri-status = mkLuaScript { + name = "niri-status"; + path = ./niri-status.lua; + description = "Emit workspace and active window information list."; + luaPackages = ( + ps: [ + ps.lgi + ps.lua-cjson + ] + ); + deps = [ config.desktop.niri.package ]; + gobjectIntrospection = true; + }; + in + builtins.replaceStrings + [ + "@@niri-status-script@@" + "@@system-stats-script@@" + "@@icon-offline@@" + "@@icon-wifi@@" + "@@icon-ethernet@@" + "@@icon-proxy@@" + "@@icon-cpu@@" + "@@icon-ram@@" + "@@icon-audio@@" + "@@icon-calendar@@" + ] + [ + (lib.getExe niri-status) + (lib.getExe system-stats) + (toString ../../../assets/icons/bar/offline.svg) + (toString ../../../assets/icons/bar/wifi.svg) + (toString ../../../assets/icons/bar/ethernet.svg) + (toString ../../../assets/icons/bar/proxy.svg) + (toString ../../../assets/icons/bar/cpu.svg) + (toString ../../../assets/icons/bar/ram.svg) + (toString ../../../assets/icons/bar/audio.svg) + (toString ../../../assets/icons/bar/calendar.svg) + ] + (builtins.readFile ./bar.yuck); + }; +} diff --git a/modules/desktop/eww/default.nix b/modules/desktop/eww/default.nix index e22f8c6..fad0cc4 100644 --- a/modules/desktop/eww/default.nix +++ b/modules/desktop/eww/default.nix @@ -5,7 +5,7 @@ }: { imports = [ - ./yuck.nix + ./bar.nix ]; options.desktop.eww = { @@ -21,7 +21,50 @@ programs.eww = { enable = true; systemd.enable = true; - scssConfig = builtins.readFile (import ./scss.nix { inherit config; }); + scssConfig = + let + baseSize = config.fonts.size; + in + builtins.readFile ( + config.scheme { + template = + builtins.replaceStrings + [ + "@@font-family@@" + "@@font-size@@" + "@@font-size-icon@@" + "@@font-size-label@@" + "@@font-size-small@@" + "@@font-size-idx@@" + ] + [ + config.fonts.normal + (toString baseSize) + (toString (baseSize + 6)) + (toString (baseSize - 2)) + (toString (baseSize - 6)) + (toString (baseSize - 4)) + ] + (builtins.readFile ./eww.mustache.scss); + } + ); + }; + + systemd.user.services.eww-bar = { + Unit = { + Description = "Open Eww Bar"; + After = [ "eww.service" ]; + Requires = [ "eww.service" ]; + }; + Service = { + Type = "oneshot"; + RemainAfterExit = true; + ExecStart = "${lib.getExe config.desktop.eww.package} open bar"; + ExecStop = "${lib.getExe config.desktop.eww.package} close bar"; + }; + Install = { + WantedBy = [ config.programs.eww.systemd.target ]; + }; }; }; } diff --git a/modules/desktop/eww/scss.nix b/modules/desktop/eww/scss.nix deleted file mode 100644 index f625199..0000000 --- a/modules/desktop/eww/scss.nix +++ /dev/null @@ -1,28 +0,0 @@ -{ - config, - ... -}: -let - baseSize = config.fonts.size; -in -config.scheme { - template = - builtins.replaceStrings - [ - "@@font-family@@" - "@@font-size@@" - "@@font-size-icon@@" - "@@font-size-label@@" - "@@font-size-small@@" - "@@font-size-idx@@" - ] - [ - config.fonts.normal - (toString baseSize) - (toString (baseSize + 6)) - (toString (baseSize - 2)) - (toString (baseSize - 6)) - (toString (baseSize - 4)) - ] - (builtins.readFile ./eww.mustache.scss); -} diff --git a/modules/desktop/eww/yuck.nix b/modules/desktop/eww/yuck.nix deleted file mode 100644 index 4f6c158..0000000 --- a/modules/desktop/eww/yuck.nix +++ /dev/null @@ -1,122 +0,0 @@ -{ - config, - lib, - pkgs, - ... -}: -{ - config = lib.mkIf config.desktop.enable { - programs.eww.yuckConfig = - let - mkLuaScript = - { - name, - path, - description ? "", - lua ? pkgs.luajit, - luaPackages ? (_: [ ]), - deps ? [ ], - gobjectIntrospection ? false, - }: - let - luaEnv = lua.withPackages luaPackages; - pathPrefix = lib.concatStringsSep ":" ([ "${luaEnv}/bin" ] ++ map (p: "${lib.getBin p}/bin") deps); - in - pkgs.stdenv.mkDerivation { - pname = name; - version = "0.1.0"; - src = path; - dontUnpack = true; - meta = lib.optionalAttrs (description != "") { inherit description; } // { - mainProgram = name; - }; - - nativeBuildInputs = - lib.optionals gobjectIntrospection [ - pkgs.wrapGAppsHook3 - pkgs.gobject-introspection - ] - ++ lib.optional (!gobjectIntrospection) pkgs.makeWrapper; - buildInputs = lib.optionals gobjectIntrospection [ pkgs.gtk3 ]; - - installPhase = '' - mkdir -p $out/bin - install -m755 $src $out/bin/${name} - patchShebangs $out/bin/${name} - ''; - - # wrapGAppsHook3 wraps every executable in $out/bin automatically, - # setting GI_TYPELIB_PATH etc. from buildInputs' closure. With - # gobjectIntrospection = false a plain wrapProgram only extends PATH. - preFixup = - if gobjectIntrospection then - '' - gappsWrapperArgs+=(--prefix PATH : "${pathPrefix}") - '' - else - '' - wrapProgram $out/bin/${name} --prefix PATH : "${pathPrefix}" - ''; - }; - - system-stats = mkLuaScript { - name = "eww-system-stats"; - path = ./system-stats.lua; - description = "Emit {cpu, ram, net} as JSON."; - luaPackages = ( - ps: [ - ps.lua-cjson - ps.luaposix - ] - ); - deps = [ - pkgs.iw - pkgs.iproute2 - pkgs.pamixer - pkgs.inotify-tools - pkgs.dmidecode - ]; - }; - - niri-status = mkLuaScript { - name = "niri-status"; - path = ./niri-status.lua; - description = "Emit workspace and active window information list."; - luaPackages = ( - ps: [ - ps.lgi - ps.lua-cjson - ] - ); - deps = [ config.desktop.niri.package ]; - gobjectIntrospection = true; - }; - in - builtins.replaceStrings - [ - "@@niri-status-script@@" - "@@system-stats-script@@" - "@@icon-offline@@" - "@@icon-wifi@@" - "@@icon-ethernet@@" - "@@icon-proxy@@" - "@@icon-cpu@@" - "@@icon-ram@@" - "@@icon-audio@@" - "@@icon-calendar@@" - ] - [ - (lib.getExe niri-status) - (lib.getExe system-stats) - (toString ../../../assets/icons/bar/offline.svg) - (toString ../../../assets/icons/bar/wifi.svg) - (toString ../../../assets/icons/bar/ethernet.svg) - (toString ../../../assets/icons/bar/proxy.svg) - (toString ../../../assets/icons/bar/cpu.svg) - (toString ../../../assets/icons/bar/ram.svg) - (toString ../../../assets/icons/bar/audio.svg) - (toString ../../../assets/icons/bar/calendar.svg) - ] - (builtins.readFile ./bar.yuck); - }; -} -- cgit v1.2.3