Nix configurations for my homelab
0

Configure Feed

Select the types of activity you want to include in your feed.

Patch xdg-desktop-portal-wlr to fix the stuttering in stream output

+130 -15
+12 -12
flake.lock
··· 149 149 ] 150 150 }, 151 151 "locked": { 152 - "lastModified": 1775360939, 153 - "narHash": "sha256-XUBlSgUFdvTh6+K5LcI5mJu5F5L8scmJDMRiZM484TM=", 152 + "lastModified": 1775556024, 153 + "narHash": "sha256-j1u/859OVS54rGlsvFqJdwKPEnFYCI+4pyfTiSfv1Xc=", 154 154 "owner": "nix-community", 155 155 "repo": "home-manager", 156 - "rev": "2097a5c82bdc099c6135eae4b111b78124604554", 156 + "rev": "4bdfeff1d9b7473e6e58f73f5809576e8a69e406", 157 157 "type": "github" 158 158 }, 159 159 "original": { ··· 348 348 }, 349 349 "nixpkgs-unstable": { 350 350 "locked": { 351 - "lastModified": 1775036866, 352 - "narHash": "sha256-ZojAnPuCdy657PbTq5V0Y+AHKhZAIwSIT2cb8UgAz/U=", 351 + "lastModified": 1775423009, 352 + "narHash": "sha256-vPKLpjhIVWdDrfiUM8atW6YkIggCEKdSAlJPzzhkQlw=", 353 353 "owner": "NixOS", 354 354 "repo": "nixpkgs", 355 - "rev": "6201e203d09599479a3b3450ed24fa81537ebc4e", 355 + "rev": "68d8aa3d661f0e6bd5862291b5bb263b2a6595c9", 356 356 "type": "github" 357 357 }, 358 358 "original": { ··· 380 380 }, 381 381 "nixpkgs_3": { 382 382 "locked": { 383 - "lastModified": 1775371993, 384 - "narHash": "sha256-shlcgEOzW6rl7zmZeYBMP9EpF3O/cTL7/HpWlyqearw=", 383 + "lastModified": 1775545155, 384 + "narHash": "sha256-hTjWyj6wz9Iw6IjfrP+rZj1V1DjbVRCd1WjcpxH8Fqs=", 385 385 "owner": "NixOS", 386 386 "repo": "nixpkgs", 387 - "rev": "ff2af6f7ebc6c123603d5689aeea6461290f46b5", 387 + "rev": "f97e195236002ce34b91d43ffe68557ac7d007fc", 388 388 "type": "github" 389 389 }, 390 390 "original": { ··· 450 450 "rust-overlay": "rust-overlay" 451 451 }, 452 452 "locked": { 453 - "lastModified": 1775298296, 454 - "narHash": "sha256-TiuT6J+Q2wfdNIwvytKF2J02ySiwO+6whpGXCHzPMSo=", 453 + "lastModified": 1775543919, 454 + "narHash": "sha256-htsluTXkVCDngTRD0oNIGH8bTf2u0/j3t52Ha2chG1w=", 455 455 "owner": "roc-lang", 456 456 "repo": "roc", 457 - "rev": "564046bf97229be1dfabc433871bffc5fcb934d7", 457 + "rev": "aa4e23c44773c16fbfe09aee22df9f84d81e9225", 458 458 "type": "github" 459 459 }, 460 460 "original": {
+5 -3
modules/river.nix
··· 25 25 roc-lang-server = roc-lang.packages.${prev.stdenv.hostPlatform.system}.lang-server; 26 26 xdg-desktop-portal-wlr = prev.xdg-desktop-portal-wlr.overrideAttrs ( 27 27 finalAttrs: prevAttrs: { 28 - version = "0.7.1"; 28 + version = "896cee82a6f14ee996fb870c0fc5e27533e37907"; 29 29 30 30 src = prev.fetchFromGitHub { 31 31 owner = "emersion"; 32 32 repo = "xdg-desktop-portal-wlr"; 33 - rev = "v${finalAttrs.version}"; 34 - sha256 = "sha256-GIIDeZMIGUiZV0IUhcclRVThE5LKaqVc5VwnNT8beNU="; 33 + rev = "${finalAttrs.version}"; 34 + sha256 = "sha256-uQYXGiMmrMHCygh5IHt90NSZLPbY7uVMyDx8zUTHXaM="; 35 35 }; 36 + 37 + patches = (prevAttrs.patches or [ ]) ++ [ ../patches/${prevAttrs.pname}/pw-graph-driver.patch ]; 36 38 } 37 39 ); 38 40 })
+113
patches/xdg-desktop-portal-wlr/pw-graph-driver.patch
··· 1 + From 8142629da7fd5e400fd00658d5ddaa8ea78cba53 Mon Sep 17 00:00:00 2001 2 + From: CToID <funk443@icloud.com> 3 + Date: Sun, 5 Apr 2026 23:24:45 +0800 4 + Subject: [PATCH] screencast: drive the Pipewire graph by ourselves. 5 + 6 + --- 7 + src/screencast/pipewire_screencast.c | 56 +++++++++++++++++----------- 8 + 1 file changed, 35 insertions(+), 21 deletions(-) 9 + 10 + diff --git a/src/screencast/pipewire_screencast.c b/src/screencast/pipewire_screencast.c 11 + index 102a0f2b..04f3341b 100644 12 + --- a/src/screencast/pipewire_screencast.c 13 + +++ b/src/screencast/pipewire_screencast.c 14 + @@ -16,6 +16,7 @@ 15 + #include "wlr_screencast.h" 16 + #include "xdpw.h" 17 + #include "logger.h" 18 + +#include "timespec_util.h" 19 + 20 + #define DAMAGE_REGION_COUNT 16 21 + 22 + @@ -328,6 +329,31 @@ void xdpw_pwr_enqueue_buffer(struct xdpw_screencast_instance *cast) { 23 + cast->current_frame.pw_buffer = NULL; 24 + } 25 + 26 + +static void pwr_capture_one(void *data) { 27 + + struct xdpw_screencast_instance *cast = data; 28 + + 29 + + if (!cast->pwr_stream_state) { 30 + + logprint(INFO, "pipewire: not streaming"); 31 + + return; 32 + + } 33 + + 34 + + if (cast->current_frame.pw_buffer) { 35 + + logprint(DEBUG, "pipewire: buffer already exported"); 36 + + goto trigger_graph; 37 + + } 38 + + 39 + + xdpw_pwr_dequeue_buffer(cast); 40 + + if (!cast->current_frame.pw_buffer) { 41 + + logprint(WARN, "pipewire: unable to export buffer"); 42 + + goto trigger_graph; 43 + + } 44 + + 45 + + xdpw_wlr_frame_capture(cast); 46 + + 47 + +trigger_graph: 48 + + pw_stream_trigger_process(cast->stream); 49 + +} 50 + + 51 + void pwr_update_stream_param(struct xdpw_screencast_instance *cast) { 52 + logprint(TRACE, "pipewire: stream update parameters"); 53 + struct pw_stream *stream = cast->stream; 54 + @@ -359,6 +385,7 @@ static void pwr_handle_stream_state_changed(void *data, 55 + switch (state) { 56 + case PW_STREAM_STATE_STREAMING: 57 + cast->pwr_stream_state = true; 58 + + pwr_capture_one(cast); 59 + break; 60 + case PW_STREAM_STATE_PAUSED: 61 + if (old == PW_STREAM_STATE_STREAMING) { 62 + @@ -586,27 +613,13 @@ static void pwr_handle_stream_remove_buffer(void *data, struct pw_buffer *buffer 63 + buffer->user_data = NULL; 64 + } 65 + 66 + -static void pwr_handle_stream_on_process(void *data) { 67 + +static void pwr_handle_stream_trigger_done(void *data) { 68 + struct xdpw_screencast_instance *cast = data; 69 + - 70 + - logprint(TRACE, "pipewire: on process event handle"); 71 + - 72 + - if (!cast->pwr_stream_state) { 73 + - logprint(INFO, "pipewire: not streaming"); 74 + - return; 75 + - } 76 + - 77 + - if (cast->current_frame.pw_buffer) { 78 + - logprint(DEBUG, "pipewire: buffer already exported"); 79 + - return; 80 + + uint64_t delay_ns = fps_limit_measure_end(&cast->fps_limit, cast->framerate); 81 + + if (delay_ns <= 0) { 82 + + delay_ns = (1.0 / cast->framerate) * TIMESPEC_NSEC_PER_SEC; 83 + } 84 + - 85 + - xdpw_pwr_dequeue_buffer(cast); 86 + - if (!cast->current_frame.pw_buffer) { 87 + - logprint(WARN, "pipewire: unable to export buffer"); 88 + - return; 89 + - } 90 + - xdpw_wlr_frame_capture(cast); 91 + + xdpw_add_timer(cast->ctx->state, delay_ns, pwr_capture_one, cast); 92 + } 93 + 94 + static const struct pw_stream_events pwr_stream_events = { 95 + @@ -615,7 +628,7 @@ static const struct pw_stream_events pwr_stream_events = { 96 + .param_changed = pwr_handle_stream_param_changed, 97 + .add_buffer = pwr_handle_stream_add_buffer, 98 + .remove_buffer = pwr_handle_stream_remove_buffer, 99 + - .process = pwr_handle_stream_on_process, 100 + + .trigger_done = pwr_handle_stream_trigger_done, 101 + }; 102 + 103 + void xdpw_pwr_stream_create(struct xdpw_screencast_instance *cast) { 104 + @@ -652,7 +665,8 @@ void xdpw_pwr_stream_create(struct xdpw_screencast_instance *cast) { 105 + pw_stream_connect(cast->stream, 106 + PW_DIRECTION_OUTPUT, 107 + PW_ID_ANY, 108 + - PW_STREAM_FLAG_ALLOC_BUFFERS, 109 + + (PW_STREAM_FLAG_ALLOC_BUFFERS | 110 + + PW_STREAM_FLAG_DRIVER), 111 + params.data, params.size / sizeof(struct spa_pod *)); 112 + 113 + spa_pod_dynamic_builder_clean(&builder);