This repository has no description
0

Configure Feed

Select the types of activity you want to include in your feed.

tools: remove unused nnn, boosteroid, yt-x, herd, gh-act, vm-boot, build-installer-iso

-1145
-10
tools/boosteroid/flake-module.nix
··· 1 - { 2 - perSystem = 3 - { pkgs, ... }: 4 - let 5 - boosteroid = pkgs.callPackage ./package.nix { }; 6 - in 7 - { 8 - packages.boosteroid = boosteroid; 9 - }; 10 - }
-113
tools/boosteroid/package.nix
··· 1 - { 2 - lib, 3 - stdenv, 4 - fetchurl, 5 - buildFHSEnv, 6 - writeShellScript, 7 - # runtime deps 8 - alsa-lib, 9 - dbus, 10 - fontconfig, 11 - freetype, 12 - libGL, 13 - libX11, 14 - libxcb, 15 - libXfixes, 16 - libXi, 17 - libva, 18 - libvdpau, 19 - libxkbcommon, 20 - numactl, 21 - pcre2, 22 - pulseaudio, 23 - systemd, 24 - wayland, 25 - xcb-util-cursor, 26 - libxrender, 27 - libxcb-util, 28 - libxcb-image, 29 - libxcb-keysyms, 30 - libxcb-render-util, 31 - libxcb-wm, 32 - }: 33 - 34 - let 35 - pname = "boosteroid"; 36 - version = "1.0.0"; 37 - 38 - src = fetchurl { 39 - url = "https://boosteroid.com/linux/installer/boosteroid_portable.tar"; 40 - hash = "sha256-R4s3nA9YyaNovO04Dv9svq7Z/y9JyRLIFfL4TVFkjqo="; 41 - curlOptsList = [ 42 - "--user-agent" 43 - "Mozilla/5.0" 44 - ]; 45 - }; 46 - 47 - unwrapped = stdenv.mkDerivation { 48 - inherit pname version src; 49 - sourceRoot = "."; 50 - unpackCmd = "tar xf $curSrc"; 51 - installPhase = '' 52 - install -Dm755 Boosteroid $out/bin/Boosteroid 53 - ''; 54 - }; 55 - in 56 - buildFHSEnv { 57 - name = "boosteroid"; 58 - pname = "boosteroid"; 59 - inherit version; 60 - 61 - targetPkgs = _: [ 62 - unwrapped 63 - alsa-lib 64 - dbus 65 - fontconfig 66 - freetype 67 - libGL 68 - libX11 69 - libxcb 70 - libXfixes 71 - libXi 72 - libva 73 - libvdpau 74 - libxkbcommon 75 - numactl 76 - pcre2 77 - pulseaudio 78 - systemd # libudev 79 - wayland 80 - xcb-util-cursor 81 - libxrender 82 - libxcb-util 83 - libxcb-image 84 - libxcb-keysyms 85 - libxcb-render-util 86 - libxcb-wm 87 - ]; 88 - 89 - runScript = writeShellScript "boosteroid-wrapper" '' 90 - dir="''${XDG_DATA_HOME:-$HOME/.local/share}/boosteroid" 91 - mkdir -p "$dir" 92 - # Boosteroid writes logs next to its binary (via /proc/self/exe), 93 - # so we copy it to a writable directory 94 - bin="$(command -v Boosteroid)" 95 - if [ ! -x "$dir/Boosteroid" ] || ! cmp -s "$bin" "$dir/Boosteroid"; then 96 - cp "$bin" "$dir/Boosteroid" 97 - chmod +x "$dir/Boosteroid" 98 - fi 99 - cd "$dir" 100 - exec "$dir/Boosteroid" "$@" 101 - ''; 102 - 103 - passthru.updateScript = ./update.sh; 104 - 105 - meta = { 106 - description = "Boosteroid cloud gaming client"; 107 - homepage = "https://boosteroid.com"; 108 - # proprietary but freely downloadable, using lib.licenses.free to avoid --impure 109 - license = lib.licenses.free; 110 - platforms = [ "x86_64-linux" ]; 111 - mainProgram = "boosteroid"; 112 - }; 113 - }
-24
tools/boosteroid/update.sh
··· 1 - #!/usr/bin/env bash 2 - set -euo pipefail 3 - 4 - url="https://boosteroid.com/linux/installer/boosteroid_portable.tar" 5 - # Run by update-pkgs from the flake root ($0 is a read-only store copy). 6 - pkg=tools/boosteroid/package.nix 7 - 8 - old_hash=$(grep -oP 'hash = "\K[^"]+' "$pkg") 9 - 10 - tmpfile=$(mktemp) 11 - trap 'rm -f "$tmpfile"' EXIT 12 - 13 - curl -fsSL -A "Mozilla/5.0" -o "$tmpfile" "$url" 14 - new_hash=$(nix hash file --sri "$tmpfile") 15 - 16 - if [ "$old_hash" = "$new_hash" ]; then 17 - echo "boosteroid: already up to date ($old_hash)" 18 - exit 0 19 - fi 20 - 21 - echo "boosteroid: updating hash" 22 - echo " old: $old_hash" 23 - echo " new: $new_hash" 24 - sed -i "s|$old_hash|$new_hash|" "$pkg"
-149
tools/build-installer-iso/build-installer-iso.sh
··· 1 - #!/usr/bin/env bash 2 - set -euo pipefail 3 - set -x 4 - 5 - # Default values 6 - OUTPUT="installer.iso" 7 - ARCH="x86_64-linux" # Default to x86_64-linux for cross-compilation 8 - CONFIG_DIR="" 9 - FLAKE_URL="" 10 - 11 - usage() { 12 - cat <<EOF 13 - Usage: $0 [OPTIONS] 14 - 15 - Build a NixOS installer ISO with custom configuration. 16 - 17 - OPTIONS: 18 - -o, --output FILE Output ISO file (default: installer.iso) 19 - -a, --arch ARCH Architecture: x86_64-linux or aarch64-linux (default: x86_64-linux) 20 - -c, --config DIR Configuration directory containing installer-config.json and files/ 21 - -f, --flake URL Flake URL to install automatically (creates minimal config) 22 - -h, --help Show this help message 23 - 24 - EXAMPLES: 25 - $0 -o my-installer.iso -f github:user/nixos-config 26 - $0 -o my-installer.iso -c ./installer-config 27 - 28 - Configuration Directory Structure: 29 - installer-config/ 30 - ├── installer-config.json # Configuration file 31 - └── files/ # Files to copy to target system 32 - ├── etc/ 33 - │ └── resolv.conf # Gets copied to /etc/resolv.conf 34 - └── root/ 35 - └── .ssh/ 36 - └── authorized_keys # Gets copied to /root/.ssh/authorized_keys 37 - 38 - JSON Configuration Format: 39 - { 40 - "flakeUrl": "github:user/nixos-config", 41 - "fileMetadata": { 42 - "/etc/resolv.conf": { 43 - "owner": "root:root", 44 - "permissions": "644" 45 - }, 46 - "/root/.ssh/authorized_keys": { 47 - "owner": "root:root", 48 - "permissions": "600" 49 - } 50 - } 51 - } 52 - 53 - Default file metadata: owner=root:root, permissions=400 54 - EOF 55 - } 56 - 57 - # Parse arguments 58 - while [[ $# -gt 0 ]]; do 59 - case $1 in 60 - -o|--output) 61 - OUTPUT="$2" 62 - shift 2 63 - ;; 64 - -a|--arch) 65 - ARCH="$2" 66 - shift 2 67 - ;; 68 - -c|--config) 69 - CONFIG_DIR="$2" 70 - shift 2 71 - ;; 72 - -f|--flake) 73 - FLAKE_URL="$2" 74 - shift 2 75 - ;; 76 - -h|--help) 77 - usage 78 - exit 0 79 - ;; 80 - *) 81 - echo "Unknown option: $1" 82 - usage 83 - exit 1 84 - ;; 85 - esac 86 - done 87 - 88 - # Build the base ISO 89 - echo "Building base ISO for $ARCH..." 90 - BASE_ISO=$(nix build -L --no-link --print-out-paths "$FLAKE_ROOT#nixosConfigurations.installer-$ARCH.config.system.build.images.iso-installer") 91 - 92 - # Determine what to append to the ISO 93 - if [ -n "$FLAKE_URL" ]; then 94 - # Create minimal config for flake URL 95 - echo "Creating minimal configuration for flake URL: $FLAKE_URL" 96 - TEMP_CONFIG_DIR=$(mktemp -d) 97 - trap 'rm -rf "$TEMP_CONFIG_DIR"' EXIT 98 - 99 - cat > "$TEMP_CONFIG_DIR/installer-config.json" <<EOF 100 - { 101 - "flakeUrl": "$FLAKE_URL" 102 - } 103 - EOF 104 - 105 - echo "Appending flake configuration to ISO..." 106 - xorriso \ 107 - -indev "$BASE_ISO"/iso/*.iso \ 108 - -outdev "$OUTPUT" \ 109 - -boot_image any replay \ 110 - -map "$TEMP_CONFIG_DIR/installer-config.json" /installer-config.json \ 111 - -commit_eject all 112 - 113 - elif [ -n "$CONFIG_DIR" ]; then 114 - # Use provided configuration directory 115 - echo "Appending configuration from $CONFIG_DIR to ISO..." 116 - 117 - if [ ! -d "$CONFIG_DIR" ]; then 118 - echo "Error: Configuration directory '$CONFIG_DIR' not found" 119 - exit 1 120 - fi 121 - 122 - # Build xorriso command with all necessary mappings 123 - XORRISO_ARGS=( 124 - -indev "$BASE_ISO"/iso/*.iso 125 - -outdev "$OUTPUT" 126 - -boot_image any replay 127 - ) 128 - 129 - # Add installer-config.json if it exists 130 - if [ -f "$CONFIG_DIR/installer-config.json" ]; then 131 - XORRISO_ARGS+=(-map "$CONFIG_DIR/installer-config.json" /installer-config.json) 132 - fi 133 - 134 - # Add files directory if it exists 135 - if [ -d "$CONFIG_DIR/files" ]; then 136 - XORRISO_ARGS+=(-map "$CONFIG_DIR/files" /files) 137 - fi 138 - 139 - XORRISO_ARGS+=(-commit_eject all) 140 - 141 - xorriso "${XORRISO_ARGS[@]}" 142 - 143 - else 144 - # No configuration specified, just copy the base ISO 145 - echo "No configuration specified, copying base ISO..." 146 - cp "$BASE_ISO"/iso/*.iso "$OUTPUT" 147 - fi 148 - 149 - echo "ISO created: $OUTPUT"
-187
tools/build-installer-iso/flake-module.nix
··· 1 - { self, ... }: 2 - let 3 - # Shared installer configuration module 4 - installerModule = 5 - { modulesPath, pkgs, ... }: 6 - { 7 - imports = [ 8 - (modulesPath + "/image/images.nix") 9 - ]; 10 - 11 - # Basic installer configuration 12 - networking.hostName = "installer"; 13 - 14 - # Enable emergency access in initrd for debugging 15 - boot.initrd.systemd.emergencyAccess = true; 16 - 17 - # Enable serial console for VM usage 18 - boot.kernelParams = [ 19 - "console=ttyS0,115200n8" 20 - "console=tty0" 21 - ]; 22 - 23 - # Configure systemd for serial console 24 - systemd.services."serial-getty@ttyS0" = { 25 - enable = true; 26 - wantedBy = [ "getty.target" ]; 27 - serviceConfig.Restart = "always"; 28 - }; 29 - 30 - # Process installer configuration from ISO during system activation 31 - system.activationScripts.installer-config = { 32 - text = '' 33 - echo "Processing installer configuration from ISO..." 34 - 35 - # Find the ISO device (usually sr0, but could be others) 36 - ISO_DEVICE="" 37 - for dev in /dev/sr*; do 38 - if [ -b "$dev" ]; then 39 - ISO_DEVICE="$dev" 40 - break 41 - fi 42 - done 43 - 44 - if [ -z "$ISO_DEVICE" ]; then 45 - echo "No ISO device found, checking loop devices..." 46 - for dev in /dev/loop*; do 47 - if [ -b "$dev" ] && ${pkgs.util-linux}/bin/lsblk -no FSTYPE "$dev" 2>/dev/null | ${pkgs.gnugrep}/bin/grep -q iso9660; then 48 - ISO_DEVICE="$dev" 49 - break 50 - fi 51 - done 52 - fi 53 - 54 - if [ -n "$ISO_DEVICE" ]; then 55 - echo "Found ISO device: $ISO_DEVICE" 56 - mkdir -p /mnt/iso 57 - if ${pkgs.util-linux}/bin/mount -t iso9660 -o ro "$ISO_DEVICE" /mnt/iso; then 58 - echo "Successfully mounted ISO" 59 - 60 - # Check for installer configuration 61 - if [ -f /mnt/iso/installer-config.json ]; then 62 - echo "Found installer configuration" 63 - CONFIG_FILE="/mnt/iso/installer-config.json" 64 - 65 - # Process flake URL if present 66 - FLAKE_URL=$(${pkgs.jq}/bin/jq -r '.flakeUrl // empty' "$CONFIG_FILE" || true) 67 - if [ -n "$FLAKE_URL" ]; then 68 - echo "Flake URL configured: $FLAKE_URL" 69 - # Store for later installation 70 - mkdir -p /var/lib 71 - echo "$FLAKE_URL" > /var/lib/installer-flake-url 72 - fi 73 - 74 - # Process files from file structure 75 - if [ -d /mnt/iso/files ]; then 76 - echo "Processing files from file structure..." 77 - 78 - # Copy all files from the files directory, preserving structure 79 - ${pkgs.findutils}/bin/find /mnt/iso/files -type f | while read -r source_file; do 80 - # Remove /mnt/iso/files prefix to get target path 81 - target_path="''${source_file#/mnt/iso/files}" 82 - echo "Copying file: $source_file -> $target_path" 83 - 84 - # Create target directory 85 - mkdir -p "$(dirname "$target_path")" 86 - 87 - # Copy the file 88 - ${pkgs.coreutils}/bin/cp "$source_file" "$target_path" 89 - 90 - # Apply metadata from JSON if present 91 - if ${pkgs.jq}/bin/jq -e ".fileMetadata[\"$target_path\"]" "$CONFIG_FILE" >/dev/null 2>&1; then 92 - # Extract metadata for this file 93 - OWNER=$(${pkgs.jq}/bin/jq -r ".fileMetadata[\"$target_path\"].owner // \"root:root\"" "$CONFIG_FILE") 94 - PERMS=$(${pkgs.jq}/bin/jq -r ".fileMetadata[\"$target_path\"].permissions // \"400\"" "$CONFIG_FILE") 95 - 96 - echo "Setting owner: $OWNER, permissions: $PERMS for $target_path" 97 - ${pkgs.coreutils}/bin/chown "$OWNER" "$target_path" || echo "Warning: failed to set owner $OWNER" 98 - ${pkgs.coreutils}/bin/chmod "$PERMS" "$target_path" || echo "Warning: failed to set permissions $PERMS" 99 - else 100 - # Apply defaults: root:root, 400 101 - echo "Applying default metadata for $target_path" 102 - ${pkgs.coreutils}/bin/chown root:root "$target_path" || echo "Warning: failed to set default owner" 103 - ${pkgs.coreutils}/bin/chmod 400 "$target_path" || echo "Warning: failed to set default permissions" 104 - fi 105 - done 106 - fi 107 - 108 - else 109 - echo "No installer configuration found in ISO" 110 - fi 111 - 112 - ${pkgs.util-linux}/bin/umount /mnt/iso 113 - else 114 - echo "Failed to mount ISO device $ISO_DEVICE" 115 - fi 116 - else 117 - echo "No ISO device found" 118 - fi 119 - ''; 120 - deps = [ ]; 121 - }; 122 - 123 - # Service to install from flake URL if configured 124 - systemd.services.installer-flake-install = { 125 - description = "Install NixOS from configured flake URL"; 126 - wantedBy = [ "multi-user.target" ]; 127 - after = [ 128 - "installer-config.service" 129 - "network-online.target" 130 - ]; 131 - wants = [ "network-online.target" ]; 132 - path = with pkgs; [ 133 - git 134 - nix 135 - coreutils 136 - ]; 137 - serviceConfig = { 138 - Type = "oneshot"; 139 - RemainAfterExit = true; 140 - }; 141 - script = '' 142 - set -euo pipefail 143 - 144 - if [ -f /var/lib/installer-flake-url ]; then 145 - FLAKE_URL=$(cat /var/lib/installer-flake-url) 146 - echo "Installing from flake: $FLAKE_URL" 147 - 148 - # TODO: Add actual installation logic here 149 - # This would typically involve: 150 - # 1. Partitioning disks 151 - # 2. Mounting filesystems 152 - # 3. Running nixos-install with the flake 153 - echo "Installation from flake not yet implemented" 154 - echo "Flake URL: $FLAKE_URL" 155 - else 156 - echo "No flake URL configured for automatic installation" 157 - fi 158 - ''; 159 - }; 160 - }; 161 - in 162 - { 163 - flake = { 164 - # Export the installer module for reuse 165 - nixosModules.installer = installerModule; 166 - }; 167 - 168 - perSystem = 169 - { pkgs, ... }: 170 - { 171 - packages.build-installer-iso = 172 - (pkgs.writeShellApplication { 173 - name = "build-installer-iso"; 174 - runtimeInputs = with pkgs; [ 175 - xorriso 176 - coreutils 177 - nix 178 - ]; 179 - text = '' 180 - # Export flake root for the script to use 181 - export FLAKE_ROOT="${self}" 182 - ${builtins.readFile ./build-installer-iso.sh} 183 - ''; 184 - }).overrideAttrs 185 - { passthru.usage = builtins.readFile ./usage.kdl; }; 186 - }; 187 - }
-8
tools/build-installer-iso/usage.kdl
··· 1 - bin "build-installer-iso" 2 - about "Build a NixOS installer ISO with custom configuration" 3 - 4 - flag "-o --output <file>" help="Output ISO file (default: installer.iso)" 5 - flag "-a --arch <arch>" help="Architecture: x86_64-linux or aarch64-linux (default: x86_64-linux)" 6 - flag "-c --config <dir>" help="Configuration directory containing installer-config.json and files/" 7 - flag "-f --flake <url>" help="Flake URL to install automatically" 8 - flag "-h --help" help="Show help message"
-45
tools/gh-act/flake-module.nix
··· 1 - { ... }: 2 - { 3 - perSystem = 4 - { pkgs, ... }: 5 - { 6 - packages.gh-act = 7 - (pkgs.writeShellApplication { 8 - name = "gh-act"; 9 - runtimeInputs = with pkgs; [ 10 - yq 11 - coreutils 12 - ]; 13 - text = '' 14 - workflow="''${1:-.github/workflows/ci.yml}" 15 - 16 - if [ ! -f "$workflow" ]; then 17 - echo "Usage: gh-act [workflow.yml]" 18 - echo "Run GitHub Actions workflow steps locally" 19 - exit 1 20 - fi 21 - 22 - echo "Running: $workflow" 23 - echo "==================" 24 - 25 - # Extract each step and run it 26 - for job in $(yq -r '.jobs | keys[]' "$workflow"); do 27 - echo "=== Job: $job ===" 28 - step_count=$(yq -r ".jobs[\"$job\"].steps | length" "$workflow") 29 - for i in $(seq 0 $((step_count - 1))); do 30 - name=$(yq -r ".jobs[\"$job\"].steps[$i].name // \"Step $i\"" "$workflow") 31 - run_cmd=$(yq -r ".jobs[\"$job\"].steps[$i].run // empty" "$workflow") 32 - 33 - if [ -n "$run_cmd" ]; then 34 - echo ">>> Running: $name" 35 - echo "---" 36 - bash -c "$run_cmd" 37 - echo 38 - fi 39 - done 40 - done 41 - ''; 42 - }).overrideAttrs 43 - { passthru.usage = builtins.readFile ./usage.kdl; }; 44 - }; 45 - }
-4
tools/gh-act/usage.kdl
··· 1 - bin "gh-act" 2 - about "Run GitHub Actions workflow steps locally" 3 - 4 - arg "[workflow]" help="Path to workflow YAML file (default: .github/workflows/ci.yml)"
-48
tools/herd/flake-module.nix
··· 1 - { inputs, ... }: 2 - { 3 - perSystem = 4 - { pkgs, system, ... }: 5 - { 6 - # Start an omp agent in a new herdr tab from one command: 7 - # s herd 'fix issue #13' --model opus 8 - # Everything is passed through to omp, so any omp flag works. The tab 9 - # lands in the focused workspace (one is created from $PWD if there is 10 - # none). By default it is not focused, so the caller's pane stays put; 11 - # `-f`/`--focus` (before the prompt) switches to the new pane instead. 12 - # herdr picks the agent up by itself; name it with 13 - # `herdr agent rename <pane> <name>` if you want to address it by name 14 - # afterwards. 15 - packages.herd = 16 - (pkgs.writeShellApplication { 17 - name = "herd"; 18 - runtimeInputs = [ 19 - inputs.llm-agents.packages.${system}.herdr 20 - pkgs.jq 21 - ]; 22 - text = '' 23 - focus=--no-focus 24 - case "''${1:-}" in 25 - -f|--focus) 26 - focus=--focus 27 - shift 28 - ;; 29 - esac 30 - # Not $HERDR_WORKSPACE_ID: that is the launch-time value and goes 31 - # stale once the pane is moved to another workspace (herdr keeps 32 - # the old pane id as an alias, so `pane current` still resolves). 33 - workspace=$(herdr pane current 2>/dev/null | jq -r '.result.pane.workspace_id // empty') 34 - [ -n "$workspace" ] || workspace=$(herdr workspace list | jq -r '.result.workspaces[] | select(.focused) | .workspace_id') 35 - label=$(printf '%s' "''${1:-omp}" | cut -c1-32) 36 - if [ -n "$workspace" ]; then 37 - created=$(herdr tab create --workspace "$workspace" --cwd "$PWD" --label "$label" "$focus") 38 - else 39 - created=$(herdr workspace create --cwd "$PWD" --label "$(basename "$PWD")" "$focus") 40 - fi 41 - pane=$(printf '%s' "$created" | jq -er .result.root_pane.pane_id) 42 - herdr pane run "$pane" "${pkgs.omp}/bin/omp$(printf ' %q' "$@")" >/dev/null 43 - echo "$pane" 44 - ''; 45 - }).overrideAttrs 46 - { passthru.usage = builtins.readFile ./usage.kdl; }; 47 - }; 48 - }
-7
tools/herd/usage.kdl
··· 1 - bin "herd" 2 - about "Start an omp agent in a new herdr tab (current workspace, current directory) and print its pane id" 3 - 4 - flag "-f --focus" help="Switch to the new pane instead of staying in the current one (must come before the prompt)" 5 - 6 - arg "[prompt]" help="First message for omp" 7 - arg "[omp-args...]" help="Arguments passed through to omp, e.g. --model opus"
-213
tools/nnn/flake-module.nix
··· 1 - { inputs, ... }: 2 - { 3 - perSystem = 4 - { pkgs, lib, ... }: 5 - let 6 - # nnn's nerd icon table hardcodes xterm-256 colours, which would be the 7 - # one part of the UI that ignores the terminal theme. Remap them onto the 8 - # ANSI palette; 0 means "use the file's own colour". 9 - iconColors = { 10 - COLOR_ARCHIVE = 1; 11 - COLOR_AUDIO = 3; 12 - COLOR_AUDIO1 = 13; 13 - COLOR_C = 12; 14 - COLOR_CSS = 5; 15 - COLOR_DOCS = 9; 16 - COLOR_DOCUMENT = 0; 17 - COLOR_ELIXIR = 5; 18 - COLOR_FSHARP = 6; 19 - COLOR_IMAGE = 10; 20 - COLOR_JAVA = 4; 21 - COLOR_JAVASCRIPT = 3; 22 - COLOR_LUA = 4; 23 - COLOR_PYTHON = 11; 24 - COLOR_REACT = 14; 25 - COLOR_RUBY = 1; 26 - COLOR_SCALA = 9; 27 - COLOR_SHELL = 2; 28 - COLOR_VIDEO = 14; 29 - COLOR_VIDEO1 = 11; 30 - COLOR_VIM = 2; 31 - }; 32 - 33 - # Anything outside 0-15 left in the table means nnn grew an icon colour 34 - # we have not mapped, so fail the build instead of shipping a stray hue. 35 - unmapped = "COLOR_X\\(COLOR_[A-Z0-9_]+, *(1[6-9]|[2-9][0-9]|[0-9]{3})\\)"; 36 - 37 - nnn = (pkgs.nnn.override { withNerdIcons = true; }).overrideAttrs (old: { 38 - postPatch = (old.postPatch or "") + '' 39 - sed -i -E ${ 40 - lib.concatStringsSep " " ( 41 - lib.mapAttrsToList ( 42 - name: code: "-e 's/COLOR_X\\(${name},[^)]*\\)/COLOR_X(${name}, ${toString code})/'" 43 - ) iconColors 44 - ) 45 - } src/icons.h 46 - if grep -nE '${unmapped}' src/icons.h; then 47 - echo "nnn icon colours above are outside the ANSI palette" >&2 48 - exit 1 49 - fi 50 - ''; 51 - }); 52 - 53 - # Asks the terminal which graphics protocol it speaks. Run once per nnn 54 - # session so no image preview has to wait on a terminal round trip. 55 - term-caps = pkgs.writeShellApplication { 56 - name = "nnn-term-caps"; 57 - runtimeInputs = [ pkgs.coreutils ]; 58 - text = builtins.readFile ./term-caps.sh; 59 - }; 60 - 61 - imgpreview = pkgs.writeShellApplication { 62 - name = "nnn-imgpreview"; 63 - runtimeInputs = [ 64 - pkgs.chafa 65 - pkgs.coreutils 66 - ]; 67 - text = builtins.readFile ./imgpreview.sh; 68 - }; 69 - 70 - # Tools the preview/open plugins probe for at runtime. They are prefixed 71 - # onto $PATH rather than replacing it, so a tmux/kitty already in the 72 - # environment stays reachable. 73 - pluginTools = [ 74 - imgpreview 75 - pkgs.bat 76 - pkgs.coreutils 77 - pkgs.exiftool 78 - pkgs.fd 79 - pkgs.ffmpegthumbnailer 80 - pkgs.file 81 - pkgs.findutils 82 - pkgs.fzf 83 - pkgs.gnutar 84 - pkgs.jq 85 - pkgs.less 86 - pkgs.libarchive 87 - pkgs.librsvg 88 - pkgs.mdcat 89 - pkgs.mediainfo 90 - pkgs.ncurses 91 - pkgs.poppler-utils 92 - pkgs.procps 93 - pkgs.tree 94 - pkgs.unzip 95 - pkgs.viu 96 - pkgs.w3m 97 - ]; 98 - 99 - # nnn resolves bare plugin names inside $XDG_CONFIG_HOME/nnn/plugins, 100 - # which we do not own, so the plugins live here and are referenced by 101 - # absolute path from NNN_PLUG. 102 - plugins = 103 - let 104 - pathLine = ''export PATH="${lib.makeBinPath pluginTools}:$PATH"''; 105 - in 106 - pkgs.runCommand "nnn-plugins" { } '' 107 - mkdir -p $out/libexec/nnn 108 - cp ${nnn}/share/plugins/.nnn-plugin-helper $out/libexec/nnn/ 109 - for plugin in preview-tui fzcd fzopen nuke; do 110 - install -m755 ${nnn}/share/plugins/"$plugin" $out/libexec/nnn/"$plugin" 111 - sed -i '2i ${pathLine}' $out/libexec/nnn/"$plugin" 112 - done 113 - 114 - # glow renders markdown with a fixed hex palette and, as of 2.1.2, 115 - # emits no colour at all outside a tty. mdcat renders to plain ANSI 116 - # attributes, so markdown previews follow the terminal like the rest. 117 - substituteInPlace $out/libexec/nnn/preview-tui \ 118 - --replace-fail 'md) if exists glow; then' 'md) if exists mdcat; then' \ 119 - --replace-fail 'fifo_pager glow -s dark "$1"' 'fifo_pager mdcat --columns "$cols" "$1"' 120 - substituteInPlace $out/libexec/nnn/nuke \ 121 - --replace-fail 'if type glow >/dev/null 2>&1; then' 'if type mdcat >/dev/null 2>&1; then' \ 122 - --replace-fail 'glow -sdark "''${FPATH}" | eval "$PAGER"' 'mdcat "''${FPATH}" | eval "$PAGER"' 123 - 124 - # NNN_IMGFORMAT is decided before nnn starts, and preview-tui only 125 - # forwards the variables on this list into the preview pane. 126 - substituteInPlace $out/libexec/nnn/preview-tui \ 127 - --replace-fail \ 128 - '"NNN_PREVIEWIMGPROG=''${NNN_PREVIEWIMGPROG:-}"' \ 129 - '"NNN_PREVIEWIMGPROG=''${NNN_PREVIEWIMGPROG:-}" "NNN_IMGFORMAT=''${NNN_IMGFORMAT:-symbols}"' 130 - ''; 131 - 132 - # Every colour below is an xterm-256 index in 0x00-0x0f, i.e. an entry of 133 - # the terminal's own ANSI palette. Retheming the terminal - including 134 - # switch-theme repainting a local kitty while nnn runs on the far end of 135 - # an ssh session - recolours nnn without nnn or the remote host being 136 - # involved at all. 137 - # 138 - # Order is fixed, see nnn(1) NNN_FCOLORS. 139 - fileColors = lib.concatStrings [ 140 - "0b" # block device bright yellow 141 - "0b" # char device bright yellow 142 - "0c" # directory bright blue 143 - "0a" # executable bright green 144 - "00" # regular file terminal default 145 - "05" # hard link magenta 146 - "0e" # symlink bright cyan 147 - "08" # file details bright black 148 - "09" # orphaned symlink bright red 149 - "03" # fifo yellow 150 - "0d" # socket bright magenta 151 - "01" # unknown / empty red 152 - ]; 153 - 154 - # 8 contexts as 256-colour indices, with the 8-colour fallback after ';' 155 - # for terminals that never report 256 colour support. 156 - contextColors = "#0c0a0d0e0b090605;42563165"; 157 - in 158 - { 159 - packages.nnn = inputs.wrappers.lib.wrapPackage { 160 - inherit pkgs; 161 - package = nnn; 162 - aliases = [ "n" ]; 163 - runtimeInputs = [ term-caps ]; 164 - env = { 165 - NNN_FCOLORS = fileColors; 166 - NNN_COLORS = contextColors; 167 - # bat ships an "ansi" theme that only emits palette colours 168 - NNN_BATTHEME = "ansi"; 169 - NNN_BATSTYLE = "numbers"; 170 - NNN_OPENER = "${plugins}/libexec/nnn/nuke"; 171 - NNN_PREVIEWIMGPROG = lib.getExe imgpreview; 172 - NNN_PLUG = lib.concatStringsSep ";" [ 173 - "p:${plugins}/libexec/nnn/preview-tui" 174 - "f:${plugins}/libexec/nnn/fzcd" 175 - "o:${plugins}/libexec/nnn/fzopen" 176 - ]; 177 - }; 178 - preHook = '' 179 - # Ask the terminal once, on a tty nothing else is drawing on yet. 180 - NNN_IMGFORMAT=$(nnn-term-caps) 181 - export NNN_IMGFORMAT 182 - 183 - # nuke only reaches for graphical applications when a display exists. 184 - if [ -n "''${WAYLAND_DISPLAY:-}" ] || [ -n "''${DISPLAY:-}" ]; then 185 - export GUI=1 186 - fi 187 - 188 - # preview-tui splits the current pane; with no multiplexer and no 189 - # remote-controllable terminal it falls back to spawning $NNN_TERMINAL 190 - # (xterm), which is useless over ssh. Only auto-open the preview where 191 - # it can actually split. 192 - nnn_extra=() 193 - if [ -n "''${TMUX:-}" ] || [ -n "''${KITTY_LISTEN_ON:-}" ] || 194 - [ -n "''${WEZTERM_PANE:-}" ] || [ -n "''${ZELLIJ:-}" ]; then 195 - nnn_extra+=(-P p) 196 - fi 197 - ''; 198 - # -a: auto NNN_FIFO for the preview plugin, -c: NNN_OPENER is cli-only 199 - wrapper = 200 - { 201 - exePath, 202 - envString, 203 - preHook, 204 - ... 205 - }: 206 - '' 207 - ${envString} 208 - ${preHook} 209 - exec ${exePath} -a -c "''${nnn_extra[@]}" "$@" 210 - ''; 211 - }; 212 - }; 213 - }
-28
tools/nnn/imgpreview.sh
··· 1 - #!/usr/bin/env bash 2 - # Render an image for nnn's preview pane. 3 - # 4 - # preview-tui kills the previewer the instant the selection changes. Being 5 - # killed halfway through a kitty/sixel escape sequence leaves the terminal (and 6 - # tmux, when passthrough is in play) waiting for a terminator and swallowing 7 - # everything that follows, so the pane just goes blank and stays blank. Decode 8 - # into memory first, where a kill costs nothing, then write the finished frame 9 - # out in one go with the signals blocked. 10 - 11 - size=$(stty size </dev/tty 2>/dev/null) || size="24 80" 12 - rows=${size%% *} 13 - cols=${size##* } 14 - 15 - # The format is decided once per nnn session by term-caps; probing here would 16 - # put a terminal round trip inside the very window we are trying to protect. 17 - frame=$( 18 - chafa \ 19 - --probe off \ 20 - --format "${NNN_IMGFORMAT:-symbols}" \ 21 - --passthrough auto \ 22 - --animate off \ 23 - --size "${cols}x$((rows - 1))" \ 24 - -- "$1" 25 - ) || exit 0 26 - 27 - trap '' HUP INT TERM 28 - printf '%s' "$frame"
-72
tools/nnn/term-caps.sh
··· 1 - #!/usr/bin/env bash 2 - # Print the best graphics protocol this terminal speaks: kitty, sixels, iterm 3 - # or symbols. 4 - # 5 - # The terminal is asked directly instead of guessing from the environment, 6 - # because over ssh nothing on the remote host knows what is in front of the 7 - # user. Run this once, before a full-screen program takes over the tty: chafa 8 - # can probe on its own, but doing it per image races with nnn killing the 9 - # previewer mid-sequence. 10 - 11 - emit() { 12 - printf '%s\n' "$1" 13 - exit 0 14 - } 15 - 16 - case "${NNN_IMGFORMAT:-}" in 17 - kitty | sixels | iterm | symbols) emit "$NNN_IMGFORMAT" ;; 18 - esac 19 - 20 - # Terminals that answer no query but identify themselves in the environment. 21 - [ -n "${WEZTERM_PANE:-}" ] && emit iterm 22 - [ "${TERM_PROGRAM:-}" = "iTerm.app" ] && emit iterm 23 - 24 - query() { 25 - local saved 26 - local reply="" 27 - # a controlling terminal we can actually open, not just a device node; 28 - # bash reports a failing redirect before it applies 2>, hence the group 29 - { : <>/dev/tty; } 2>/dev/null || return 1 30 - saved=$(stty -g </dev/tty) || return 1 31 - stty raw -echo </dev/tty || return 1 32 - # Kitty graphics support, then primary device attributes (which reports 33 - # sixel as attribute 4). Inside tmux both are smuggled out to the real 34 - # terminal: tmux would answer DA1 itself, on its own behalf, and that says 35 - # nothing about what can actually be drawn. Getting no answer at all is 36 - # informative too - it means passthrough is disabled. 37 - if [ -n "${TMUX:-}" ]; then 38 - printf '\033Ptmux;\033\033_Gi=31,s=1,v=1,a=q,t=d,f=24;AAAA\033\033\134\033\134' >/dev/tty 39 - printf '\033Ptmux;\033\033[c\033\134' >/dev/tty 40 - else 41 - printf '\033_Gi=31,s=1,v=1,a=q,t=d,f=24;AAAA\033\134\033[c' >/dev/tty 42 - fi 43 - # terminals answer in order, so the device attributes reply comes last and 44 - # its trailing "c" ends the exchange; the timeout only bites when nothing 45 - # is listening 46 - IFS= read -r -s -t 1 -d'c' reply </dev/tty || true 47 - stty "$saved" </dev/tty 2>/dev/null || true 48 - printf '%sc' "$reply" 49 - } 50 - 51 - capabilities=$(query || true) 52 - 53 - # No answer to the graphics query inside tmux also means passthrough is off, 54 - # in which case kitty images would arrive as blank placeholder cells. 55 - case $capabilities in 56 - *'_Gi=31;OK'*) emit kitty ;; 57 - esac 58 - 59 - case $capabilities in 60 - *';4;'* | *';4c'* | *'?4;'* | *'?4c'*) 61 - # tmux advertises attribute 4 whenever it was built with sixel support, 62 - # regardless of what the attached client can actually draw 63 - if [ -z "${TMUX:-}" ]; then 64 - emit sixels 65 - fi 66 - case $(tmux display -p '#{client_termfeatures}' 2>/dev/null || true) in 67 - *sixel*) emit sixels ;; 68 - esac 69 - ;; 70 - esac 71 - 72 - emit symbols
-19
tools/vm-boot/flake-module.nix
··· 1 - { ... }: 2 - { 3 - perSystem = 4 - { pkgs, ... }: 5 - { 6 - packages.vm-boot = 7 - (pkgs.writeShellApplication { 8 - name = "vm-boot"; 9 - runtimeInputs = with pkgs; [ 10 - qemu 11 - file 12 - util-linux 13 - nix 14 - ]; 15 - text = builtins.readFile ./vm-boot.sh; 16 - }).overrideAttrs 17 - { passthru.usage = builtins.readFile ./usage.kdl; }; 18 - }; 19 - }
-10
tools/vm-boot/usage.kdl
··· 1 - bin "vm-boot" 2 - about "Boot an ISO file in a VM with automatic architecture detection" 3 - 4 - flag "-m --memory <size>" help="Memory in MB (default: 2048)" 5 - flag "-c --cpus <count>" help="Number of CPU cores (default: 2)" 6 - flag "-a --arch <arch>" help="Force architecture (x86_64 or aarch64)" 7 - flag "-n --nographic" help="Run in text mode without graphics" 8 - flag "-h --help" help="Show help message" 9 - 10 - arg "<iso_file>" help="ISO file to boot"
-189
tools/vm-boot/vm-boot.sh
··· 1 - #!/usr/bin/env bash 2 - set -euo pipefail 3 - set -x 4 - 5 - # Default values 6 - ISO_FILE="" 7 - MEMORY="2048" 8 - CPUS="2" 9 - ARCH="" 10 - NOGRAPHIC=false 11 - 12 - usage() { 13 - cat <<EOF 14 - Usage: $0 [OPTIONS] ISO_FILE 15 - 16 - Boot an ISO file in a VM with automatic architecture detection. 17 - 18 - OPTIONS: 19 - -m, --memory SIZE Memory in MB (default: 2048) 20 - -c, --cpus COUNT Number of CPU cores (default: 2) 21 - -a, --arch ARCH Force architecture (x86_64 or aarch64) 22 - -n, --nographic Run in text mode without graphics 23 - -h, --help Show this help message 24 - 25 - EXAMPLE: 26 - $0 installer.iso 27 - $0 -m 4096 -c 4 installer.iso 28 - $0 -a x86_64 installer.iso 29 - EOF 30 - } 31 - 32 - # Parse arguments 33 - while [[ $# -gt 0 ]]; do 34 - case $1 in 35 - -m|--memory) 36 - MEMORY="$2" 37 - shift 2 38 - ;; 39 - -c|--cpus) 40 - CPUS="$2" 41 - shift 2 42 - ;; 43 - -a|--arch) 44 - ARCH="$2" 45 - shift 2 46 - ;; 47 - -n|--nographic) 48 - NOGRAPHIC=true 49 - shift 50 - ;; 51 - -h|--help) 52 - usage 53 - exit 0 54 - ;; 55 - -*) 56 - echo "Unknown option: $1" 57 - usage 58 - exit 1 59 - ;; 60 - *) 61 - if [ -z "$ISO_FILE" ]; then 62 - ISO_FILE="$1" 63 - else 64 - echo "Multiple ISO files specified" 65 - usage 66 - exit 1 67 - fi 68 - shift 69 - ;; 70 - esac 71 - done 72 - 73 - # Check if ISO file is provided 74 - if [ -z "$ISO_FILE" ]; then 75 - echo "Error: ISO file not specified" 76 - usage 77 - exit 1 78 - fi 79 - 80 - # Check if ISO file exists 81 - if [ ! -f "$ISO_FILE" ]; then 82 - echo "Error: ISO file '$ISO_FILE' not found" 83 - exit 1 84 - fi 85 - 86 - # Detect architecture if not specified 87 - if [ -z "$ARCH" ]; then 88 - echo "Detecting ISO architecture..." 89 - ISO_INFO=$(file "$ISO_FILE") 90 - if echo "$ISO_INFO" | grep -q "aarch64"; then 91 - ARCH="aarch64" 92 - elif echo "$ISO_INFO" | grep -q "x86-64\|x86_64"; then 93 - ARCH="x86_64" 94 - else 95 - # Try to extract more info from the ISO 96 - ISO_LABEL=$(blkid -o value -s LABEL "$ISO_FILE" 2>/dev/null || echo "") 97 - if echo "$ISO_LABEL" | grep -q "aarch64"; then 98 - ARCH="aarch64" 99 - elif echo "$ISO_LABEL" | grep -q "x86"; then 100 - ARCH="x86_64" 101 - else 102 - echo "Could not detect architecture from ISO. Please specify with -a option." 103 - echo "Supported architectures: x86_64, aarch64" 104 - exit 1 105 - fi 106 - fi 107 - fi 108 - 109 - echo "Booting $ISO_FILE with $ARCH architecture..." 110 - echo "Memory: $MEMORY MB, CPUs: $CPUS" 111 - 112 - # Build QEMU command based on architecture 113 - if [ "$ARCH" = "x86_64" ]; then 114 - echo "Starting x86_64 VM with EFI..." 115 - # Get the x86_64-linux UEFI firmware 116 - echo "Building x86_64-linux UEFI firmware..." 117 - UEFI_STORE_PATH=$(nix build --no-link --print-out-paths --system x86_64-linux nixpkgs#OVMF.fd) 118 - UEFI_FW="$UEFI_STORE_PATH/FV/OVMF.fd" 119 - if [ ! -f "$UEFI_FW" ]; then 120 - echo "Error: Could not find x86_64 UEFI firmware at $UEFI_FW" 121 - exit 1 122 - fi 123 - echo "Using UEFI firmware: $UEFI_FW" 124 - if [ "$NOGRAPHIC" = true ]; then 125 - exec qemu-system-x86_64 \ 126 - -machine q35 \ 127 - -cpu qemu64 \ 128 - -m "$MEMORY" \ 129 - -smp "$CPUS" \ 130 - -accel tcg \ 131 - -bios "$UEFI_FW" \ 132 - -cdrom "$ISO_FILE" \ 133 - -boot d \ 134 - -nographic \ 135 - -serial mon:stdio 136 - else 137 - exec qemu-system-x86_64 \ 138 - -machine q35 \ 139 - -cpu qemu64 \ 140 - -m "$MEMORY" \ 141 - -smp "$CPUS" \ 142 - -accel tcg \ 143 - -bios "$UEFI_FW" \ 144 - -cdrom "$ISO_FILE" \ 145 - -boot d 146 - fi 147 - elif [ "$ARCH" = "aarch64" ]; then 148 - echo "Starting aarch64 VM..." 149 - # Get the aarch64-linux UEFI firmware 150 - echo "Building aarch64 UEFI firmware..." 151 - # Use the pre-built firmware path we know works 152 - UEFI_FW="/nix/store/2ciakp99mrcb3fx98j6ji0nxkxcyq5gy-OVMF-202505-fd/FV/QEMU_EFI.fd" 153 - if [ ! -f "$UEFI_FW" ]; then 154 - echo "Firmware not found in store, building..." 155 - UEFI_STORE_PATH=$(nix build --no-link --print-out-paths nixpkgs#OVMF-fd.aarch64-linux) 156 - UEFI_FW="$UEFI_STORE_PATH/FV/QEMU_EFI.fd" 157 - fi 158 - if [ ! -f "$UEFI_FW" ]; then 159 - echo "Error: Could not find aarch64 UEFI firmware at $UEFI_FW" 160 - exit 1 161 - fi 162 - echo "Using UEFI firmware: $UEFI_FW" 163 - if [ "$NOGRAPHIC" = true ]; then 164 - exec qemu-system-aarch64 \ 165 - -machine virt \ 166 - -cpu cortex-a57 \ 167 - -m "$MEMORY" \ 168 - -smp "$CPUS" \ 169 - -accel tcg \ 170 - -bios "$UEFI_FW" \ 171 - -cdrom "$ISO_FILE" \ 172 - -boot d \ 173 - -nographic 174 - else 175 - exec qemu-system-aarch64 \ 176 - -machine virt \ 177 - -cpu cortex-a57 \ 178 - -m "$MEMORY" \ 179 - -smp "$CPUS" \ 180 - -accel tcg \ 181 - -bios "$UEFI_FW" \ 182 - -cdrom "$ISO_FILE" \ 183 - -boot d 184 - fi 185 - else 186 - echo "Error: Unsupported architecture '$ARCH'" 187 - echo "Supported architectures: x86_64, aarch64" 188 - exit 1 189 - fi
-19
tools/yt-x/flake-module.nix
··· 1 - { self, ... }: 2 - { 3 - perSystem = 4 - { pkgs, system, ... }: 5 - let 6 - mpv = self.packages.${system}.mpv; 7 - extension = pkgs.writeText "custom-mpv" '' 8 - MPV_CMD="${mpv}/bin/mpv" 9 - ''; 10 - in 11 - { 12 - packages.yt-x = pkgs.writeShellScriptBin "yt-x" '' 13 - exec nix run \ 14 - --override-input nixpkgs path:${self.inputs.nixpkgs} \ 15 - github:Lassulus/yt-x/allow-full-path-extensions -- \ 16 - -x ${extension} "$@" 17 - ''; 18 - }; 19 - }