From 8b7236eef0c66beb31446e20f919bc1b9f8c98f3 Mon Sep 17 00:00:00 2001 From: bluepython508 <16466646+bluepython508@users.noreply.github.com> Date: Tue, 18 Mar 2025 12:17:46 +0000 Subject: [PATCH] Fix nix build (forgot it was building from git source); patch to load module & put fns in module --- default.nix | 42 ++++++------------------------------------ module/riverguile.scm | 15 ++++++++++++++- src/load-script.c | 15 +++++++++++---- 3 files changed, 31 insertions(+), 41 deletions(-) diff --git a/default.nix b/default.nix index 1b4a99e..9f3e501 100644 --- a/default.nix +++ b/default.nix @@ -1,40 +1,10 @@ {pkgs ? import {}}: pkgs.stdenv.mkDerivation { name = "riverguile"; - src = pkgs.fetchgit { - url = "https://git.sr.ht/~leon_plickat/riverguile/"; - rev = "744ce4b1eb5950d0dc795d64bfac6b7738eec6f1"; - hash = "sha256-80XVaq+17Vu+DAs7pjt3cu5wiK37680A7S6qIulPRLc="; - }; - patches = [ - (pkgs.writeText "nix-build.patch" '' -diff --git a/Makefile b/Makefile -index 915f7ac..ff2b3c2 100644 ---- a/Makefile -+++ b/Makefile -@@ -1,6 +1,6 @@ - SCANNER := wayland-scanner - --PREFIX=/usr/local -+PREFIX=''${out} - BINDIR=$(PREFIX)/bin - DATADIR=$(PREFIX)/share - MODULEDIR=$(DATADIR)/guile/3.0 -diff --git a/src/call-idle-handler.c b/src/call-idle-handler.c -index 727656e..b4d4474 100644 ---- a/src/call-idle-handler.c -+++ b/src/call-idle-handler.c -@@ -8,7 +8,7 @@ static void *call_idle_handler_inner (void *data) - struct Call_idle_handler_parameters *params = - (struct Call_idle_handler_parameters *)data; - -- SCM event; -+ SCM event = { 0 }; - switch (params->event) - { - case IDLE: event = scm_from_utf8_symbol("idle"); break; -'') - ]; - buildInputs = with pkgs; [wayland-scanner wayland guile]; - nativeBuildInputs = [pkgs.pkg-config]; + src = ./.; + preFixup = '' + wrapProgram $out/bin/riverguile --set GUILE_LOAD_PATH "$out/share/guile/3.0/" + ''; + buildInputs = with pkgs; [wayland guile]; + nativeBuildInputs = with pkgs; [pkg-config makeBinaryWrapper wayland wayland-scanner]; } diff --git a/module/riverguile.scm b/module/riverguile.scm index 30e9a36..969ac34 100644 --- a/module/riverguile.scm +++ b/module/riverguile.scm @@ -25,7 +25,20 @@ #:export (R R:input R:map - R:keyboard-group)) + R:keyboard-group + riverctl + install-handler + seat + outputs + output-name + output-focused-tags + output-view-tags + output-urgent-tags + output-layout-name + seat-focused-output + seat-focused-view-title + seat-mode + )) (define (stringify x) (cond ((string? x) x) diff --git a/src/load-script.c b/src/load-script.c index eb01020..df4c38a 100644 --- a/src/load-script.c +++ b/src/load-script.c @@ -8,6 +8,7 @@ #include "libguile/boolean.h" #include "libguile/foreign-object.h" #include "libguile/list.h" +#include "libguile/modules.h" #include "libguile/numbers.h" #include "libguile/pairs.h" #include "libguile/scm.h" @@ -306,10 +307,12 @@ static SCM seat(void) { wl_list_for_each(seat, &context.seats, link) break; struct Output *output = NULL; - if ( seat->status.focused_output != NULL ) + if ( seat->status.focused_output != NULL ) wl_list_for_each(output, &context.outputs, link) if ( output->wl_output == seat->status.focused_output ) break; + + return scm_make_foreign_object_3( seat_t, output != NULL ? output_for(output) : SCM_BOOL_F, @@ -345,10 +348,8 @@ static void *load_script_inner (void *data) return scm_primitive_load_path(scm_from_utf8_string(path)); } -void *load_script (void *data) -{ +SCM init_module(void *data) { /* Note: All guile objects are garbage collected. */ - scm_c_define_gsubr_fix("install-handler", 2, 0, 0, install_handler); scm_c_define_gsubr_fix("riverctl", 1, 0, 1, riverctl); @@ -374,7 +375,13 @@ void *load_script (void *data) #define X(t, c, scm, i) scm_c_define_gsubr_fix(scm, 1, 0, 0, c); getters(X) #undef X + return SCM_UNSPECIFIED; +} +void *load_script (void *data) +{ + SCM module = scm_c_resolve_module("riverguile"); + scm_c_call_with_current_module(module, init_module, NULL); /* Continuation barrier causes stack unwind on exceptions to stop here. * Otherwise the entire stack created by scm_with_guile() would be