refiled directories

This commit is contained in:
2026-03-31 13:58:19 -05:00
parent b669e6349d
commit e145ba949b
6 changed files with 119 additions and 258 deletions

View File

@@ -7,7 +7,6 @@ from typing import Literal
def _run(cmd: list[str]) -> str: def _run(cmd: list[str]) -> str:
"""Run a command and return stripped stdout (empty string on failure)."""
try: try:
result = subprocess.run(cmd, capture_output=True, text=True, timeout=10) result = subprocess.run(cmd, capture_output=True, text=True, timeout=10)
return result.stdout.strip() return result.stdout.strip()
@@ -16,12 +15,10 @@ def _run(cmd: list[str]) -> str:
def is_active(unit: str, scope: Literal["system", "user"] = "system") -> str: def is_active(unit: str, scope: Literal["system", "user"] = "system") -> str:
"""Return the ActiveState string (active / inactive / failed / …)."""
return _run(["systemctl", f"--{scope}", "is-active", unit]) or "unknown" return _run(["systemctl", f"--{scope}", "is-active", unit]) or "unknown"
def is_enabled(unit: str, scope: Literal["system", "user"] = "system") -> str: def is_enabled(unit: str, scope: Literal["system", "user"] = "system") -> str:
"""Return the UnitFileState string (enabled / disabled / masked / …)."""
return _run(["systemctl", f"--{scope}", "is-enabled", unit]) or "unknown" return _run(["systemctl", f"--{scope}", "is-enabled", unit]) or "unknown"
@@ -31,18 +28,11 @@ def run_action(
scope: Literal["system", "user"] = "system", scope: Literal["system", "user"] = "system",
method: str = "systemctl", method: str = "systemctl",
) -> bool: ) -> bool:
"""Start / stop / restart a unit.
For *system* units the command is elevated via *method* (pkexec or sudo).
Returns True on apparent success.
"""
base_cmd = ["systemctl", f"--{scope}", action, unit] base_cmd = ["systemctl", f"--{scope}", action, unit]
if scope == "system" and method == "pkexec": if scope == "system" and method == "pkexec":
cmd = ["pkexec", "--user", "root"] + base_cmd cmd = ["pkexec", "--user", "root"] + base_cmd
else: else:
cmd = base_cmd cmd = base_cmd
try: try:
subprocess.Popen(cmd) subprocess.Popen(cmd)
return True return True

View File

@@ -9,84 +9,63 @@ import gi
gi.require_version("Gtk", "4.0") gi.require_version("Gtk", "4.0")
gi.require_version("Adw", "1") gi.require_version("Adw", "1")
from gi.repository import Adw, Gdk, Gio, GLib, Gtk # noqa: E402 from gi.repository import Adw, Gdk, Gio, GLib, Gtk
from .config import load_config # noqa: E402 from .config import load_config
from .service_tile import ServiceTile # noqa: E402 from .service_tile import ServiceTile
APP_ID = "com.sovransystems.hub" APP_ID = "com.sovransystems.hub"
class SovranHubWindow(Adw.ApplicationWindow): class SovranHubWindow(Adw.ApplicationWindow):
"""Primary window: a 4-across grid of service tiles with auto-refresh."""
def __init__(self, app: Adw.Application, config: dict): def __init__(self, app, config):
super().__init__( super().__init__(
application=app, application=app, title="Sovran_SystemsOS Hub",
title="Sovran_SystemsOS Hub", default_width=680, default_height=700,
default_width=680,
default_height=700,
) )
self._config = config self._config = config
self._tiles: list[ServiceTile] = [] self._tiles = []
# ── Load custom CSS ──
css_path = os.environ.get("SOVRAN_HUB_CSS", "") css_path = os.environ.get("SOVRAN_HUB_CSS", "")
if css_path and os.path.isfile(css_path): if css_path and os.path.isfile(css_path):
provider = Gtk.CssProvider() provider = Gtk.CssProvider()
provider.load_from_path(css_path) provider.load_from_path(css_path)
Gtk.StyleContext.add_provider_for_display( Gtk.StyleContext.add_provider_for_display(
Gdk.Display.get_default(), Gdk.Display.get_default(), provider,
provider,
Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION, Gtk.STYLE_PROVIDER_PRIORITY_APPLICATION,
) )
# ── Header bar ──
header = Adw.HeaderBar() header = Adw.HeaderBar()
refresh_btn = Gtk.Button(icon_name="view-refresh-symbolic", tooltip_text="Refresh now")
refresh_btn = Gtk.Button(
icon_name="view-refresh-symbolic",
tooltip_text="Refresh now",
)
refresh_btn.connect("clicked", lambda _b: self._refresh_all()) refresh_btn.connect("clicked", lambda _b: self._refresh_all())
header.pack_end(refresh_btn) header.pack_end(refresh_btn)
# ── FlowBox: 4 tiles across ──
self._flowbox = Gtk.FlowBox( self._flowbox = Gtk.FlowBox(
max_children_per_line=4, max_children_per_line=4, min_children_per_line=2,
min_children_per_line=2, selection_mode=Gtk.SelectionMode.NONE, homogeneous=True,
selection_mode=Gtk.SelectionMode.NONE, row_spacing=12, column_spacing=12,
homogeneous=True, margin_top=16, margin_bottom=16, margin_start=16, margin_end=16,
row_spacing=12, halign=Gtk.Align.CENTER, valign=Gtk.Align.START,
column_spacing=12,
margin_top=16,
margin_bottom=16,
margin_start=16,
margin_end=16,
halign=Gtk.Align.CENTER,
valign=Gtk.Align.START,
) )
# ── Scrollable content ──
scrolled = Gtk.ScrolledWindow( scrolled = Gtk.ScrolledWindow(
hscrollbar_policy=Gtk.PolicyType.NEVER, hscrollbar_policy=Gtk.PolicyType.NEVER,
vscrollbar_policy=Gtk.PolicyType.AUTOMATIC, vscrollbar_policy=Gtk.PolicyType.AUTOMATIC,
vexpand=True, vexpand=True, child=self._flowbox,
child=self._flowbox,
) )
toolbar_view = Adw.ToolbarView() toolbar_view = Adw.ToolbarView()
toolbar_view.add_top_bar(header) toolbar_view.add_top_bar(header)
toolbar_view.set_content(scrolled) toolbar_view.set_content(scrolled)
self.set_content(toolbar_view) self.set_content(toolbar_view)
# ── Populate ──
self._build_tiles() self._build_tiles()
self._start_auto_refresh() interval = config.get("refresh_interval", 5)
if interval and interval > 0:
GLib.timeout_add_seconds(interval, self._auto_refresh)
def _build_tiles(self): def _build_tiles(self):
"""Create ServiceTile widgets from config."""
for entry in self._config.get("services", []): for entry in self._config.get("services", []):
tile = ServiceTile( tile = ServiceTile(
name=entry.get("name", entry["unit"]), name=entry.get("name", entry["unit"]),
@@ -99,27 +78,18 @@ class SovranHubWindow(Adw.ApplicationWindow):
self._tiles.append(tile) self._tiles.append(tile)
def _refresh_all(self): def _refresh_all(self):
for tile in self._tiles: for t in self._tiles:
tile.refresh() t.refresh()
def _start_auto_refresh(self): def _auto_refresh(self):
interval = self._config.get("refresh_interval", 5)
if interval and interval > 0:
GLib.timeout_add_seconds(interval, self._auto_refresh_cb)
def _auto_refresh_cb(self) -> bool:
self._refresh_all() self._refresh_all()
return True return True
class SovranHubApp(Adw.Application): class SovranHubApp(Adw.Application):
"""Sovran_SystemsOS_Hub Adw.Application."""
def __init__(self): def __init__(self):
super().__init__( super().__init__(application_id=APP_ID, flags=Gio.ApplicationFlags.DEFAULT_FLAGS)
application_id=APP_ID,
flags=Gio.ApplicationFlags.DEFAULT_FLAGS,
)
self._config = load_config() self._config = load_config()
def do_activate(self): def do_activate(self):

View File

@@ -10,31 +10,19 @@ gi.require_version("Gtk", "4.0")
gi.require_version("Adw", "1") gi.require_version("Adw", "1")
gi.require_version("Gdk", "4.0") gi.require_version("Gdk", "4.0")
from gi.repository import Adw, Gdk, GdkPixbuf, GLib, Gtk # noqa: E402 from gi.repository import Adw, Gdk, GdkPixbuf, GLib, Gtk
from . import systemctl # noqa: E402 from . import systemctl
LOADING_STATES = {"reloading", "activating", "deactivating", "maintenance"} LOADING_STATES = {"reloading", "activating", "deactivating", "maintenance"}
# Icon directory injected by the Nix derivation via environment variable
ICON_DIR = os.environ.get("SOVRAN_HUB_ICONS", "") ICON_DIR = os.environ.get("SOVRAN_HUB_ICONS", "")
# Supported icon extensions in priority order
ICON_EXTENSIONS = [".svg", ".png"] ICON_EXTENSIONS = [".svg", ".png"]
class ServiceTile(Gtk.Box): class ServiceTile(Gtk.Box):
"""A square tile showing a service logo, name, status, toggle, and restart."""
def __init__( def __init__(self, name, unit, scope="system", method="systemctl", icon_name="", **kw):
self,
name: str,
unit: str,
scope: str = "system",
method: str = "systemctl",
icon_name: str = "",
**kwargs,
):
super().__init__( super().__init__(
orientation=Gtk.Orientation.VERTICAL, orientation=Gtk.Orientation.VERTICAL,
spacing=6, spacing=6,
@@ -43,136 +31,84 @@ class ServiceTile(Gtk.Box):
width_request=140, width_request=140,
height_request=160, height_request=160,
css_classes=["card", "sovran-tile"], css_classes=["card", "sovran-tile"],
margin_top=6, margin_top=6, margin_bottom=6, margin_start=6, margin_end=6,
margin_bottom=6, **kw,
margin_start=6,
margin_end=6,
**kwargs,
) )
self._unit = unit self._unit = unit
self._scope = scope self._scope = scope
self._method = method self._method = method
self._name = name
# ── Logo ── self._logo = Gtk.Image(pixel_size=48, margin_top=12, halign=Gtk.Align.CENTER)
self._logo = Gtk.Image(
pixel_size=48,
margin_top=12,
halign=Gtk.Align.CENTER,
css_classes=["sovran-tile-icon"],
)
self._set_logo(icon_name) self._set_logo(icon_name)
self.append(self._logo) self.append(self._logo)
# ── Service name ── self.append(Gtk.Label(
label = Gtk.Label( label=name, css_classes=["heading"],
label=name, halign=Gtk.Align.CENTER, ellipsize=3, max_width_chars=14,
css_classes=["heading"], ))
halign=Gtk.Align.CENTER,
ellipsize=3, # PANGO_ELLIPSIZE_END
max_width_chars=14,
)
self.append(label)
# ── Status label ── self._status_label = Gtk.Label(css_classes=["caption"], halign=Gtk.Align.CENTER)
self._status_label = Gtk.Label(
css_classes=["caption"],
halign=Gtk.Align.CENTER,
)
self.append(self._status_label) self.append(self._status_label)
# ── Controls row (switch + restart) ──
controls = Gtk.Box( controls = Gtk.Box(
orientation=Gtk.Orientation.HORIZONTAL, orientation=Gtk.Orientation.HORIZONTAL,
spacing=8, spacing=8, halign=Gtk.Align.CENTER, margin_bottom=8,
halign=Gtk.Align.CENTER,
margin_bottom=8,
) )
self._switch = Gtk.Switch(valign=Gtk.Align.CENTER) self._switch = Gtk.Switch(valign=Gtk.Align.CENTER)
self._switch.connect("state-set", self._on_toggled) self._switch.connect("state-set", self._on_toggled)
controls.append(self._switch) controls.append(self._switch)
restart_btn = Gtk.Button( restart_btn = Gtk.Button(
icon_name="view-refresh-symbolic", icon_name="view-refresh-symbolic", valign=Gtk.Align.CENTER,
valign=Gtk.Align.CENTER, tooltip_text="Restart", css_classes=["flat", "circular"],
tooltip_text="Restart",
css_classes=["flat", "circular"],
) )
restart_btn.connect("clicked", self._on_restart) restart_btn.connect("clicked", self._on_restart)
controls.append(restart_btn) controls.append(restart_btn)
self.append(controls) self.append(controls)
# Initial state
self.refresh() self.refresh()
def _set_logo(self, icon_name: str): def _set_logo(self, icon_name):
"""Set the tile logo from an SVG or PNG in the icons dir."""
if icon_name and ICON_DIR: if icon_name and ICON_DIR:
for ext in ICON_EXTENSIONS: for ext in ICON_EXTENSIONS:
icon_path = os.path.join(ICON_DIR, f"{icon_name}{ext}") path = os.path.join(ICON_DIR, f"{icon_name}{ext}")
if os.path.isfile(icon_path): if os.path.isfile(path):
if ext == ".svg": pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(path, 48, 48, True)
# GTK4 handles SVGs natively via GdkPixbuf
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(
icon_path, 48, 48, True
)
texture = Gdk.Texture.new_for_pixbuf(pixbuf)
self._logo.set_from_paintable(texture)
else:
# PNG path
pixbuf = GdkPixbuf.Pixbuf.new_from_file_at_scale(
icon_path, 48, 48, True
)
texture = Gdk.Texture.new_for_pixbuf(pixbuf) texture = Gdk.Texture.new_for_pixbuf(pixbuf)
self._logo.set_from_paintable(texture) self._logo.set_from_paintable(texture)
return return
# Fallback: themed symbolic icon
self._logo.set_from_icon_name("system-run-symbolic") self._logo.set_from_icon_name("system-run-symbolic")
# ── public API ──
def refresh(self): def refresh(self):
"""Poll systemctl and update the tile.""" active = systemctl.is_active(self._unit, self._scope)
active_state = systemctl.is_active(self._unit, self._scope) enabled = systemctl.is_enabled(self._unit, self._scope)
enabled_state = systemctl.is_enabled(self._unit, self._scope) is_on = active == "active"
is_loading = active in LOADING_STATES
is_failed = active == "failed"
is_active = active_state == "active"
is_loading = active_state in LOADING_STATES
is_failed = active_state == "failed"
# Block the handler so we don't trigger a start/stop
self._switch.handler_block_by_func(self._on_toggled) self._switch.handler_block_by_func(self._on_toggled)
self._switch.set_active(is_active) self._switch.set_active(is_on)
self._switch.handler_unblock_by_func(self._on_toggled) self._switch.handler_unblock_by_func(self._on_toggled)
self._switch.set_sensitive(not is_loading) self._switch.set_sensitive(not is_loading)
# Status text + color
if is_failed: if is_failed:
self._status_label.set_label("● failed") self._status_label.set_label("● failed")
self._status_label.set_css_classes(["caption", "error"]) self._status_label.set_css_classes(["caption", "error"])
elif is_active: elif is_on:
self._status_label.set_label("● running") self._status_label.set_label("● running")
self._status_label.set_css_classes(["caption", "success"]) self._status_label.set_css_classes(["caption", "success"])
elif is_loading: elif is_loading:
self._status_label.set_label(f"{active_state}") self._status_label.set_label(f"{active}")
self._status_label.set_css_classes(["caption", "warning"]) self._status_label.set_css_classes(["caption", "warning"])
else: else:
self._status_label.set_label(f"{active_state}") self._status_label.set_label(f"{active}")
self._status_label.set_css_classes(["caption", "dim-label"]) self._status_label.set_css_classes(["caption", "dim-label"])
# ── signal handlers ── def _on_toggled(self, switch, state):
systemctl.run_action("start" if state else "stop", self._unit, self._scope, self._method)
def _on_toggled(self, switch: Gtk.Switch, state: bool) -> bool:
action = "start" if state else "stop"
systemctl.run_action(action, self._unit, self._scope, self._method)
GLib.timeout_add(1500, self.refresh) GLib.timeout_add(1500, self.refresh)
return False return False
def _on_restart(self, _btn: Gtk.Button): def _on_restart(self, _btn):
systemctl.run_action("restart", self._unit, self._scope, self._method) systemctl.run_action("restart", self._unit, self._scope, self._method)
GLib.timeout_add(1500, self.refresh) GLib.timeout_add(1500, self.refresh)

View File

@@ -7,7 +7,6 @@ from typing import Literal
def _run(cmd: list[str]) -> str: def _run(cmd: list[str]) -> str:
"""Run a command and return stripped stdout (empty string on failure)."""
try: try:
result = subprocess.run(cmd, capture_output=True, text=True, timeout=10) result = subprocess.run(cmd, capture_output=True, text=True, timeout=10)
return result.stdout.strip() return result.stdout.strip()
@@ -16,12 +15,10 @@ def _run(cmd: list[str]) -> str:
def is_active(unit: str, scope: Literal["system", "user"] = "system") -> str: def is_active(unit: str, scope: Literal["system", "user"] = "system") -> str:
"""Return the ActiveState string (active / inactive / failed / …)."""
return _run(["systemctl", f"--{scope}", "is-active", unit]) or "unknown" return _run(["systemctl", f"--{scope}", "is-active", unit]) or "unknown"
def is_enabled(unit: str, scope: Literal["system", "user"] = "system") -> str: def is_enabled(unit: str, scope: Literal["system", "user"] = "system") -> str:
"""Return the UnitFileState string (enabled / disabled / masked / …)."""
return _run(["systemctl", f"--{scope}", "is-enabled", unit]) or "unknown" return _run(["systemctl", f"--{scope}", "is-enabled", unit]) or "unknown"
@@ -31,18 +28,11 @@ def run_action(
scope: Literal["system", "user"] = "system", scope: Literal["system", "user"] = "system",
method: str = "systemctl", method: str = "systemctl",
) -> bool: ) -> bool:
"""Start / stop / restart a unit.
For *system* units the command is elevated via *method* (pkexec or sudo).
Returns True on apparent success.
"""
base_cmd = ["systemctl", f"--{scope}", action, unit] base_cmd = ["systemctl", f"--{scope}", action, unit]
if scope == "system" and method == "pkexec": if scope == "system" and method == "pkexec":
cmd = ["pkexec", "--user", "root"] + base_cmd cmd = ["pkexec", "--user", "root"] + base_cmd
else: else:
cmd = base_cmd cmd = base_cmd
try: try:
subprocess.Popen(cmd) subprocess.Popen(cmd)
return True return True

View File

@@ -1,5 +1,3 @@
/* Sovran_SystemsOS Hub — tile styling */
.sovran-tile { .sovran-tile {
border-radius: 16px; border-radius: 16px;
padding: 8px; padding: 8px;
@@ -7,21 +5,8 @@
min-height: 160px; min-height: 160px;
transition: box-shadow 200ms ease-in-out; transition: box-shadow 200ms ease-in-out;
} }
.sovran-tile:hover { .sovran-tile:hover {
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25); box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
} }
.success { color: #2ec27e; }
.sovran-tile-icon { .warning { color: #e5a50a; }
margin-top: 8px;
margin-bottom: 2px;
}
/* Status dot colors */
.success {
color: #2ec27e;
}
.warning {
color: #e5a50a;
}

View File

@@ -1,50 +1,42 @@
# modules/core/sovran-hub.nix { config, lib, pkgs, ... }:
#
# Declarative NixOS module that:
# 1. Builds the Sovran_SystemsOS_Hub GTK4 app as a Nix derivation
# 2. Generates its config.json from existing sovran_systemsOS options
# 3. Uses logos committed directly in the repo (no fetchurl hashes)
# 4. Installs a .desktop file so it appears in GNOME Activities
{ config, pkgs, lib, ... }:
let let
cfg = config.sovran_systemsOS; cfg = config.sovran_systemsOS;
# ── Build the list of monitored units from NixOS option state ──
monitoredServices = monitoredServices =
(lib.optional cfg.services.bitcoin [
{ name = "Bitcoind"; unit = "bitcoind.service"; type = "system"; icon = "bitcoind"; })
++ (lib.optional cfg.services.bitcoin
{ name = "Electrs"; unit = "electrs.service"; type = "system"; icon = "electrs"; })
++ (lib.optional cfg.services.bitcoin
{ name = "LND"; unit = "lnd.service"; type = "system"; icon = "lnd"; })
++ (lib.optional cfg.services.bitcoin
{ name = "Ride The Lightning"; unit = "rtl.service"; type = "system"; icon = "rtl"; })
++ (lib.optional cfg.services.bitcoin
{ name = "BTCPayserver"; unit = "btcpayserver.service"; type = "system"; icon = "btcpayserver"; })
++ (lib.optional cfg.services.synapse
{ name = "Matrix-Synapse"; unit = "matrix-synapse.service"; type = "system"; icon = "synapse"; })
++ (lib.optional cfg.services.vaultwarden
{ name = "VaultWarden"; unit = "vaultwarden.service"; type = "system"; icon = "vaultwarden"; })
++ (lib.optional cfg.services.nextcloud
{ name = "Nextcloud"; unit = "phpfpm-nextcloud.service"; type = "system"; icon = "nextcloud"; })
++ (lib.optional cfg.services.wordpress
{ name = "WordPress"; unit = "phpfpm-wordpress.service"; type = "system"; icon = "wordpress"; })
++ (lib.optional cfg.features.haven
{ name = "Haven Relay"; unit = "haven-relay.service"; type = "system"; icon = "haven"; })
++ (lib.optional cfg.features.mempool
{ name = "Mempool"; unit = "mempool.service"; type = "system"; icon = "mempool"; })
++ (lib.optional cfg.features.element-calling
{ name = "LiveKit"; unit = "livekit.service"; type = "system"; icon = "livekit"; })
# Always-on infrastructure
++ [
{ name = "Caddy"; unit = "caddy.service"; type = "system"; icon = "caddy"; } { name = "Caddy"; unit = "caddy.service"; type = "system"; icon = "caddy"; }
{ name = "Tor"; unit = "tor.service"; type = "system"; icon = "tor"; } { name = "Tor"; unit = "tor.service"; type = "system"; icon = "tor"; }
]
++ lib.optionals cfg.services.bitcoin [
{ name = "Bitcoind"; unit = "bitcoind.service"; type = "system"; icon = "bitcoind"; }
{ name = "Electrs"; unit = "electrs.service"; type = "system"; icon = "electrs"; }
{ name = "LND"; unit = "lnd.service"; type = "system"; icon = "lnd"; }
{ name = "Ride The Lightning"; unit = "rtl.service"; type = "system"; icon = "rtl"; }
{ name = "BTCPayserver"; unit = "btcpayserver.service"; type = "system"; icon = "btcpayserver"; }
]
++ lib.optionals cfg.services.synapse [
{ name = "Matrix-Synapse"; unit = "matrix-synapse.service"; type = "system"; icon = "synapse"; }
]
++ lib.optionals cfg.services.vaultwarden [
{ name = "VaultWarden"; unit = "vaultwarden.service"; type = "system"; icon = "vaultwarden"; }
]
++ lib.optionals cfg.services.nextcloud [
{ name = "Nextcloud"; unit = "phpfpm-nextcloud.service"; type = "system"; icon = "nextcloud"; }
]
++ lib.optionals cfg.services.wordpress [
{ name = "WordPress"; unit = "phpfpm-wordpress.service"; type = "system"; icon = "wordpress"; }
]
++ lib.optionals cfg.features.haven [
{ name = "Haven Relay"; unit = "haven-relay.service"; type = "system"; icon = "haven"; }
]
++ lib.optionals cfg.features.mempool [
{ name = "Mempool"; unit = "mempool.service"; type = "system"; icon = "mempool"; }
]
++ lib.optionals cfg.features.element-calling [
{ name = "LiveKit"; unit = "livekit.service"; type = "system"; icon = "livekit"; }
]; ];
# ── Generate the config.json at build time ──
generatedConfig = pkgs.writeText "sovran-hub-config.json" generatedConfig = pkgs.writeText "sovran-hub-config.json"
(builtins.toJSON { (builtins.toJSON {
refresh_interval = 5; refresh_interval = 5;
@@ -52,7 +44,6 @@ let
services = monitoredServices; services = monitoredServices;
}); });
# ── Package the Python GTK4 app ──
sovran-hub = pkgs.python3Packages.buildPythonApplication { sovran-hub = pkgs.python3Packages.buildPythonApplication {
pname = "sovran-systemsos-hub"; pname = "sovran-systemsos-hub";
version = "1.0.0"; version = "1.0.0";
@@ -60,54 +51,51 @@ let
src = ../../app; src = ../../app;
nativeBuildInputs = [ pkgs.wrapGAppsHook4 ]; nativeBuildInputs = with pkgs; [
wrapGAppsHook4
buildInputs = [ gobject-introspection
pkgs.gtk4
pkgs.libadwaita
pkgs.gobject-introspection
pkgs.gdk-pixbuf
pkgs.librsvg
]; ];
propagatedBuildInputs = [ buildInputs = with pkgs; [
pkgs.python3Packages.pygobject3 gtk4
libadwaita
gdk-pixbuf
librsvg
];
propagatedBuildInputs = with pkgs.python3Packages; [
pygobject3
]; ];
dontBuild = true; dontBuild = true;
installPhase = '' installPhase = ''
mkdir -p $out/bin $out/lib/sovran-hub $out/share/applications $out/share/sovran-hub/icons runHook preInstall
# Copy Python source install -d $out/lib/sovran-hub
cp -r sovran_systemsos_hub $out/lib/sovran-hub/ cp -r sovran_systemsos_hub $out/lib/sovran-hub/
# Copy CSS
cp style.css $out/lib/sovran-hub/style.css cp style.css $out/lib/sovran-hub/style.css
# Copy logos from the repo (no fetchurl needed)
cp icons/* $out/share/sovran-hub/icons/ 2>/dev/null || true
# Install the generated config
cp ${generatedConfig} $out/lib/sovran-hub/config.json cp ${generatedConfig} $out/lib/sovran-hub/config.json
# Create the launcher script install -d $out/share/sovran-hub/icons
cat > $out/bin/sovran-hub <<'LAUNCHER' cp icons/* $out/share/sovran-hub/icons/ 2>/dev/null || true
#!/usr/bin/env python3
import sys, os install -d $out/bin
sys.path.insert(0, os.path.join("@out@", "lib", "sovran-hub")) cat > $out/bin/sovran-hub <<LAUNCHER
os.environ["SOVRAN_HUB_CONFIG"] = os.path.join("@out@", "lib", "sovran-hub", "config.json") #!${pkgs.python3}/bin/python3
os.environ["SOVRAN_HUB_ICONS"] = os.path.join("@out@", "share", "sovran-hub", "icons") import os, sys
os.environ["SOVRAN_HUB_CSS"] = os.path.join("@out@", "lib", "sovran-hub", "style.css") base = os.path.join("$out", "lib", "sovran-hub")
sys.path.insert(0, base)
os.environ["SOVRAN_HUB_CONFIG"] = os.path.join(base, "config.json")
os.environ["SOVRAN_HUB_ICONS"] = os.path.join("$out", "share", "sovran-hub", "icons")
os.environ["SOVRAN_HUB_CSS"] = os.path.join(base, "style.css")
from sovran_systemsos_hub.application import SovranHubApp from sovran_systemsos_hub.application import SovranHubApp
sys.exit(SovranHubApp().run(sys.argv)) sys.exit(SovranHubApp().run(sys.argv))
LAUNCHER LAUNCHER
substituteInPlace $out/bin/sovran-hub --replace "@out@" "$out"
chmod +x $out/bin/sovran-hub chmod +x $out/bin/sovran-hub
# Desktop file install -d $out/share/applications
cat > $out/share/applications/Sovran_SystemsOS_Hub.desktop <<EOF cat > $out/share/applications/Sovran_SystemsOS_Hub.desktop <<DESKTOP
[Desktop Entry] [Desktop Entry]
Type=Application Type=Application
Name=Sovran_SystemsOS Hub Name=Sovran_SystemsOS Hub
@@ -117,11 +105,13 @@ Icon=system-run-symbolic
Terminal=false Terminal=false
Categories=System;Monitor; Categories=System;Monitor;
StartupWMClass=com.sovransystems.hub StartupWMClass=com.sovransystems.hub
EOF DESKTOP
runHook postInstall
''; '';
meta = { meta = {
description = "Sovran_SystemsOS Hub GTK4 app to manage systemd services"; description = "Sovran_SystemsOS Hub GTK4 systemd service manager";
mainProgram = "sovran-hub"; mainProgram = "sovran-hub";
}; };
}; };