All my system configs and packages in one repo

leah/waybar: update, add GPU usage monitoring for intel GPUs

pluie.me 0a329f7c 3d4f75ee

verified
+307 -279
-1
modules/hjem-ext/default.nix
··· 1 1 { 2 2 imports = [ 3 3 ./programs/direnv.nix 4 - ./programs/git.nix 5 4 ./programs/hyfetch.nix 6 5 ./programs/jujutsu.nix 7 6 ./programs/moar.nix
-30
modules/hjem-ext/programs/git.nix
··· 1 - { 2 - config, 3 - pkgs, 4 - lib, 5 - ... 6 - }: 7 - let 8 - cfg = config.ext.programs.git; 9 - format = pkgs.formats.gitIni { }; 10 - in 11 - { 12 - options.ext.programs.git = { 13 - enable = lib.mkEnableOption "Git"; 14 - package = lib.mkPackageOption pkgs "git" { }; 15 - 16 - settings = lib.mkOption { 17 - type = lib.types.submodule { 18 - freeformType = format.type; 19 - }; 20 - default = { }; 21 - }; 22 - }; 23 - 24 - config = lib.mkIf cfg.enable { 25 - packages = [ cfg.package ]; 26 - files.".config/git/config".source = lib.mkIf (cfg.settings != { }) ( 27 - format.generate "git-config" cfg.settings 28 - ); 29 - }; 30 - }
+4
systems/laptop.nix
··· 10 10 11 11 boot.kernelPackages = pkgs.linuxPackages_xanmod_latest; 12 12 13 + # Allow GPU usage monitoring utilities like `intel_gpu_top` 14 + # to function without superuser access 15 + boot.kernel.sysctl."kernel.perf_event_paranoid" = 0; 16 + 13 17 # Update the system timezone according to physical location 14 18 systemd.services.automatic-timezoned.enable = true; 15 19
+1 -3
users/leah/presets/niri/default.nix
··· 6 6 imports = [ 7 7 ./gui-toolkits.nix 8 8 ./services.nix 9 + ./waybar 9 10 ]; 10 11 11 12 programs.niri.enable = true; ··· 33 34 34 35 files.".config/swaync/style.css".source = ./swaync/style.css; 35 36 files.".config/swaync/config.json".source = ./swaync/config.json; 36 - 37 - files.".config/waybar/style.css".source = ./waybar/style.css; 38 - files.".config/waybar/config.jsonc".source = ./waybar/config.jsonc; 39 37 }; 40 38 41 39 hjem.users.leah.rum.programs.fuzzel = {
-153
users/leah/presets/niri/waybar/config.jsonc
··· 1 - [ 2 - { 3 - "name": "top", 4 - "layer": "top", 5 - "position": "top", 6 - "reload_style_on_change": true, 7 - "modules-left": ["group/dials"], 8 - "modules-center": ["clock"], 9 - "modules-right": [ 10 - "group/apps", 11 - "privacy", 12 - "group/appearance", 13 - "group/connectivity", 14 - "group/energy", 15 - ], 16 - "group/apps": { 17 - "orientation": "inherit", 18 - "modules": ["custom/notification", "tray"], 19 - "drawer": {}, 20 - }, 21 - "group/dials": { 22 - "orientation": "inherit", 23 - "modules": ["cpu", "custom/gpu", "memory"], 24 - }, 25 - "group/appearance": { 26 - "orientation": "inherit", 27 - "modules": [ 28 - "pulseaudio", 29 - "backlight", 30 - ], 31 - "drawer": {}, 32 - }, 33 - "group/connectivity": { 34 - "orientation": "inherit", 35 - "modules": [ 36 - "network", 37 - "bluetooth", 38 - ], 39 - "drawer": {}, 40 - }, 41 - "group/energy": { 42 - "orientation": "inherit", 43 - "modules": [ 44 - "battery", 45 - "power-profiles-daemon", 46 - ], 47 - "drawer": {}, 48 - }, 49 - "tray": { 50 - "icon-size": 24, 51 - "spacing": 6 52 - }, 53 - "custom/gpu": { 54 - "exec": "nvidia-smi --query-gpu=utilization.gpu --format=csv,noheader,nounits", 55 - "format": " {}%", 56 - "interval": 5, 57 - "return-type": "" 58 - }, 59 - "cpu": { 60 - "format": " {usage}%", 61 - }, 62 - "memory": { 63 - "format": " {percentage}%", 64 - }, 65 - "network": { 66 - "format-wifi": " {essid}", 67 - "format-ethernet": "{essid}", 68 - "format-disconnected": "", 69 - }, 70 - "pulseaudio": { 71 - "format": " {volume}%" 72 - }, 73 - "backlight": { 74 - "format": " {percent}%" 75 - }, 76 - "clock": { 77 - "format": "<b>{0:%H:%M}</b> <span size='small' color='#a6adc8'>{0:%e %b '%y / %a (%Ez)}</span>", 78 - "locale": "de_DE.UTF-8", 79 - "tooltip-format": "{tz_list}", 80 - "timezones": [ 81 - "Europe/Berlin", 82 - "Asia/Shanghai", 83 - ], 84 - }, 85 - "bluetooth": { 86 - "format-off": " ", 87 - "format-on": " ", 88 - "format-connected": " {device_alias}", 89 - "format-connected-battery": " {device_alias} {device_battery_percentage}%", 90 - }, 91 - "battery": { 92 - "interval": 15, 93 - "states": { 94 - "full": 100, 95 - "not-quite-full": 65, 96 - "warning": 25, 97 - "critical": 10 98 - }, 99 - "format": "{icon} {capacity}%", 100 - "format-plugged": " {capacity}%", 101 - "format-charging": " {capacity}%", 102 - "format-critical": "󰂃 {capacity}%", 103 - "format-icons": ["", "", "", "", ""], 104 - }, 105 - "custom/notification": { 106 - "tooltip": false, 107 - "format": "{icon} {}", 108 - "format-icons": { 109 - "notification": "", 110 - "none": "", 111 - "dnd-notification": "", 112 - "dnd-none": "", 113 - "inhibited-notification": "", 114 - "inhibited-none": "", 115 - "dnd-inhibited-notification": "", 116 - "dnd-inhibited-none": "" 117 - }, 118 - "return-type": "json", 119 - "exec-if": "which swaync-client", 120 - "exec": "swaync-client -swb", 121 - "on-click": "swaync-client -t -sw", 122 - "on-click-right": "swaync-client -d -sw", 123 - "escape": true 124 - }, 125 - }, 126 - { 127 - "layer": "top", 128 - "position": "bottom", 129 - "name": "dock", 130 - "reload_style_on_change": true, 131 - "modules-center": ["wlr/taskbar"], 132 - "wlr/taskbar": { 133 - "icon-size": 64, 134 - "on-click": "activate", 135 - }, 136 - }, 137 - { 138 - "layer": "top", 139 - "position": "left", 140 - "reload_style_on_change": true, 141 - "modules-center": ["niri/workspaces"], 142 - 143 - "niri/workspaces": { 144 - "format": "{icon}", 145 - "format-icons": { 146 - "chat": "<b></b>", 147 - "dev": "", 148 - "gaming": "", 149 - "default": "•" 150 - } 151 - } 152 - } 153 - ]
+208
users/leah/presets/niri/waybar/config.nix
··· 1 + { 2 + pkgs, 3 + lib, 4 + ... 5 + }: 6 + let 7 + common = { 8 + layer = "top"; 9 + reload_style_on_change = true; 10 + }; 11 + 12 + interval = 5; 13 + restart-interval = 20; 14 + 15 + poll-intel-gpu = pkgs.writeShellApplication { 16 + name = "poll-intel-gpu"; 17 + runtimeInputs = with pkgs; [ 18 + intel-gpu-tools 19 + jq 20 + ]; 21 + 22 + text = '' 23 + poll_rate=$1 24 + intel_gpu_top -J -s $poll_rate | jq -c --unbuffered --stream ' 25 + fromstream(2|truncate_stream(inputs)) 26 + | select(has("Render/3D")) 27 + | { 28 + percentage: ."Render/3D".busy, 29 + tooltip: "Render 3D: \(."Render/3D".busy | round)%\nBlitter: \(.Blitter.busy | round)%\nVideo: \(.Video.busy | round)%\nVideo Enhance: \(.VideoEnhance.busy | round)%\nCompute: \(.Compute.busy | round)%", 30 + }' 31 + ''; 32 + }; 33 + in 34 + map (v: common // v) [ 35 + { 36 + name = "top"; 37 + position = "top"; 38 + 39 + modules-left = [ "group/dials" ]; 40 + modules-center = [ "clock" ]; 41 + modules-right = [ 42 + "group/apps" 43 + "privacy" 44 + "group/appearance" 45 + "group/connectivity" 46 + "battery" 47 + ]; 48 + 49 + "group/apps" = { 50 + orientation = "inherit"; 51 + modules = [ 52 + "custom/notification" 53 + "tray" 54 + ]; 55 + drawer = { }; 56 + }; 57 + "group/dials" = { 58 + orientation = "inherit"; 59 + modules = [ 60 + "cpu" 61 + "custom/gpu-nvidia" 62 + "custom/gpu-intel" 63 + "memory" 64 + ]; 65 + }; 66 + "group/appearance" = { 67 + orientation = "inherit"; 68 + modules = [ 69 + "pulseaudio" 70 + "backlight" 71 + ]; 72 + drawer = { }; 73 + }; 74 + "group/connectivity" = { 75 + orientation = "inherit"; 76 + modules = [ 77 + "network" 78 + "bluetooth" 79 + ]; 80 + drawer = { }; 81 + }; 82 + 83 + # Modules 84 + tray = { 85 + icon-size = 24; 86 + spacing = 6; 87 + }; 88 + cpu = { 89 + format = " {usage}%"; 90 + inherit interval; 91 + }; 92 + memory = { 93 + format = " {percentage}%"; 94 + inherit interval; 95 + }; 96 + network = { 97 + format-wifi = ""; 98 + format-ethernet = ""; 99 + format-disconnected = ""; 100 + tooltip-format-wifi = "{essid} ({signalStrength}%)"; 101 + }; 102 + pulseaudio.format = " {volume}%"; 103 + backlight.format = " {percent}%"; 104 + clock = { 105 + format = "<b>{0:%H:%M}</b> <span size='small' color='#a6adc8'>{0:L%e %b '%y / %a (%Ez %Z)}</span>"; 106 + locale = "de_DE.UTF-8"; 107 + tooltip-format = "{tz_list}"; 108 + timezones = [ 109 + "Europe/Berlin" 110 + "Asia/Shanghai" 111 + ]; 112 + actions = { 113 + on-scroll-up = "tz_up"; 114 + on-scroll-down = "tz_down"; 115 + }; 116 + }; 117 + bluetooth = { 118 + format-off = " "; 119 + format-on = " "; 120 + format-connected = " {device_alias}"; 121 + format-connected-battery = " {device_alias} {device_battery_percentage}%"; 122 + }; 123 + battery = { 124 + inherit interval; 125 + states = { 126 + full = 100; 127 + not-quite-full = 65; 128 + warning = 25; 129 + critical = 10; 130 + }; 131 + format = "{icon} {capacity}%"; 132 + format-plugged = " {capacity}%"; 133 + format-charging = " {capacity}%"; 134 + format-critical = "󰂃 {capacity}%"; 135 + format-icons = [ 136 + "" 137 + "" 138 + "" 139 + "" 140 + "" 141 + ]; 142 + }; 143 + 144 + # Custom modules 145 + "custom/gpu-nvidia" = { 146 + exec = "nvidia-smi --query-gpu=utilization.gpu --format=csv,noheader,nounits"; 147 + exec-if = "command -v nvidia-smi"; 148 + format = " {}%"; 149 + inherit interval restart-interval; 150 + }; 151 + "custom/gpu-intel" = { 152 + exec = "${lib.getExe poll-intel-gpu} ${toString (interval * 1000)}"; 153 + exec-if = "command -v intel_gpu_top"; 154 + format = " {percentage}%"; 155 + return-type = "json"; 156 + # interval mustn't be set here as the script is continuous 157 + inherit restart-interval; 158 + }; 159 + "custom/notification" = { 160 + tooltip = false; 161 + format = "{icon} {}"; 162 + format-icons = { 163 + notification = ""; 164 + none = ""; 165 + dnd-notification = ""; 166 + dnd-none = ""; 167 + inhibited-notification = ""; 168 + inhibited-none = ""; 169 + dnd-inhibited-notification = ""; 170 + dnd-inhibited-none = ""; 171 + }; 172 + return-type = "json"; 173 + exec = "swaync-client -swb"; 174 + exec-if = "command -v swaync-client"; 175 + on-click = "swaync-client -t -sw"; 176 + on-click-right = "swaync-client -d -sw"; 177 + escape = true; 178 + }; 179 + } 180 + { 181 + name = "dock"; 182 + position = "bottom"; 183 + 184 + modules-center = [ "wlr/taskbar" ]; 185 + 186 + "wlr/taskbar" = { 187 + icon-size = 64; 188 + on-click = "activate"; 189 + }; 190 + } 191 + { 192 + name = "workspaces"; 193 + position = "left"; 194 + exclusive = false; 195 + 196 + modules-center = [ "niri/workspaces" ]; 197 + 198 + "niri/workspaces" = { 199 + format = "{icon}"; 200 + format-icons = { 201 + chat = ""; 202 + dev = ""; 203 + gaming = ""; 204 + default = "•"; 205 + }; 206 + }; 207 + } 208 + ]
+6 -2
users/leah/presets/niri/waybar/default.nix
··· 1 1 { 2 2 pkgs, 3 3 ... 4 - }: 4 + }@args: 5 + let 6 + jsonFormat = pkgs.formats.json { }; 7 + config = import ./config.nix args; 8 + in 5 9 { 6 10 hjem.users.leah = { 7 11 packages = [ pkgs.waybar ]; 8 12 9 13 files.".config/waybar/style.css".source = ./style.css; 10 - files.".config/waybar/config.jsonc".source = ./config.jsonc; 14 + files.".config/waybar/config.jsonc".source = jsonFormat.generate "waybar-config.jsonc" config; 11 15 }; 12 16 }
+88 -90
users/leah/programs/vcs.nix
··· 16 16 HWATCH = "--no-title --color --mouse --keymap q=force_cancel"; 17 17 }; 18 18 19 - hjem.users.leah.ext.programs = { 20 - git = { 21 - enable = true; 22 - integrations.difftastic.enable = true; 23 - 24 - settings = { 25 - init.defaultBranch = "main"; 26 - push.autoSetupRemote = true; 27 - url."https://github.com/".insteadOf = "gh:"; 28 - gpg.format = "ssh"; 19 + hjem.users.leah.rum.programs.git = { 20 + enable = true; 21 + integrations.difftastic.enable = true; 22 + 23 + settings = { 24 + init.defaultBranch = "main"; 25 + push.autoSetupRemote = true; 26 + url."https://github.com/".insteadOf = "gh:"; 27 + gpg.format = "ssh"; 29 28 30 - http.proxy = "http://127.0.0.1:2080"; 29 + http.proxy = "http://127.0.0.1:2080"; 31 30 32 - user = { 33 - name = "Leah Amelia Chen"; 34 - email = "hi@pluie.me"; 35 - signingKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIC7uJGE2/25M4a3DIVxtnTA5INqWsFGw+49qHXaN/kqy"; 36 - }; 31 + user = { 32 + name = "Leah Amelia Chen"; 33 + email = "hi@pluie.me"; 34 + signingKey = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIC7uJGE2/25M4a3DIVxtnTA5INqWsFGw+49qHXaN/kqy"; 37 35 }; 38 36 }; 37 + }; 39 38 40 - jujutsu = { 41 - enable = true; 42 - settings = { 43 - user = { 44 - name = "Leah Amelia Chen"; 45 - email = "hi@pluie.me"; 46 - }; 39 + hjem.users.leah.ext.programs.jujutsu = { 40 + enable = true; 41 + settings = { 42 + user = { 43 + name = "Leah Amelia Chen"; 44 + email = "hi@pluie.me"; 45 + }; 47 46 48 - ui = { 49 - default-command = [ "log" ]; 50 - diff-formatter = "difft"; 51 - pager = "${lib.getExe pkgs.moar} -no-linenumbers"; 52 - log-word-wrap = true; 53 - }; 47 + ui = { 48 + default-command = [ "log" ]; 49 + diff-formatter = "difft"; 50 + pager = "${lib.getExe pkgs.moar} -no-linenumbers"; 51 + log-word-wrap = true; 52 + }; 54 53 55 - aliases = { 56 - tug = [ 57 - "bookmark" 58 - "move" 59 - "--from" 60 - "closest_bookmark(@-)" 61 - "--to" 62 - "closest_pushable(@-)" 63 - ]; 54 + aliases = { 55 + tug = [ 56 + "bookmark" 57 + "move" 58 + "--from" 59 + "closest_bookmark(@-)" 60 + "--to" 61 + "closest_pushable(@-)" 62 + ]; 64 63 65 - monitor = [ 66 - "util" 67 - "exec" 68 - "--" 69 - "hwatch" 70 - "--exec" 71 - "--limit=1" 72 - "--" 73 - "jj" 74 - "--ignore-working-copy" 75 - "log" 76 - "--color=always" 77 - "-r" 78 - "current()" 79 - ]; 80 - }; 64 + monitor = [ 65 + "util" 66 + "exec" 67 + "--" 68 + "hwatch" 69 + "--exec" 70 + "--limit=1" 71 + "--" 72 + "jj" 73 + "--ignore-working-copy" 74 + "log" 75 + "--color=always" 76 + "-r" 77 + "current()" 78 + ]; 79 + }; 81 80 82 - revsets = { 83 - short-prefixes = "current()"; 84 - }; 81 + revsets = { 82 + short-prefixes = "current()"; 83 + }; 85 84 86 - revset-aliases = { 87 - "current()" = "(trunk()..@)::"; 88 - "closest_bookmark(to)" = "heads(::to & bookmarks())"; 89 - "closest_pushable(to)" = 90 - "heads(::to & mutable() & ~description(exact:\"\") & (~empty() | merges()))"; 91 - }; 85 + revset-aliases = { 86 + "current()" = "(trunk()..@)::"; 87 + "closest_bookmark(to)" = "heads(::to & bookmarks())"; 88 + "closest_pushable(to)" = 89 + "heads(::to & mutable() & ~description(exact:\"\") & (~empty() | merges()))"; 90 + }; 92 91 93 - template-aliases = { 94 - "format_short_id(id)" = ''id.shortest(12).prefix() ++ "'" ++ id.shortest(12).rest()''; 95 - "format_timestamp(timestamp)" = "timestamp.ago()"; 96 - "commit_timestamp(commit)" = "commit.author().timestamp()"; 97 - "format_short_signature(signature)" = "signature.name()"; 98 - }; 92 + template-aliases = { 93 + "format_short_id(id)" = ''id.shortest(12).prefix() ++ "'" ++ id.shortest(12).rest()''; 94 + "format_timestamp(timestamp)" = "timestamp.ago()"; 95 + "commit_timestamp(commit)" = "commit.author().timestamp()"; 96 + "format_short_signature(signature)" = "signature.name()"; 97 + }; 99 98 100 - templates = { 101 - git_push_bookmark = ''"pluie/jj-" ++ change_id.short()''; 102 - }; 99 + templates = { 100 + git_push_bookmark = ''"pluie/jj-" ++ change_id.short()''; 101 + }; 103 102 104 - fix.tools = { 105 - nixfmt = { 106 - command = [ "nixfmt" ]; 107 - patterns = [ "glob:'**/*.nix'" ]; 108 - }; 103 + fix.tools = { 104 + nixfmt = { 105 + command = [ "nixfmt" ]; 106 + patterns = [ "glob:'**/*.nix'" ]; 109 107 }; 108 + }; 110 109 111 - signing = { 112 - behavior = "drop"; 113 - backend = "ssh"; 114 - key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIC7uJGE2/25M4a3DIVxtnTA5INqWsFGw+49qHXaN/kqy"; 115 - }; 110 + signing = { 111 + behavior = "drop"; 112 + backend = "ssh"; 113 + key = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIC7uJGE2/25M4a3DIVxtnTA5INqWsFGw+49qHXaN/kqy"; 114 + }; 116 115 117 - git = { 118 - sign-on-push = true; 119 - private-commits = "description(glob:'wip:*')"; 120 - }; 116 + git = { 117 + sign-on-push = true; 118 + private-commits = "description(glob:'wip:*')"; 119 + }; 121 120 122 - core = { 123 - fsmonitor = "watchman"; 124 - watchman.register-snapshot-trigger = true; 125 - }; 121 + core = { 122 + fsmonitor = "watchman"; 123 + watchman.register-snapshot-trigger = true; 126 124 }; 127 125 }; 128 126 };