2023-08-28 09:26:30 +00:00
|
|
|
{ stdenv
|
|
|
|
, bash
|
|
|
|
, bc
|
|
|
|
, bemenu
|
|
|
|
, bonsai
|
|
|
|
, brightnessctl
|
|
|
|
, buildPackages
|
|
|
|
, busybox
|
|
|
|
, conky
|
|
|
|
, coreutils
|
|
|
|
, curl
|
|
|
|
, dbus
|
2023-09-24 19:49:59 +00:00
|
|
|
, dmenu
|
2023-08-28 09:26:30 +00:00
|
|
|
, fetchgit
|
|
|
|
, fetchpatch
|
|
|
|
, gitUpdater
|
|
|
|
, gnugrep
|
|
|
|
, gojq
|
|
|
|
, grim
|
|
|
|
, inotify-tools
|
|
|
|
, j4-dmenu-desktop
|
|
|
|
, jq
|
|
|
|
, lib
|
|
|
|
, libnotify
|
|
|
|
, libxml2
|
|
|
|
, lisgd
|
|
|
|
, makeBinaryWrapper
|
|
|
|
, mako
|
|
|
|
, modemmanager
|
|
|
|
, nettools
|
2023-10-08 17:12:53 +00:00
|
|
|
, networkmanager
|
2023-08-28 09:26:30 +00:00
|
|
|
, playerctl
|
|
|
|
, procps
|
|
|
|
, pulseaudio
|
|
|
|
, rsync
|
|
|
|
, scdoc
|
2023-09-24 19:49:59 +00:00
|
|
|
, scrot
|
2023-08-28 09:26:30 +00:00
|
|
|
, sfeed
|
2023-08-29 09:17:09 +00:00
|
|
|
, slurp
|
2023-08-28 09:26:30 +00:00
|
|
|
, superd
|
|
|
|
, sway
|
|
|
|
, swayidle
|
2023-10-08 17:12:53 +00:00
|
|
|
, systemd
|
2023-08-28 09:26:30 +00:00
|
|
|
, wob
|
2023-08-29 09:44:30 +00:00
|
|
|
, wl-clipboard
|
2023-08-29 08:49:25 +00:00
|
|
|
, wtype
|
2023-08-28 09:26:30 +00:00
|
|
|
, wvkbd
|
|
|
|
, xdg-user-dirs
|
|
|
|
, xdotool
|
|
|
|
, xrdb
|
|
|
|
|
|
|
|
, version
|
|
|
|
, rev ? version
|
|
|
|
, hash ? ""
|
|
|
|
, patches ? []
|
2023-09-24 19:49:59 +00:00
|
|
|
, supportSway ? true
|
|
|
|
, supportDwm ? false
|
2023-10-08 17:12:53 +00:00
|
|
|
, preferSystemd ? false
|
2023-08-28 09:26:30 +00:00
|
|
|
}:
|
|
|
|
|
|
|
|
let
|
|
|
|
# anything which any sxmo script or default hook in this package might invoke
|
|
|
|
runtimeDeps = [
|
|
|
|
bc # also in busybox
|
|
|
|
bonsai
|
|
|
|
brightnessctl
|
|
|
|
conky
|
|
|
|
curl
|
|
|
|
dbus
|
|
|
|
gnugrep # also in busybox
|
|
|
|
gojq
|
|
|
|
inotify-tools
|
|
|
|
j4-dmenu-desktop
|
|
|
|
jq
|
|
|
|
libnotify
|
|
|
|
libxml2.bin # for xmllint; sxmo_weather.sh, sxmo_surf_linkset.sh
|
|
|
|
lisgd
|
|
|
|
mako
|
|
|
|
modemmanager # mmcli
|
|
|
|
nettools # netstat
|
2023-10-08 17:12:53 +00:00
|
|
|
networkmanager # nmcli
|
2023-08-28 09:26:30 +00:00
|
|
|
playerctl
|
|
|
|
procps # pgrep
|
|
|
|
pulseaudio # pactl
|
|
|
|
sfeed
|
2023-09-24 19:49:59 +00:00
|
|
|
wob
|
|
|
|
xdg-user-dirs # used by sxmo_hook_start.sh
|
|
|
|
xrdb # for sxmo_xinit AND sxmo_winit
|
2023-10-08 17:12:53 +00:00
|
|
|
] ++ (
|
|
|
|
if preferSystemd then [ systemd ] else [ superd ]
|
|
|
|
) ++ lib.optionals supportSway [
|
2023-09-24 19:49:59 +00:00
|
|
|
bemenu
|
|
|
|
grim
|
|
|
|
slurp # for sxmo_screenshot.sh
|
2023-08-28 09:26:30 +00:00
|
|
|
sway
|
|
|
|
swayidle
|
2023-08-29 09:44:30 +00:00
|
|
|
wl-clipboard # for wl-copy; sxmo_screenshot.sh
|
2023-08-29 08:49:25 +00:00
|
|
|
wtype # for sxmo_type
|
2023-09-24 19:49:59 +00:00
|
|
|
wvkbd # sxmo_winit.sh
|
|
|
|
] ++ lib.optionals supportDwm [
|
|
|
|
dmenu
|
|
|
|
scrot # sxmo_screenshot.sh
|
2023-08-28 09:26:30 +00:00
|
|
|
xdotool
|
|
|
|
];
|
|
|
|
in
|
|
|
|
stdenv.mkDerivation rec {
|
|
|
|
pname = "sxmo-utils";
|
|
|
|
inherit version;
|
|
|
|
|
|
|
|
src = fetchgit {
|
|
|
|
url = "https://git.sr.ht/~mil/sxmo-utils";
|
|
|
|
inherit rev hash;
|
|
|
|
};
|
|
|
|
|
|
|
|
inherit patches;
|
|
|
|
|
|
|
|
postPatch = ''
|
|
|
|
# allow sxmo to source its init file
|
|
|
|
sed -i "s@/etc/profile\.d/sxmo_init.sh@$out/etc/profile.d/sxmo_init.sh@" scripts/core/*.sh
|
|
|
|
# remove absolute paths
|
|
|
|
substituteInPlace scripts/core/sxmo_version.sh \
|
|
|
|
--replace "/usr/bin/" ""
|
|
|
|
|
|
|
|
# let superd find sxmo service binaries at runtime via PATH
|
|
|
|
# TODO: replace with fully-qualified paths
|
2023-10-11 01:30:43 +00:00
|
|
|
sed -i 's:ExecStart=/usr/bin/:ExecStart=/usr/bin/env :' \
|
|
|
|
configs/services/*.service \
|
|
|
|
configs/superd/services/*.service
|
2023-08-28 09:26:30 +00:00
|
|
|
|
|
|
|
# install udev rules to where nix expects
|
|
|
|
substituteInPlace Makefile \
|
|
|
|
--replace "/usr/lib/udev/rules.d" "/etc/udev/rules.d"
|
|
|
|
# avoid relative paths in udev rules
|
|
|
|
substituteInPlace configs/udev/90-sxmo.rules \
|
|
|
|
--replace "/bin/chgrp" "${coreutils}/bin/chgrp" \
|
|
|
|
--replace "/bin/chmod" "${coreutils}/bin/chmod"
|
2023-10-08 17:12:53 +00:00
|
|
|
'' + lib.optionalString preferSystemd ''
|
2023-10-09 22:18:07 +00:00
|
|
|
shopt -s globstar
|
|
|
|
sed -i 's/superctl status "$1" | grep -q started/systemctl --user is-active --quiet "$1"/g' **/*.sh
|
2023-10-08 17:12:53 +00:00
|
|
|
sed -i 's/superctl/systemctl --user/g' **/*.sh
|
2023-08-28 09:26:30 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
nativeBuildInputs = [
|
|
|
|
makeBinaryWrapper
|
|
|
|
scdoc
|
|
|
|
];
|
|
|
|
|
|
|
|
buildInputs = [ bash ]; # needed here so stdenv's `patchShebangsAuto` hook sets the right interpreter
|
|
|
|
|
2023-08-29 07:59:43 +00:00
|
|
|
makeFlags = [
|
|
|
|
"PREFIX=${placeholder "out"}"
|
|
|
|
"SYSCONFDIR=${placeholder "out"}/etc"
|
|
|
|
"DESTDIR="
|
|
|
|
"OPENRC=0"
|
2023-10-11 01:30:43 +00:00
|
|
|
# TODO: use SERVICEDIR and EXTERNAL_SERVICES=0 to integrate superd/systemd better
|
2023-08-29 07:59:43 +00:00
|
|
|
];
|
2023-08-29 07:35:38 +00:00
|
|
|
preInstall = ''
|
2023-08-28 09:26:30 +00:00
|
|
|
# busybox is used by setup_config_version.sh, but placing it in nativeBuildInputs breaks the nix builder
|
2023-08-29 07:35:38 +00:00
|
|
|
PATH="$PATH:${buildPackages.busybox}/bin"
|
2023-08-28 09:26:30 +00:00
|
|
|
'';
|
|
|
|
|
|
|
|
# we don't wrap sxmo_common.sh or sxmo_init.sh
|
2023-08-29 07:35:38 +00:00
|
|
|
# which is unfortunate, for non-sxmo-utils files that might source those.
|
2023-08-28 09:26:30 +00:00
|
|
|
# if that's a problem, could inject a PATH=... line into them with sed.
|
|
|
|
postInstall = ''
|
|
|
|
for f in \
|
|
|
|
$out/bin/*.sh \
|
|
|
|
$out/share/sxmo/default_hooks/desktop/sxmo_hook_*.sh \
|
|
|
|
$out/share/sxmo/default_hooks/one_button_e_reader/sxmo_hook_*.sh \
|
|
|
|
$out/share/sxmo/default_hooks/three_button_touchscreen/sxmo_hook_*.sh \
|
|
|
|
$out/share/sxmo/default_hooks/sxmo_hook_*.sh \
|
|
|
|
; do
|
|
|
|
case $(basename $f) in
|
|
|
|
(sxmo_common.sh|sxmo_deviceprofile_*.sh|sxmo_hook_icons.sh|sxmo_init.sh)
|
2023-09-24 19:49:59 +00:00
|
|
|
# these are sourced by other scripts: don't wrap them else the `exec` in the nix wrapper breaks the outer script
|
2023-08-28 09:26:30 +00:00
|
|
|
;;
|
|
|
|
(*)
|
|
|
|
wrapProgram "$f" \
|
2023-10-09 00:08:57 +00:00
|
|
|
--suffix PATH : "${lib.makeBinPath runtimeDeps}"
|
2023-08-28 09:26:30 +00:00
|
|
|
;;
|
|
|
|
esac
|
|
|
|
done
|
|
|
|
'';
|
|
|
|
|
|
|
|
passthru = {
|
2023-10-08 17:12:53 +00:00
|
|
|
inherit runtimeDeps;
|
2023-09-24 19:49:59 +00:00
|
|
|
providedSessions = (lib.optional supportSway "swmo") ++ (lib.optional supportDwm "sxmo");
|
2023-08-28 09:26:30 +00:00
|
|
|
updateScript = gitUpdater { };
|
|
|
|
};
|
|
|
|
|
|
|
|
meta = {
|
|
|
|
homepage = "https://git.sr.ht/~mil/sxmo-utils";
|
|
|
|
description = "Contains the scripts and small C programs that glues the sxmo enviroment together";
|
|
|
|
license = lib.licenses.mit;
|
|
|
|
maintainers = with lib.maintainers; [ colinsane ];
|
|
|
|
platforms = lib.platforms.linux;
|
|
|
|
};
|
|
|
|
}
|