sxmo-utils: factor out commons and create a package for sxmo-utils-latest

This commit is contained in:
Colin 2023-08-28 09:26:30 +00:00
parent 02f409451d
commit e4e5df80f1
4 changed files with 250 additions and 278 deletions

View File

@ -1,58 +0,0 @@
commit bf0057011777b91ef5af005fb4e984b4b9b71c7b
Author: Colin <colin@uninsane.org>
Date: 2023-07-15 21:35:45 +0000
sxmo_wmmenu: respect SXMO_WORKSPACE_WRAPPING
sxmo_wm.sh uses the `SXMO_WORKSPACE_WRAPPING` variable to control
relative movements. for example, set this to "5" and then the "Next
Workspace" option in the switch menu will cycle WS 1 -> 2 ... -> 5 -> 1.
same for one- and two-finger left/right swipe to switch/move workspaces.
however, absolute movements (via the move menu) only allowed moving to
WS 1-4. a user with non-default `SXMO_WORKSPACE_WRAPPING` could move a
window from WS 5 to WS 4 with this menu, but not from WS 4 back to WS 5.
this patch brings consistency by using `SXMO_WORKSPACE_WRAPPING`
anywhere we would otherwise assume the number of possible workspaces.
diff --git a/scripts/core/sxmo_wmmenu.sh b/scripts/core/sxmo_wmmenu.sh
index 3d40b31..d3c1db6 100755
--- a/scripts/core/sxmo_wmmenu.sh
+++ b/scripts/core/sxmo_wmmenu.sh
@@ -12,6 +12,12 @@
set -e
+_movetowssubmenu() {
+ for ws in $(seq "${SXMO_WORKSPACE_WRAPPING:-4}"); do
+ printf "%s Move to WS %s\n" "$ws" "$ws"
+ done
+}
+
# A menu which allows to move windows or toggle floating.
swaymovemenu() {
CHOICES="$(cat <<EOF
@@ -22,10 +28,7 @@ $icon_arl Move Left
$icon_arr Move Right
$icon_wn2 Toggle Floating
$icon_ac1 Move Scratchpad
-1 Move to WS 1
-2 Move to WS 2
-3 Move to WS 3
-4 Move to WS 4
+$(_movetowssubmenu)
EOF
)"
@@ -125,10 +128,7 @@ dwmwmmenu() {
CHOICES="$(
cat <<EOF
$icon_cls Close Menu
-1 Move to WS 1
-2 Move to WS 2
-3 Move to WS 3
-4 Move to WS 4
+$(_movetowssubmenu)
$icon_rld Shift stack
$icon_grd Toggle Layout
EOF

View File

@ -0,0 +1,174 @@
{ stdenv
, bash
, bc
, bemenu
, bonsai
, brightnessctl
, buildPackages
, busybox
, conky
, coreutils
, curl
, dbus
, fetchgit
, fetchpatch
, gitUpdater
, gnugrep
, gojq
, grim
, inotify-tools
, j4-dmenu-desktop
, jq
, lib
, libnotify
, libxml2
, lisgd
, makeBinaryWrapper
, mako
, mepo
, modemmanager
, nettools
, playerctl
, procps
, pulseaudio
, rsync
, scdoc
, sfeed
, superd
, sway
, swayidle
, wob
, wvkbd
, xdg-user-dirs
, xdotool
, xrdb
, version
, rev ? version
, hash ? ""
, patches ? []
}:
let
# anything which any sxmo script or default hook in this package might invoke
runtimeDeps = [
bc # also in busybox
bemenu
bonsai
brightnessctl
conky
curl
dbus
# dmenu # or dmenu-wayland? only used on x11?
gnugrep # also in busybox
gojq
grim
inotify-tools
j4-dmenu-desktop
jq
libnotify
libxml2.bin # for xmllint; sxmo_weather.sh, sxmo_surf_linkset.sh
lisgd
mako
mepo # mepo_ui_central_menu.sh
modemmanager # mmcli
nettools # netstat
playerctl
procps # pgrep
pulseaudio # pactl
sfeed
superd
sway
swayidle
wob
wvkbd
xdg-user-dirs
xrdb # for sxmo_xinit AND sxmo_winit
# X11 only?
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
sed -i 's:ExecStart=/usr/bin/:ExecStart=/usr/bin/env :' configs/superd/services/*.service
# 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"
'';
nativeBuildInputs = [
makeBinaryWrapper
scdoc
];
buildInputs = [ bash ]; # needed here so stdenv's `patchShebangsAuto` hook sets the right interpreter
installPhase = ''
runHook preInstall
# busybox is used by setup_config_version.sh, but placing it in nativeBuildInputs breaks the nix builder
PATH="$PATH:${buildPackages.busybox}/bin" make OPENRC=0 DESTDIR=$out PREFIX= install
runHook postInstall
'';
# we don't wrap sxmo_common.sh or sxmo_init.sh
# which is unfortunate, for non-sxmo-utils files that might source though.
# 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)
# these are sourced by other scripts: don't wrap them else the `exec` in the wrapper breaks the outer script
;;
(*)
wrapProgram "$f" \
--prefix PATH : "${lib.makeBinPath runtimeDeps}"
;;
esac
done
'';
passthru = {
providedSessions = [ "sxmo" "swmo" ];
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;
};
}

View File

@ -1,226 +1,80 @@
{ stdenv
, bash
, bc
, bemenu
, bonsai
, brightnessctl
, buildPackages
, busybox
, conky
, coreutils
, curl
, dbus
, fetchgit
{ callPackage
, fetchpatch
, gitUpdater
, gnugrep
, gojq
, grim
, inotify-tools
, j4-dmenu-desktop
, jq
, lib
, libnotify
, libxml2
, lisgd
, makeBinaryWrapper
, mako
, mepo
, modemmanager
, nettools
, playerctl
, procps
, pulseaudio
, rsync
, scdoc
, sfeed
, superd
, sway
, swayidle
, wob
, wvkbd
, xdg-user-dirs
, xdotool
, xrdb
}:
let
# anything which any sxmo script or default hook in this package might invoke
runtimeDeps = [
bc # also in busybox
bemenu
bonsai
brightnessctl
conky
curl
dbus
# dmenu # or dmenu-wayland? only used on x11?
gnugrep # also in busybox
gojq
grim
inotify-tools
j4-dmenu-desktop
jq
libnotify
libxml2.bin # for xmllint; sxmo_weather.sh, sxmo_surf_linkset.sh
lisgd
mako
mepo # mepo_ui_central_menu.sh
modemmanager # mmcli
nettools # netstat
playerctl
procps # pgrep
pulseaudio # pactl
sfeed
superd
sway
swayidle
wob
wvkbd
xdg-user-dirs
xrdb # for sxmo_xinit AND sxmo_winit
# X11 only?
xdotool
];
in
stdenv.mkDerivation rec {
pname = "sxmo-utils";
version = "1.14.2";
src = fetchgit {
url = "https://git.sr.ht/~mil/sxmo-utils";
rev = version;
patches = {
merged = [
(fetchpatch {
# merged post 1.14.2
# [1/2] sxmo_init: behave well when user's primary group differs from their name
# [2/2] sxmo_init: ensure XDG_STATE_HOME exists
url = "https://lists.sr.ht/~mil/sxmo-devel/patches/42309/mbox";
hash = "sha256-GVWJWTccZeaKsVtsUyZFYl9/qEwJ5U7Bu+DiTDXLjys=";
})
(fetchpatch {
# merged post 1.14.2
# sxmo_hook_block_suspend: don't assume there's only one MPRIS player
url = "https://lists.sr.ht/~mil/sxmo-devel/patches/42441/mbox";
hash = "sha256-YmkJ4JLIG/mHosRlVQqvWzujFMBsuDf5nVT3iOi40zU=";
})
(fetchpatch {
# merged post 1.14.2
# i only care about patch no. 2
# [1/2] suspend toggle: silence rm failure noise
# [2/2] config: fix keyboard files location
name = "multipatch: 42880";
url = "https://lists.sr.ht/~mil/sxmo-devel/patches/42880/mbox";
hash = "sha256-tAMPBb6vwzj1dFMTEaqrcCJU6FbQirwZgB0+tqW3rQA=";
})
(fetchpatch {
# merged post 1.14.2
name = "Switch from light to brightnessctl";
url = "https://git.sr.ht/~mil/sxmo-utils/commit/d0384a7caed036d25228fa3279c36c0230795e4a.patch";
hash = "sha256-/UlcuEI5cJnsqRuZ1zWWzR4dyJw/zYeB1rtJWFeSGEE=";
})
(fetchpatch {
# merged post 1.14.2
name = "sxmo_hook_lock: allow configuration of auto-screenoff timeout v1";
url = "https://lists.sr.ht/~mil/sxmo-devel/patches/42443/mbox";
hash = "sha256-c4VySbVJgsbh2h+CnCgwWWe5WkAregpYFqL8n3WRXwY=";
})
(fetchpatch {
# merged post 1.14.2
name = "sxmo_wmmenu: respect SXMO_WORKSPACE_WRAPPING";
url = "https://lists.sr.ht/~mil/sxmo-devel/patches/42698/mbox";
hash = "sha256-TrTlrthrpYdIMC8/RCMNaB8PcGQgtya/h2/uLNQDeWs=";
})
];
unmerged = [
# let NixOS manage the audio daemons (pulseaudio/pipewire)
./0005-system-audio.patch
# (fetchpatch {
# XXX: doesn't apply cleanly to 1.14.2 release
# # Don't wait for led or status bar in state change hooks
# # - significantly decreases the time between power-button state transitions
# url = "https://lists.sr.ht/~mil/sxmo-devel/patches/43109/mbox";
# hash = "sha256-4uR2u6pa62y6SaRHYRn15YGDPILAs7py0mPbAjsgwM4=";
# })
(fetchpatch {
name = "Make config gesture toggle persistent";
url = "https://lists.sr.ht/~mil/sxmo-devel/patches/42876/mbox";
hash = "sha256-Oa0MI0Kt9Xgl5L1KarHI6Yn4+vpRxUSujB1iY4hlK9c=";
})
./0104-full-auto-rotate.patch
./0105-more-apps.patch
# ./0106-no-restart-lisgd.patch
];
};
in {
stable = callPackage ./common.nix {
version = "1.14.2";
hash = "sha256-1bGCUhf/bt9I8BjG/G7sjYBzLh28iZSC20ml647a3J4=";
patches = patches.merged ++ patches.unmerged;
};
patches = [
# needed for basic use:
(fetchpatch {
# merged post 1.14.2
# [1/2] sxmo_init: behave well when user's primary group differs from their name
# [2/2] sxmo_init: ensure XDG_STATE_HOME exists
url = "https://lists.sr.ht/~mil/sxmo-devel/patches/42309/mbox";
hash = "sha256-GVWJWTccZeaKsVtsUyZFYl9/qEwJ5U7Bu+DiTDXLjys=";
})
(fetchpatch {
# merged post 1.14.2
# sxmo_hook_block_suspend: don't assume there's only one MPRIS player
url = "https://lists.sr.ht/~mil/sxmo-devel/patches/42441/mbox";
hash = "sha256-YmkJ4JLIG/mHosRlVQqvWzujFMBsuDf5nVT3iOi40zU=";
})
(fetchpatch {
# merged post 1.14.2
# i only care about patch no. 2
# [1/2] suspend toggle: silence rm failure noise
# [2/2] config: fix keyboard files location
name = "multipatch: 42880";
url = "https://lists.sr.ht/~mil/sxmo-devel/patches/42880/mbox";
hash = "sha256-tAMPBb6vwzj1dFMTEaqrcCJU6FbQirwZgB0+tqW3rQA=";
})
(fetchpatch {
# merged post 1.14.2
name = "Switch from light to brightnessctl";
url = "https://git.sr.ht/~mil/sxmo-utils/commit/d0384a7caed036d25228fa3279c36c0230795e4a.patch";
hash = "sha256-/UlcuEI5cJnsqRuZ1zWWzR4dyJw/zYeB1rtJWFeSGEE=";
})
# wanted to fix/silence some non-fatal errors
./0005-system-audio.patch
./0007-workspace-wrapping.patch
# personal (but upstreamable) preferences:
(fetchpatch {
# merged post 1.14.2
name = "sxmo_hook_lock: allow configuration of auto-screenoff timeout v1";
url = "https://lists.sr.ht/~mil/sxmo-devel/patches/42443/mbox";
hash = "sha256-c4VySbVJgsbh2h+CnCgwWWe5WkAregpYFqL8n3WRXwY=";
})
# (fetchpatch {
# XXX: doesn't apply cleanly to 1.14.2 release
# # Don't wait for led or status bar in state change hooks
# # - significantly decreases the time between power-button state transitions
# url = "https://lists.sr.ht/~mil/sxmo-devel/patches/43109/mbox";
# hash = "sha256-4uR2u6pa62y6SaRHYRn15YGDPILAs7py0mPbAjsgwM4=";
# })
(fetchpatch {
name = "Make config gesture toggle persistent";
url = "https://lists.sr.ht/~mil/sxmo-devel/patches/42876/mbox";
hash = "sha256-Oa0MI0Kt9Xgl5L1KarHI6Yn4+vpRxUSujB1iY4hlK9c=";
})
./0104-full-auto-rotate.patch
./0105-more-apps.patch
# ./0106-no-restart-lisgd.patch
];
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
sed -i 's:ExecStart=/usr/bin/:ExecStart=/usr/bin/env :' configs/superd/services/*.service
# 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"
'';
nativeBuildInputs = [
makeBinaryWrapper
scdoc
];
buildInputs = [ bash ]; # needed here so stdenv's `patchShebangsAuto` hook sets the right interpreter
installPhase = ''
runHook preInstall
# busybox is used by setup_config_version.sh, but placing it in nativeBuildInputs breaks the nix builder
PATH="$PATH:${buildPackages.busybox}/bin" make OPENRC=0 DESTDIR=$out PREFIX= install
runHook postInstall
'';
# we don't wrap sxmo_common.sh or sxmo_init.sh
# which is unfortunate, for non-sxmo-utils files that might source though.
# 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)
# these are sourced by other scripts: don't wrap them else the `exec` in the wrapper breaks the outer script
;;
(*)
wrapProgram "$f" \
--prefix PATH : "${lib.makeBinPath runtimeDeps}"
;;
esac
done
'';
passthru = {
providedSessions = [ "sxmo" "swmo" ];
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;
latest = callPackage ./common.nix {
version = "unstable-2023-08-11";
rev = "095678e77fcd9ad2c1ed1ffc98fc66d2f19ccf64";
hash = "sha256-TGj3zcwW7aS/5KXcUt0jyESZcNqHY/JZ5HCTgT7Qsbk=";
patches = patches.unmerged;
};
}

View File

@ -55,7 +55,9 @@ let
sane-weather = callPackage ./additional/sane-weather { };
static-nix-shell = callPackage ./additional/static-nix-shell { };
sublime-music-mobile = callPackage ./additional/sublime-music-mobile { };
sxmo-utils = callPackage ./additional/sxmo-utils { };
sxmo-utils' = lib.recurseIntoAttrs (callPackage ./additional/sxmo-utils { });
sxmo-utils = sxmo-utils'.stable;
sxmo-utils-latest = sxmo-utils'.latest;
tow-boot-pinephone = callPackage ./additional/tow-boot-pinephone { };
tree-sitter-nix-shell = callPackage ./additional/tree-sitter-nix-shell { };
unftp = callPackage ./additional/unftp { };