--- /dev/null
+prefix = /usr/local
+exec_prefix = $(prefix)
+bindir = $(exec_prefix)/bin
+INSTALL = install -D
+INSTALL_PROGRAM = $(INSTALL)
+
+batteryviewer: batteryviewer.c
+ gcc $(shell pkg-config --cflags gtk4) -o $@ $< $(shell pkg-config --libs gtk4)
+
+all: batteryviewer
+
+install:
+ $(INSTALL_PROGRAM) batteryviewer $(bindir)/batteryviewer
+
+clean:
+ rm batteryviewer
+
+.PHONY: all clean install
--- /dev/null
+#include <gtk/gtk.h>
+
+static void print_hello(GtkWidget *widget, gpointer data) {
+ g_print("Hello World\n");
+}
+
+static void activate(GtkApplication *app, gpointer user_data) {
+ GtkWidget *window;
+ GtkWidget *button;
+
+ window = gtk_application_window_new(app);
+ gtk_window_set_title(GTK_WINDOW(window), "Window");
+ gtk_window_set_default_size(GTK_WINDOW(window), 200, 200);
+
+ button = gtk_button_new_with_label("Hello World");
+ g_signal_connect(button, "clicked", G_CALLBACK(print_hello), NULL);
+ gtk_window_set_child(GTK_WINDOW(window), button);
+
+ gtk_window_present(GTK_WINDOW(window));
+}
+
+int main(int argc, char **argv) {
+ GtkApplication *app;
+ int status;
+
+ app = gtk_application_new("org.gtk.example", G_APPLICATION_DEFAULT_FLAGS);
+ g_signal_connect(app, "activate", G_CALLBACK(activate), NULL);
+ status = g_application_run(G_APPLICATION(app), argc, argv);
+ g_object_unref(app);
+
+ return status;
+}
--- /dev/null
+let
+ batteryviewer = { lib, stdenv, gtk4, pkg-config, }:
+ stdenv.mkDerivation {
+ pname = "batteryviewer";
+ version = "0.1";
+
+ src = lib.cleanSource ./.;
+
+ nativeBuildInputs = [ pkg-config ];
+ buildInputs = [ gtk4 ];
+
+ makeFlags = [ "prefix=$(out)" ];
+ };
+in { pkgs ? import <nixpkgs> { }, }: {
+ batteryviewer = pkgs.callPackage batteryviewer { };
+}