From 0dedcb3893bb879f4e61bde2aa3416b66fc9126b Mon Sep 17 00:00:00 2001 From: Nils Stinnesbeck Date: Sun, 25 Oct 2026 18:16:05 +0100 Subject: [PATCH] Nix flake with a dev shell for everything nix develop: Go, gopls, shellcheck, make, curl, jq, Python, Node.js, oxipng and ImageMagick; on Linux also Ghostty, Xvfb, xdotool, DejaVu fonts and Chromium for the README screenshots and the webOS app. Co-Authored-By: Claude Opus 5.5 --- README.md | 2 ++ dev/screenshots/README.md | 4 +-- dev/screenshots/take.sh | 2 +- flake.lock | 27 +++++++++++++++++ flake.nix | 62 +++++++++++++++++++++++++++++++++++++++ webos/README.md | 2 ++ 6 files changed, 96 insertions(+), 3 deletions(-) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/README.md b/README.md index a6c0db4..6bdb5d2 100644 --- a/README.md +++ b/README.md @@ -140,6 +140,8 @@ TV's Developer Mode; see [webos/README.md](webos/README.md). ## Development +`nix develop` opens a shell with everything below (Go, shellcheck, Node.js, Python, the screenshot +tools and Chromium; the flake is in [flake.nix](flake.nix)); without Nix, install what you use. `dev/` has a compose file with pinned Radarr, Sonarr and SABnzbd containers plus a fake indexer; see [dev/README.md](dev/README.md). `make test` runs vet and the unit tests. The screenshots are made with diff --git a/dev/screenshots/README.md b/dev/screenshots/README.md index 664507f..d4f1817 100644 --- a/dev/screenshots/README.md +++ b/dev/screenshots/README.md @@ -7,8 +7,8 @@ keys (masked in the Config view anyway). ```sh dev/screenshots/take.sh -# on NixOS, with the tools from nixpkgs: -nix-shell -p xvfb-run xorg-server xdotool imagemagick oxipng --run dev/screenshots/take.sh +# with Nix, everything from the flake's dev shell: +nix develop --command dev/screenshots/take.sh ``` Needs Go, Python 3, Ghostty, `xvfb-run` (Xvfb), `xdotool`, ImageMagick 7 and fontconfig with the diff --git a/dev/screenshots/take.sh b/dev/screenshots/take.sh index e67832f..ba15ad9 100755 --- a/dev/screenshots/take.sh +++ b/dev/screenshots/take.sh @@ -5,7 +5,7 @@ # # Needs: go, python3, ghostty, xvfb-run (Xvfb), xdotool, ImageMagick 7, # fontconfig with DejaVu fonts; oxipng optional. On NixOS: -# nix-shell -p xvfb-run xorg-server xdotool imagemagick oxipng --run dev/screenshots/take.sh +# nix develop --command dev/screenshots/take.sh set -euo pipefail here=$(cd "$(dirname "$0")" && pwd) repo=$(cd "$here/../.." && pwd) diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..3ddc189 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1792773339, + "narHash": "sha256-rZLrzrC6i+jnTAlvPZHogKDulY7WWDEv9hJeHieO7Zw=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "3ec636362e1816bc2f0888fa0fa2c69f1bc9e504", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..6dfeac6 --- /dev/null +++ b/flake.nix @@ -0,0 +1,62 @@ +{ + description = "arr-tui: a terminal UI (and webOS TV app) for Radarr, Sonarr and SABnzbd"; + + inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + + outputs = { self, nixpkgs }: + let + systems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ]; + forAll = f: nixpkgs.lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system}); + in + { + # nix develop: everything make test, the release script, the README + # screenshots (dev/screenshots) and the webOS app (webos/) need. + # Containers for dev/up.sh (docker or podman) come from the system. + devShells = forAll (pkgs: { + default = pkgs.mkShell { + packages = with pkgs; [ + # arr-tui + go + gopls + gnumake + shellcheck + git + # scripts/release.sh, dev/up.sh + curl + jq + # dev/screenshots (fake services), webos (app, tests, ares CLI) + python3 + nodejs_24 + # README pictures: oxipng compresses them + oxipng + imagemagick + ] ++ lib.optionals stdenv.hostPlatform.isLinux [ + # dev/screenshots/take.sh: Ghostty on a virtual X display + ghostty + xvfb-run + xorg-server + xdotool + fontconfig + dejavu_fonts + # webos/dev/drive.mjs + chromium + ]; + + # posters.sh asks fontconfig for the DejaVu fonts: the system's + # fonts plus DejaVu. + FONTCONFIG_FILE = pkgs.lib.optionalString pkgs.stdenv.hostPlatform.isLinux (pkgs.writeText "fonts.conf" '' + + + + /etc/fonts/fonts.conf + ${pkgs.dejavu_fonts}/share/fonts + + ''); + + shellHook = pkgs.lib.optionalString pkgs.stdenv.hostPlatform.isLinux '' + export CHROMIUM=${pkgs.chromium}/bin/chromium + ''; + }; + }); + }; +} diff --git a/webos/README.md b/webos/README.md index 3533bdb..f08f8c2 100644 --- a/webos/README.md +++ b/webos/README.md @@ -77,6 +77,8 @@ The app targets webOS 5 (2020 TVs, Chromium 68) and newer. ## Development +`nix develop` in the repository has Node.js and Chromium (and sets `$CHROMIUM`). + ```sh npm run typecheck npm test # unit tests (Node's test runner)