Fix nix build (forgot it was building from git source); patch to load module & put fns in module

This commit is contained in:
bluepython508
2025-03-18 12:17:46 +00:00
parent b31915e6a6
commit 8b7236eef0
3 changed files with 31 additions and 41 deletions

View File

@@ -1,40 +1,10 @@
{pkgs ? import <nixpkgs> {}}:
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];
}

View File

@@ -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)

View File

@@ -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"
@@ -310,6 +311,8 @@ static SCM seat(void) {
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