Start migration to using flake-parts
This commit is contained in:
27
packages/acer-battery-health-mode/default.nix
Normal file
27
packages/acer-battery-health-mode/default.nix
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
writeShellApplication,
|
||||
kmod,
|
||||
}:
|
||||
writeShellApplication {
|
||||
name = "acer-battery-health-mode";
|
||||
|
||||
runtimeInputs = [kmod]; # contains insmod
|
||||
|
||||
text = ''
|
||||
#/usr/bin/env sh
|
||||
|
||||
# Using following tool https://github.com/frederik-h/acer-wmi-battery.git
|
||||
|
||||
PROJECT_LOCATION=~/git/acer-wmi-battery
|
||||
|
||||
if [ "$1" == "enable" ]; then
|
||||
sudo insmod "$PROJECT_LOCATION/acer-wmi-battery.ko" enable_health_mode=1
|
||||
echo "Battery health mode enabled"
|
||||
elif [ "$1" == "disable" ]; then
|
||||
sudo insmod "$PROJECT_LOCATION/acer-wmi-battery.ko" enable_health_mode=0
|
||||
echo "Battery health mode disabled"
|
||||
else
|
||||
echo "Please either state 'enable' or 'disable'"
|
||||
fi
|
||||
'';
|
||||
}
|
||||
41
packages/conda-direnv/default.nix
Normal file
41
packages/conda-direnv/default.nix
Normal file
@@ -0,0 +1,41 @@
|
||||
{
|
||||
conda,
|
||||
yq,
|
||||
writeShellApplication,
|
||||
}:
|
||||
writeShellApplication {
|
||||
name = "conda-direnv";
|
||||
|
||||
runtimeInputs = [
|
||||
conda
|
||||
yq
|
||||
];
|
||||
|
||||
text = ''
|
||||
if [ ! -f environment.yml ]; then
|
||||
echo "environment.yml does not exist! Exiting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
ENV_NAME=$(${yq}/bin/yq ".name" environment.yml -r)
|
||||
if [ "$ENV_NAME" == "" ] || [ "$ENV_NAME" == "null" ]; then
|
||||
echo "Property \"name\" not in environment.yml or empty! Exiting..."
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo Welcome to your conda environment "$ENV_NAME"! Activating...
|
||||
|
||||
condanew() {
|
||||
conda env create -f environment.yml -n $ENV_NAME
|
||||
conda activate $ENV_NAME
|
||||
}
|
||||
|
||||
exec ${conda}/bin/conda-shell
|
||||
conda activate $ENV_NAME || condanew
|
||||
|
||||
echo "Environment active! To update it, run:"
|
||||
echo -e "\tconda env update -f environment.yml -n $ENV_NAME"
|
||||
|
||||
"$SHELL" # needs to be last line so that conda-shell actually enters a shell
|
||||
'';
|
||||
}
|
||||
21
packages/default.nix
Normal file
21
packages/default.nix
Normal file
@@ -0,0 +1,21 @@
|
||||
{pkgs ? import <nixpkgs> {}, ...}: {
|
||||
conda-direnv = pkgs.callPackage ./conda-direnv {};
|
||||
deploy-to-pianopi = pkgs.callPackage ./deploy-to-pianopi {};
|
||||
edit-config = pkgs.callPackage ./edit-config {};
|
||||
hyprshot-gui = pkgs.callPackage ./hyprshot-gui {};
|
||||
install = pkgs.callPackage ./install {};
|
||||
lntocp = pkgs.callPackage ./lntocp {};
|
||||
open-messaging = pkgs.callPackage ./open-messaging {};
|
||||
pulseaudio-popup = pkgs.callPackage ./pulseaudio-popup {};
|
||||
sos = pkgs.callPackage ./sos {};
|
||||
xwacomcalibrate = pkgs.callPackage ./xwacomcalibrate {};
|
||||
acer-battery-health-mode = pkgs.callPackage ./acer-battery-health-mode {};
|
||||
pob2 = pkgs.callPackage ./pob2 {};
|
||||
wl-ocr = pkgs.callPackage ./wl-ocr {};
|
||||
rtklib = pkgs.qt6Packages.callPackage ./rtklib {};
|
||||
typst-languagetool = pkgs.callPackage ./typst-languagetool {};
|
||||
pob2-frajul = pkgs.callPackage ./pob2-frajul {};
|
||||
|
||||
# rpi-ws281x-python = pkgs.callPackage ./rpi-ws281x-python {};
|
||||
# piano-led-visualizer = pkgs.callPackage ./piano-led-visualizer {};
|
||||
}
|
||||
25
packages/deploy-to-pianopi/default.nix
Normal file
25
packages/deploy-to-pianopi/default.nix
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
rsync,
|
||||
writeShellApplication,
|
||||
}:
|
||||
writeShellApplication {
|
||||
name = "deploy-to-pianopi";
|
||||
|
||||
runtimeInputs = [rsync];
|
||||
|
||||
text = ''
|
||||
set -e
|
||||
set -x
|
||||
|
||||
nix build .#packages.aarch64-linux.default --print-out-paths
|
||||
# copy dependencies etc
|
||||
nix copy --to ssh://julian@pianopi.local .#packages.aarch64-linux.default
|
||||
|
||||
# This should be expanded on the client side
|
||||
# shellcheck disable=SC2029
|
||||
# ssh julian@pianopi.local ln -sf "$DERIVATION_PATH"/bin/\* /home/julian/.local/bin
|
||||
# ssh julian@pianopi.local nix profile install "$DERIVATION_PATH"
|
||||
|
||||
rsync -ac result/bin/ julian@pianopi.local:/home/julian/.local/bin
|
||||
'';
|
||||
}
|
||||
34
packages/edit-config/default.nix
Normal file
34
packages/edit-config/default.nix
Normal file
@@ -0,0 +1,34 @@
|
||||
{
|
||||
writeShellApplication,
|
||||
fd,
|
||||
fzf,
|
||||
}:
|
||||
writeShellApplication {
|
||||
name = "edit-config";
|
||||
|
||||
runtimeInputs = [
|
||||
fd
|
||||
fzf
|
||||
];
|
||||
|
||||
text = ''
|
||||
if [[ $# == 0 ]]; then
|
||||
QUERY=""
|
||||
else
|
||||
QUERY="$1"
|
||||
fi
|
||||
|
||||
FILE=$(fd -H -t f . ~/.dotfiles | fzf --query "$QUERY")
|
||||
if [[ "$FILE" != "" ]]; then
|
||||
$EDITOR "$FILE"
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
read -rp 'Run "home-manager switch"? [Yn]: ' yn
|
||||
case $yn in
|
||||
Y | y | Yes | yes | "" ) home-manager switch;;
|
||||
* ) echo "Not switching home-manager configuration";;
|
||||
esac
|
||||
'';
|
||||
}
|
||||
43
packages/hyprshot-gui/default.nix
Normal file
43
packages/hyprshot-gui/default.nix
Normal file
@@ -0,0 +1,43 @@
|
||||
{
|
||||
lib,
|
||||
stdenv,
|
||||
fetchFromGitHub,
|
||||
makeWrapper,
|
||||
bash,
|
||||
hyprshot,
|
||||
zenity,
|
||||
}:
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "hyprshot-gui";
|
||||
version = "2023-10-20";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "ThatOneCalculator";
|
||||
repo = pname;
|
||||
rev = "30a9bc377c1c0a3ad05c63945f2fe92709a99d7b";
|
||||
sha256 = "sha256-XUy6+mFbNL+3zDfS4tWva4DiJeLnRM9S8ECRayTcPfI=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [makeWrapper];
|
||||
|
||||
buildInputs = [
|
||||
bash
|
||||
hyprshot
|
||||
zenity
|
||||
];
|
||||
|
||||
dontBuild = true;
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
cp hyprshot-gui $out/bin/hyprshot-gui
|
||||
wrapProgram $out/bin/hyprshot-gui --prefix PATH : '${lib.makeBinPath buildInputs}'
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "A simple shell script";
|
||||
homepage = "https://github.com/ThatOneCalculator/hyprshot-gui";
|
||||
platforms = platforms.all;
|
||||
mainProgram = "hyprshot-gui";
|
||||
# maintainers
|
||||
};
|
||||
}
|
||||
31
packages/install/default.nix
Normal file
31
packages/install/default.nix
Normal file
@@ -0,0 +1,31 @@
|
||||
{
|
||||
writeShellScriptBin,
|
||||
gum,
|
||||
...
|
||||
}:
|
||||
# https://github.com/IogaMaster/dotfiles/blob/main/packages/install/default.nix
|
||||
writeShellScriptBin "install" ''
|
||||
${gum}/bin/gum style --border normal --margin "1" --padding "1 2" --border-foreground 212 "✨ IogaMaster's dotfiles installer ✨"
|
||||
echo "This script will wipe the remote system!"
|
||||
${gum}/bin/gum confirm "Cancel..." && exit
|
||||
|
||||
echo
|
||||
echo "🔥 kexec into the NixOS Installer..."
|
||||
ssh root@$2 'curl -L https://github.com/nix-community/nixos-images/releases/download/nixos-unstable/nixos-kexec-installer-noninteractive-x86_64-linux.tar.gz | tar -xzf- -C /root'
|
||||
ssh root@$2 '/root/kexec/run'
|
||||
|
||||
echo
|
||||
echo "⏰ Waiting for host nixos to come online..."
|
||||
while true; do ping -c1 nixos > /dev/null && break; done
|
||||
|
||||
echo
|
||||
echo "📥 Grabbing hardware config..."
|
||||
ssh root@nixos 'nixos-generate-config --show-hardware-config --root /mnt' > systems/x86_64-linux/$1/hardware-configuration.nix
|
||||
|
||||
echo
|
||||
echo "✅ Installing..."
|
||||
nix run github:nix-community/nixos-anywhere -- --flake .#$1 root@nixos
|
||||
|
||||
echo
|
||||
echo "✨ Done!!!"
|
||||
''
|
||||
58
packages/lntocp/default.nix
Normal file
58
packages/lntocp/default.nix
Normal file
@@ -0,0 +1,58 @@
|
||||
{writeShellApplication}:
|
||||
writeShellApplication {
|
||||
name = "lntocp";
|
||||
|
||||
runtimeInputs = [];
|
||||
|
||||
text = ''
|
||||
#!/bin/bash
|
||||
# This script accepts any number of files or directories as input.
|
||||
# If the input is a symbolic link, it deletes the symlink and copies
|
||||
# the original file or folder (where the symlink points to) to the location
|
||||
# where the symlink was. Non-symlink files or directories are ignored.
|
||||
|
||||
# Function to copy original file/folder in place of the symlink
|
||||
process_symlink() {
|
||||
symlink="$1"
|
||||
|
||||
# Resolve the target (the file or directory the symlink points to)
|
||||
target=$(readlink "$symlink")
|
||||
|
||||
# Check if the target is absolute or relative
|
||||
if [[ ! "$target" =~ ^/ ]]; then
|
||||
# If the target is relative, compute the full path
|
||||
target="$(dirname "$symlink")/$target"
|
||||
fi
|
||||
|
||||
# Check if the target exists
|
||||
if [ -e "$target" ]; then
|
||||
echo "Processing symlink: $symlink -> $target"
|
||||
|
||||
# Remove the symlink
|
||||
rm "$symlink"
|
||||
|
||||
# Copy the original target to the symlink location
|
||||
if [ -d "$target" ]; then
|
||||
# If it's a directory, use 'cp -r'
|
||||
cp -r "$target" "$symlink"
|
||||
else
|
||||
# Otherwise, it's a file, use 'cp'
|
||||
cp "$target" "$symlink"
|
||||
fi
|
||||
echo "Copied $target to $symlink"
|
||||
else
|
||||
echo "Target $target does not exist!"
|
||||
fi
|
||||
}
|
||||
|
||||
# Loop through all arguments (files and directories passed to the script)
|
||||
for item in "$@"; do
|
||||
if [ -L "$item" ]; then
|
||||
# If the item is a symlink, process it
|
||||
process_symlink "$item"
|
||||
else
|
||||
echo "$item is not a symlink. Skipping."
|
||||
fi
|
||||
done
|
||||
'';
|
||||
}
|
||||
27
packages/open-messaging/default.nix
Normal file
27
packages/open-messaging/default.nix
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
writeShellApplication,
|
||||
element-desktop,
|
||||
telegram-desktop,
|
||||
thunderbird,
|
||||
discord, # TODO: discord not available for aarch64, this leads to flake evaluation for this arch fail.
|
||||
}:
|
||||
writeShellApplication {
|
||||
name = "open-messaging";
|
||||
|
||||
runtimeInputs = [
|
||||
element-desktop
|
||||
telegram-desktop
|
||||
thunderbird
|
||||
discord
|
||||
];
|
||||
|
||||
text = ''
|
||||
thunderbird &
|
||||
sleep 0.1
|
||||
element-desktop &
|
||||
sleep 0.1
|
||||
Telegram &
|
||||
sleep 0.1
|
||||
discord &
|
||||
'';
|
||||
}
|
||||
63
packages/piano-led-visualizer/default.nix
Normal file
63
packages/piano-led-visualizer/default.nix
Normal file
@@ -0,0 +1,63 @@
|
||||
{
|
||||
lib,
|
||||
python3,
|
||||
callPackage,
|
||||
fetchFromGitHub,
|
||||
...
|
||||
}: let
|
||||
pythonPackages = python3.pkgs;
|
||||
rpi-ws281x-python = callPackage ../rpi-ws281x-python {inherit python3;};
|
||||
in
|
||||
pythonPackages.buildPythonApplication rec {
|
||||
pname = "piano-led-visualizer";
|
||||
version = "1.6";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "onlaj";
|
||||
repo = "Piano-LED-Visualizer";
|
||||
rev = "v${version}";
|
||||
sha256 = "sha256-SkNNu2pqVG40HBZZYJMCCKiRj1h1QdkteaPR3Ek2P7I=";
|
||||
};
|
||||
|
||||
patches = [
|
||||
./fix-log-dir.patch
|
||||
];
|
||||
|
||||
propagatedBuildInputs = with pythonPackages; [
|
||||
setuptools
|
||||
|
||||
numpy
|
||||
pillow
|
||||
flask
|
||||
rpi-gpio
|
||||
webcolors
|
||||
psutil
|
||||
mido
|
||||
rtmidi-python
|
||||
spidev
|
||||
waitress
|
||||
websockets
|
||||
werkzeug
|
||||
|
||||
rpi-ws281x-python
|
||||
];
|
||||
|
||||
format = "setuptools";
|
||||
|
||||
preBuild = ''
|
||||
cp ${./setup.py} setup.py
|
||||
sed -i 's/PLACEHOLDER_VERSION/${version}/' setup.py
|
||||
'';
|
||||
|
||||
postInstall = ''
|
||||
mv -v $out/bin/visualizer.py $out/bin/piano-led-visualizer
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "Piano LED Visualizer for Raspberry Pi";
|
||||
homepage = "https://github.com/onlaj/Piano-LED-Visualizer";
|
||||
license = licenses.gpl3;
|
||||
maintainers = [];
|
||||
platforms = platforms.linux;
|
||||
};
|
||||
}
|
||||
24
packages/piano-led-visualizer/fix-log-dir.patch
Normal file
24
packages/piano-led-visualizer/fix-log-dir.patch
Normal file
@@ -0,0 +1,24 @@
|
||||
diff --git a/lib/log_setup.py b/lib/log_setup.py
|
||||
index 34f9156..e164d14 100644
|
||||
--- a/lib/log_setup.py
|
||||
+++ b/lib/log_setup.py
|
||||
@@ -1,6 +1,7 @@
|
||||
import logging
|
||||
from logging.handlers import RotatingFileHandler
|
||||
import sys
|
||||
+import os
|
||||
|
||||
# Create a custom logger
|
||||
logger = logging.getLogger("my_app")
|
||||
@@ -10,7 +11,10 @@ logger.setLevel(logging.DEBUG)
|
||||
|
||||
# Create handlers
|
||||
console_handler = logging.StreamHandler()
|
||||
-file_handler = RotatingFileHandler('/home/Piano-LED-Visualizer/visualizer.log', maxBytes=500000, backupCount=10)
|
||||
+
|
||||
+log_path = os.path.expanduser('~/Piano-LED-Visualizer/visualizer.log')
|
||||
+os.makedirs(os.path.dirname(log_path), exist_ok=True)
|
||||
+file_handler = RotatingFileHandler(log_path, maxBytes=500000, backupCount=10)
|
||||
|
||||
|
||||
# Set the level for handlers
|
||||
24
packages/piano-led-visualizer/setup.py
Normal file
24
packages/piano-led-visualizer/setup.py
Normal file
@@ -0,0 +1,24 @@
|
||||
from setuptools import setup, find_packages
|
||||
|
||||
setup(
|
||||
name="piano_led_visualizer",
|
||||
version="PLACEHOLDER_VERSION",
|
||||
py_modules=["visualizer"],
|
||||
packages=find_packages(), # includes all packages with __init__.py
|
||||
install_requires=[
|
||||
"numpy",
|
||||
"pillow",
|
||||
"flask",
|
||||
"rpi-gpio",
|
||||
"webcolors",
|
||||
"psutil",
|
||||
"mido",
|
||||
"rtmidi",
|
||||
"spidev",
|
||||
"waitress",
|
||||
"websockets",
|
||||
"werkzeug",
|
||||
"rpi_ws281x",
|
||||
],
|
||||
scripts=["visualizer.py"],
|
||||
)
|
||||
16
packages/pob2-frajul/default.nix
Normal file
16
packages/pob2-frajul/default.nix
Normal file
@@ -0,0 +1,16 @@
|
||||
{
|
||||
writeShellApplication,
|
||||
xhost,
|
||||
}:
|
||||
writeShellApplication {
|
||||
name = "pob2-frajul";
|
||||
|
||||
runtimeInputs = [
|
||||
xhost
|
||||
];
|
||||
|
||||
text = ''
|
||||
xhost +
|
||||
sudo -u pob -i sh /home/pob/pob2.sh
|
||||
'';
|
||||
}
|
||||
88
packages/pob2/default.nix
Normal file
88
packages/pob2/default.nix
Normal file
@@ -0,0 +1,88 @@
|
||||
{
|
||||
pkgs,
|
||||
stdenv,
|
||||
lib,
|
||||
fetchFromGitHub,
|
||||
unzip,
|
||||
...
|
||||
}: let
|
||||
data = stdenv.mkDerivation (finalAttrs: {
|
||||
pname = "path-of-building-data";
|
||||
version = "dev-version";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "PathOfBuildingCommunity";
|
||||
repo = "PathOfBuilding-PoE2";
|
||||
rev = "3c579af5612d2137d37558d40d797801b5bbaa69";
|
||||
hash = "sha256-hRS4k2V9Ze6dc7BMA0iZxjCOZgqPa3Cu7gRZiVLrFR4=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [unzip];
|
||||
|
||||
buildCommand = ''
|
||||
# I have absolutely no idea how this file is generated
|
||||
# and I don't think I want to know. The Flatpak also does this.
|
||||
unzip -j -d $out $src/runtime-win32.zip lua/sha1.lua
|
||||
|
||||
# Install the actual data
|
||||
cp -r $src/src $src/runtime/lua/*.lua $src/manifest.xml $out
|
||||
|
||||
# Pretend this is an official build so we don't get the ugly "dev mode" warning
|
||||
substituteInPlace $out/manifest.xml --replace '<Version' '<Version platform="nixos"'
|
||||
touch $out/installed.cfg
|
||||
|
||||
# Completely stub out the update check
|
||||
chmod +w $out/src/UpdateCheck.lua
|
||||
echo 'return "none"' > $out/src/UpdateCheck.lua
|
||||
'';
|
||||
});
|
||||
in
|
||||
stdenv.mkDerivation {
|
||||
pname = "path-of-building-2";
|
||||
version = "${data.version}-unstable-2023-04-09";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "ernstp";
|
||||
repo = "pobfrontend";
|
||||
rev = "9faa19aa362f975737169824c1578d5011487c18";
|
||||
hash = "sha256-zhw2PZ6ZNMgZ2hG+a6AcYBkeg7kbBHNc2eSt4if17Wk=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
meson
|
||||
ninja
|
||||
pkg-config
|
||||
kdePackages.qttools
|
||||
kdePackages.wrapQtAppsHook
|
||||
];
|
||||
buildInputs = with pkgs; [
|
||||
kdePackages.qtbase
|
||||
luajit
|
||||
luajit.pkgs.lua-curl
|
||||
];
|
||||
|
||||
installPhase = ''
|
||||
runHook preInstall
|
||||
install -Dm555 pobfrontend $out/bin/pobfrontend
|
||||
runHook postInstall
|
||||
'';
|
||||
|
||||
preFixup = ''
|
||||
qtWrapperArgs+=(
|
||||
--set LUA_PATH "$LUA_PATH"
|
||||
--set LUA_CPATH "$LUA_CPATH"
|
||||
--chdir "${data}"
|
||||
)
|
||||
'';
|
||||
|
||||
passthru.data = data;
|
||||
|
||||
meta = {
|
||||
description = "Offline build planner for Path of Exile";
|
||||
homepage = "https://pathofbuilding.community/";
|
||||
license = lib.licenses.mit;
|
||||
maintainers = [lib.maintainers.k900];
|
||||
mainProgram = "pobfrontend";
|
||||
broken = stdenv.isDarwin; # doesn't find uic6 for some reason
|
||||
};
|
||||
}
|
||||
39
packages/pulseaudio-popup/default.nix
Normal file
39
packages/pulseaudio-popup/default.nix
Normal file
@@ -0,0 +1,39 @@
|
||||
{
|
||||
writeShellApplication,
|
||||
pavucontrol,
|
||||
jgmenu,
|
||||
pulseaudio,
|
||||
}:
|
||||
writeShellApplication {
|
||||
name = "pulseaudio-popup";
|
||||
|
||||
runtimeInputs = [
|
||||
pavucontrol
|
||||
jgmenu
|
||||
pulseaudio
|
||||
];
|
||||
|
||||
# Do not insert e.g. pipefail
|
||||
bashOptions = [];
|
||||
|
||||
text = ''
|
||||
HDMI_SINK="alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp_3__sink"
|
||||
LAPTOP_SINK="alsa_output.pci-0000_00_1f.3-platform-skl_hda_dsp_generic.HiFi__hw_sofhdadsp__sink"
|
||||
|
||||
HDMI_ICON=$(pactl info | grep -q $HDMI_SINK && echo "checkbox")
|
||||
LAPTOP_ICON=$(pactl info | grep -q $LAPTOP_SINK && echo "checkbox")
|
||||
|
||||
HDMI_VOLUME=$(pactl get-sink-volume $HDMI_SINK | head -n 1 | awk '{print $5}')
|
||||
LAPTOP_VOLUME=$(pactl get-sink-volume $LAPTOP_SINK | head -n 1 | awk '{print $5}')
|
||||
|
||||
read -r -d "" CONF <<EOF
|
||||
Open Pavucontrol,pavucontrol,pavucontrol
|
||||
|
||||
^sep()
|
||||
HDMI - $HDMI_VOLUME,pactl set-default-sink $HDMI_SINK,$HDMI_ICON
|
||||
Laptop - $LAPTOP_VOLUME,pactl set-default-sink $LAPTOP_SINK,$LAPTOP_ICON
|
||||
EOF
|
||||
|
||||
echo "$CONF" | jgmenu --simple --at-pointer
|
||||
'';
|
||||
}
|
||||
37
packages/rpi-ws281x-python/default.nix
Normal file
37
packages/rpi-ws281x-python/default.nix
Normal file
@@ -0,0 +1,37 @@
|
||||
{
|
||||
lib,
|
||||
python3,
|
||||
fetchFromGitHub,
|
||||
pkgs,
|
||||
}:
|
||||
python3.pkgs.buildPythonPackage rec {
|
||||
pname = "rpi-ws281x";
|
||||
version = "5.0.0";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "rpi-ws281x";
|
||||
repo = "rpi-ws281x-python";
|
||||
rev = "v${version}";
|
||||
sha256 = "sha256-CVPibDs1QLeXhtoEBw3JplKIIUpzahjgJKy8GVy99Wk=";
|
||||
fetchSubmodules = true;
|
||||
};
|
||||
|
||||
format = "setuptools";
|
||||
|
||||
propagatedBuildInputs = with python3.pkgs; [
|
||||
setuptools
|
||||
wheel
|
||||
];
|
||||
|
||||
postUnpack = ''
|
||||
sourceRoot="$sourceRoot/library"
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "Python bindings for the rpi_ws281x C library";
|
||||
homepage = "https://github.com/rpi-ws281x/rpi-ws281x-python";
|
||||
license = licenses.mit;
|
||||
maintainers = [];
|
||||
platforms = platforms.linux;
|
||||
};
|
||||
}
|
||||
40
packages/rtklib/default.nix
Normal file
40
packages/rtklib/default.nix
Normal file
@@ -0,0 +1,40 @@
|
||||
{
|
||||
stdenv,
|
||||
fetchFromGitHub,
|
||||
cmake,
|
||||
pkg-config,
|
||||
qtbase,
|
||||
wrapQtAppsHook,
|
||||
qtserialport,
|
||||
qttools,
|
||||
...
|
||||
}:
|
||||
stdenv.mkDerivation rec {
|
||||
pname = "RTKLIB";
|
||||
version = "b34L";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "rtklibexplorer";
|
||||
repo = "${pname}";
|
||||
rev = "${version}";
|
||||
hash = "sha256-bQcia3aRQNcZ55fvJViAxpo2Ev276HFTZ28SEXJD5Ds=";
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
cmake
|
||||
pkg-config
|
||||
wrapQtAppsHook
|
||||
];
|
||||
|
||||
buildInputs = [
|
||||
qtbase
|
||||
qtserialport
|
||||
qttools
|
||||
];
|
||||
|
||||
cmakeFlags = [
|
||||
"-DCMAKE_INSTALL_DATAROOTDIR=share"
|
||||
];
|
||||
|
||||
doCheck = true;
|
||||
}
|
||||
29
packages/sos/default.nix
Normal file
29
packages/sos/default.nix
Normal file
@@ -0,0 +1,29 @@
|
||||
{
|
||||
writeShellApplication,
|
||||
nix-output-monitor,
|
||||
jq,
|
||||
}:
|
||||
writeShellApplication {
|
||||
name = "sos";
|
||||
|
||||
runtimeInputs = [
|
||||
nix-output-monitor
|
||||
jq
|
||||
];
|
||||
|
||||
# TODO: somehow avoid --no-check-sigs??
|
||||
text = ''
|
||||
#!/usr/bin/env sh
|
||||
# This script performs a nixos system update using the remote builder as remote store.
|
||||
# This should improve the system update performance drastically
|
||||
|
||||
echo "########## building... ##########"
|
||||
OUT=$(nom build "$FLAKE#nixosConfigurations.$(hostname).config.system.build.toplevel" --store ssh-ng://nix@builder.julian-mutter.de --eval-store auto --json | jq -r '.[0].outputs.out')
|
||||
echo "########## output is: $OUT ##########"
|
||||
echo "########## downloading... ##########"
|
||||
nix copy --no-check-sigs --from ssh-ng://nix@builder.julian-mutter.de "$OUT"
|
||||
|
||||
echo "########## activating... ##########"
|
||||
sudo "$OUT"/bin/switch-to-configuration switch
|
||||
'';
|
||||
}
|
||||
27
packages/typst-languagetool/default.nix
Normal file
27
packages/typst-languagetool/default.nix
Normal file
@@ -0,0 +1,27 @@
|
||||
{
|
||||
rustPlatform,
|
||||
fetchFromGitHub,
|
||||
openssl,
|
||||
pkg-config,
|
||||
...
|
||||
}:
|
||||
rustPlatform.buildRustPackage {
|
||||
pname = "typst-languagetool";
|
||||
version = "0.1.0";
|
||||
|
||||
src = fetchFromGitHub {
|
||||
owner = "antonWetzel";
|
||||
repo = "typst-languagetool";
|
||||
rev = "b667a7ed94c8d671b23dd4ec018c58039277f0d6";
|
||||
sha256 = "sha256-sxE8mQW/bH58oZzamjxTQIcSjQh4FaYvrYfNJrnm8Io=";
|
||||
};
|
||||
|
||||
cargoHash = "sha256-80Dfpy2MB7ty841azRwBtA7hhO/yUXh2N4cvtrgTd2g=";
|
||||
|
||||
buildFeatures = ["server"];
|
||||
cargoBuildFlags = "-p cli";
|
||||
|
||||
# optional dependencies
|
||||
buildInputs = [openssl];
|
||||
nativeBuildInputs = [pkg-config];
|
||||
}
|
||||
18
packages/wl-ocr/default.nix
Normal file
18
packages/wl-ocr/default.nix
Normal file
@@ -0,0 +1,18 @@
|
||||
# from fufexan
|
||||
{
|
||||
writeShellScriptBin,
|
||||
lib,
|
||||
grim,
|
||||
libnotify,
|
||||
slurp,
|
||||
tesseract5,
|
||||
wl-clipboard,
|
||||
langs ? "eng+hun+fra+jpn+jpn_vert+kor+kor_vert+pol+ron+spa",
|
||||
}: let
|
||||
_ = lib.getExe;
|
||||
in
|
||||
writeShellScriptBin "wl-ocr" ''
|
||||
${_ grim} -g "$(${_ slurp})" -t ppm - | ${_ tesseract5} -l ${langs} - - | ${wl-clipboard}/bin/wl-copy
|
||||
echo "$(${wl-clipboard}/bin/wl-paste)"
|
||||
${_ libnotify} -- "$(${wl-clipboard}/bin/wl-paste)"
|
||||
''
|
||||
20
packages/xwacomcalibrate/default.nix
Normal file
20
packages/xwacomcalibrate/default.nix
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
writeShellApplication,
|
||||
xf86_input_wacom,
|
||||
xorg,
|
||||
xdotool,
|
||||
bc,
|
||||
}:
|
||||
writeShellApplication {
|
||||
name = "xwacomcalibrate";
|
||||
|
||||
runtimeInputs = [
|
||||
xf86_input_wacom
|
||||
xorg.xwininfo
|
||||
xorg.xrandr
|
||||
xdotool
|
||||
bc
|
||||
];
|
||||
|
||||
text = ./xwacomcalibrate.sh;
|
||||
}
|
||||
216
packages/xwacomcalibrate/xwacomcalibrate.sh
Executable file
216
packages/xwacomcalibrate/xwacomcalibrate.sh
Executable file
@@ -0,0 +1,216 @@
|
||||
#!/usr/bin/env bash
|
||||
|
||||
# https://aur.archlinux.org/packages/xwacomcalibrate
|
||||
|
||||
print_help () {
|
||||
printf "\nUsage: xwacomcalibrate [-h] [-d] [-f [screen]] [-r (cw | half | ccw)]\n\n"
|
||||
printf " h: prints this help\n"
|
||||
printf " d: Uses xdotool to continously run the script\n"
|
||||
printf " f: Uses whole X screen as window size. If xrandr screen name is given, limits itself to that monitor\n"
|
||||
printf " r: Chooses the device rotation. When given, needs either \"cw\" for clockwise, \"half\" for overhead, or \"ccw\" for counterclockwise as an argument\n"
|
||||
printf "\n"
|
||||
}
|
||||
|
||||
while getopts ":hdf:r:" opt
|
||||
do
|
||||
case $opt in
|
||||
h )
|
||||
print_help
|
||||
exit 0
|
||||
;;
|
||||
d )
|
||||
DAEMON=true
|
||||
;;
|
||||
f ) FULLSCREEN=true
|
||||
if [[ $OPTARG ]]
|
||||
then
|
||||
SCREEN=$OPTARG
|
||||
fi
|
||||
;;
|
||||
r ) if [[\
|
||||
$OPTARG == "cw"\
|
||||
|| $OPTARG == "half"\
|
||||
|| $OPTARG == "ccw"\
|
||||
]]
|
||||
then
|
||||
ROTATION=$OPTARG
|
||||
else
|
||||
echo "Invalid rotation: $arg" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
: ) if [[ $OPTARG == "r" ]]
|
||||
then
|
||||
echo 'option requires an argument -- ' $OPTARG 1>&2
|
||||
print_help
|
||||
exit 1
|
||||
fi
|
||||
;;
|
||||
\? ) print_help
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
done
|
||||
shift $(( OPTIND -1 ))
|
||||
|
||||
get_dev () {
|
||||
DEV=$(\
|
||||
xsetwacom --list devices\
|
||||
| grep "STYLUS"\
|
||||
| cut -d$'\t' -f 2\
|
||||
| tr -cd [:digit:]
|
||||
)
|
||||
if [[ ! $DEV ]]
|
||||
then
|
||||
echo "no device found"
|
||||
exit 1
|
||||
fi
|
||||
}
|
||||
|
||||
full_tablet_size () {
|
||||
xsetwacom --set $1 ResetArea
|
||||
TB_X=$( xsetwacom --get $1 Area | cut -d ' ' -f 1)
|
||||
TB_Y=$( xsetwacom --get $1 Area | cut -d ' ' -f 2)
|
||||
TB_WIDTH=$( xsetwacom --get $1 Area | cut -d ' ' -f 3)
|
||||
TB_HEIGHT=$( xsetwacom --get $1 Area | cut -d ' ' -f 4)
|
||||
}
|
||||
|
||||
set_rotation () {
|
||||
if [[ $2 ]]
|
||||
then
|
||||
xsetwacom --set $1 Rotate $2
|
||||
else
|
||||
xsetwacom --set $1 Rotate none
|
||||
fi
|
||||
}
|
||||
|
||||
set_output () {
|
||||
xsetwacom set $1 MapToOutput "${2}x${3}+${4}+${5}"
|
||||
}
|
||||
|
||||
set_area () {
|
||||
xsetwacom set $1 area "$2" "$3"\
|
||||
$( echo "$4 + $2" | bc )\
|
||||
$( echo "$5 + $3" | bc )
|
||||
}
|
||||
|
||||
get_x_screen_size () {
|
||||
W_X="0"
|
||||
W_Y="0"
|
||||
W_WIDTH=$( xwininfo -root | grep Width | tr -dc [:digit:])
|
||||
W_HEIGHT=$( xwininfo -root | grep Height | tr -dc [:digit:])
|
||||
}
|
||||
|
||||
get_screen_size () {
|
||||
local screen=$( xrandr -q | grep "$1 connected" | cut -d ' ' -f 3 )
|
||||
if [[ ! $screen ]]
|
||||
then
|
||||
echo "couldn't find screen: $1" 1>&2
|
||||
exit 1
|
||||
fi
|
||||
if [[ $screen == "primary" ]]
|
||||
then
|
||||
local screen=$( xrandr -q | grep "$1 connected" | cut -d ' ' -f 4 )
|
||||
fi
|
||||
IFS='x+' read -r -a array <<< "$screen"
|
||||
W_WIDTH="${array[0]}"
|
||||
W_HEIGHT="${array[1]}"
|
||||
W_X="${array[2]}"
|
||||
W_Y="${array[3]}"
|
||||
}
|
||||
|
||||
get_active_window_size () {
|
||||
W_X=$(\
|
||||
xdotool getactivewindow getwindowgeometry --shell\
|
||||
| grep X\
|
||||
| cut -d "=" -f2\
|
||||
)
|
||||
W_Y=$(\
|
||||
xdotool getactivewindow getwindowgeometry --shell\
|
||||
| grep Y\
|
||||
| cut -d "=" -f2\
|
||||
)
|
||||
W_WIDTH=$(\
|
||||
xdotool getactivewindow getwindowgeometry --shell\
|
||||
| grep WIDTH\
|
||||
| cut -d "=" -f2\
|
||||
)
|
||||
W_HEIGHT=$(\
|
||||
xdotool getactivewindow getwindowgeometry --shell\
|
||||
| grep HEIGHT\
|
||||
| cut -d "=" -f2\
|
||||
)
|
||||
}
|
||||
|
||||
calculate_new_tablet_size () {
|
||||
|
||||
if [[ $1 == "cw" || $1 == "ccw" ]]
|
||||
then
|
||||
twidth=$3
|
||||
theight=$2
|
||||
else
|
||||
twidth=$2
|
||||
theight=$3
|
||||
fi
|
||||
|
||||
tar=$( echo "scale=16; $twidth / $theight" | bc )
|
||||
war=$( echo "scale=16; $4 / $5" | bc )
|
||||
|
||||
if [[ $( echo "scale=16; $tar <= $war" | bc ) -eq "1" ]]
|
||||
then
|
||||
theight=$( echo "scale=0; $twidth / $war /1" | bc )
|
||||
else
|
||||
twidth=$( echo "scale=0; $theight * $war /1" | bc )
|
||||
fi
|
||||
|
||||
if [[ $1 == "cw" || $1 == "ccw" ]]
|
||||
then
|
||||
tmp=$twidth
|
||||
twidth=$theight
|
||||
theight=$tmp
|
||||
unset tmp
|
||||
fi
|
||||
|
||||
TB_X=$( echo "scale=0; ($TB_WIDTH - $twidth) / 2" | bc )
|
||||
TB_Y=$( echo "scale=0; ($TB_HEIGHT - $theight) / 2" | bc )
|
||||
|
||||
TB_WIDTH=$twidth
|
||||
TB_HEIGHT=$theight
|
||||
}
|
||||
|
||||
main () {
|
||||
get_dev
|
||||
set_rotation "$DEV" "$ROTATION"
|
||||
full_tablet_size "$DEV"
|
||||
if [[ $FULLSCREEN ]]
|
||||
then
|
||||
if [[ $SCREEN ]]
|
||||
then
|
||||
get_screen_size "$SCREEN"
|
||||
else
|
||||
get_x_screen_size
|
||||
fi
|
||||
else
|
||||
get_active_window_size
|
||||
fi
|
||||
calculate_new_tablet_size "$ROTATION"\
|
||||
"$TB_WIDTH" "$TB_HEIGHT"\
|
||||
"$W_WIDTH" "$W_HEIGHT"
|
||||
set_output "$DEV" "$W_WIDTH" "$W_HEIGHT" "$W_X" "$W_Y"
|
||||
set_area "$DEV" "$TB_X" "$TB_Y" "$TB_WIDTH" "$TB_HEIGHT"
|
||||
echo "${W_WIDTH}x${W_HEIGHT}+${W_X}+${W_Y} \
|
||||
${TB_WIDTH}x${TB_HEIGHT}+${TB_X}+${TB_Y} $ROTATIONATION"
|
||||
}
|
||||
|
||||
if [[ $DAEMON ]]
|
||||
then
|
||||
main
|
||||
xdotool search . behave %@ focus exec --sync\
|
||||
$(\
|
||||
echo 'xwacomcalibrate '\
|
||||
$( if [[ $ROTATION ]]; then echo '-r ' $ROTATION ; fi )\
|
||||
$( if [[ $FULLSCREEN ]]; then echo '-f'; fi )\
|
||||
)
|
||||
else
|
||||
main
|
||||
fi
|
||||
Reference in New Issue
Block a user