[PR #183] [CLOSED] Add Nix flake for declarative cross-platform installation #1136

Closed
opened 2026-03-14 09:20:14 +03:00 by kerem · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/anomalyco/opentui/pull/183
Author: @ezynda3
Created: 9/26/2025
Status: Closed

Base: mainHead: add-nix-flake


📝 Commits (9)

  • a6bc389 Add Nix flake for cross-platform OpenTUI installation
  • 7e30c04 Add Nix installation instructions to README
  • a1497ac Remove unnecessary nixConfig section from flake
  • 71e84a7 Update flake to build from source (no releases available yet)
  • 241b9be Fix dev shell to properly build and configure OpenTUI for Go development
  • eaf74fe Simplify dev shell by reusing opentui package derivation
  • 6d24e97 Fix build phase to only compile Zig library without JS dependencies
  • 3daf743 Fix Zig build by setting proper cache directories
  • 86bf0a9 Fix Zig build config: name should be a string literal

📊 Changes

4 files changed (+242 additions, -1 deletions)

View changed files

📝 README.md (+20 -0)
flake.lock (+61 -0)
flake.nix (+160 -0)
📝 packages/core/src/zig/build.zig.zon (+1 -1)

📄 Description

Summary

This PR adds Nix flake support to OpenTUI, enabling declarative, reproducible installation across different systems and architectures through the Nix package manager.

Motivation

Currently, OpenTUI installation requires running a bash script that downloads and installs binaries system-wide. While this works well for traditional setups, it presents challenges for:

  1. Declarative system management: NixOS and nix-darwin users prefer declarative package management where system state is defined in configuration files
  2. Reproducible environments: Development teams need consistent, reproducible dev environments across different machines
  3. Isolated development: Developers want to try OpenTUI without system-wide installation
  4. CI/CD pipelines: Nix provides excellent caching and reproducibility for CI environments

What This PR Adds

1. flake.nix - Main flake definition

  • Multi-platform support (x86_64 and aarch64 for Linux and macOS)
  • Automatic platform detection and correct binary selection
  • Proper library naming (.so vs .dylib) based on OS
  • pkg-config file generation for build system integration

2. flake.lock - Pinned dependencies

  • Ensures reproducible builds across all systems
  • Uses nixpkgs unstable for latest packages

3. Updated README

  • Clear installation instructions for Nix users
  • Examples for different use cases (dev shell, system package, flake input)

Benefits

  1. Zero system pollution: Users can try OpenTUI in an isolated shell without installing anything globally
  2. Declarative configuration: NixOS/nix-darwin users can add OpenTUI to their system configuration
  3. Development shells: Teams can share consistent dev environments with all required tools
  4. Better CI integration: GitHub Actions and other CI systems can leverage Nix caching
  5. Version pinning: Flake.lock ensures everyone uses the same version until explicitly updated

Usage Examples

# Quick try without installation
nix develop github:sst/opentui

# Add to dev environment
nix flake init -t github:sst/opentui

# System-wide on NixOS
environment.systemPackages = [ opentui.packages.${system}.default ];

Notes

  • The flake downloads pre-built binaries from GitHub releases, matching the existing install.sh behavior
  • No changes to existing installation methods - this is purely additive
  • Follows Nix best practices for packaging external binaries
  • Includes development shell with common tools (Go, Bun, Zig)

This enhancement makes OpenTUI more accessible to the growing Nix community while maintaining full compatibility with existing installation methods.


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/anomalyco/opentui/pull/183 **Author:** [@ezynda3](https://github.com/ezynda3) **Created:** 9/26/2025 **Status:** ❌ Closed **Base:** `main` ← **Head:** `add-nix-flake` --- ### 📝 Commits (9) - [`a6bc389`](https://github.com/anomalyco/opentui/commit/a6bc3897bd227478fb90f17543ac17577a5b1909) Add Nix flake for cross-platform OpenTUI installation - [`7e30c04`](https://github.com/anomalyco/opentui/commit/7e30c0478dfa7c45b5520e03a435262ddf4856aa) Add Nix installation instructions to README - [`a1497ac`](https://github.com/anomalyco/opentui/commit/a1497acd87cc916aa452c3d10752f28782ae3473) Remove unnecessary nixConfig section from flake - [`71e84a7`](https://github.com/anomalyco/opentui/commit/71e84a79ad280560adb8eb0cad5b1abc17694ac5) Update flake to build from source (no releases available yet) - [`241b9be`](https://github.com/anomalyco/opentui/commit/241b9bef6aa431576adc77e9364ea196df807bb7) Fix dev shell to properly build and configure OpenTUI for Go development - [`eaf74fe`](https://github.com/anomalyco/opentui/commit/eaf74fe258ff22e54b0f8dcc931dfb0be6d20537) Simplify dev shell by reusing opentui package derivation - [`6d24e97`](https://github.com/anomalyco/opentui/commit/6d24e97cf8104d21365c169ef33a5c116ecfdaa3) Fix build phase to only compile Zig library without JS dependencies - [`3daf743`](https://github.com/anomalyco/opentui/commit/3daf743925b140fefbe04f1808264a336b7565c1) Fix Zig build by setting proper cache directories - [`86bf0a9`](https://github.com/anomalyco/opentui/commit/86bf0a9b7f8db34a10e2897928fbaf5207fab2c6) Fix Zig build config: name should be a string literal ### 📊 Changes **4 files changed** (+242 additions, -1 deletions) <details> <summary>View changed files</summary> 📝 `README.md` (+20 -0) ➕ `flake.lock` (+61 -0) ➕ `flake.nix` (+160 -0) 📝 `packages/core/src/zig/build.zig.zon` (+1 -1) </details> ### 📄 Description ## Summary This PR adds Nix flake support to OpenTUI, enabling declarative, reproducible installation across different systems and architectures through the Nix package manager. ## Motivation Currently, OpenTUI installation requires running a bash script that downloads and installs binaries system-wide. While this works well for traditional setups, it presents challenges for: 1. **Declarative system management**: NixOS and nix-darwin users prefer declarative package management where system state is defined in configuration files 2. **Reproducible environments**: Development teams need consistent, reproducible dev environments across different machines 3. **Isolated development**: Developers want to try OpenTUI without system-wide installation 4. **CI/CD pipelines**: Nix provides excellent caching and reproducibility for CI environments ## What This PR Adds ### 1. `flake.nix` - Main flake definition - Multi-platform support (x86_64 and aarch64 for Linux and macOS) - Automatic platform detection and correct binary selection - Proper library naming (.so vs .dylib) based on OS - pkg-config file generation for build system integration ### 2. `flake.lock` - Pinned dependencies - Ensures reproducible builds across all systems - Uses nixpkgs unstable for latest packages ### 3. Updated README - Clear installation instructions for Nix users - Examples for different use cases (dev shell, system package, flake input) ## Benefits 1. **Zero system pollution**: Users can try OpenTUI in an isolated shell without installing anything globally 2. **Declarative configuration**: NixOS/nix-darwin users can add OpenTUI to their system configuration 3. **Development shells**: Teams can share consistent dev environments with all required tools 4. **Better CI integration**: GitHub Actions and other CI systems can leverage Nix caching 5. **Version pinning**: Flake.lock ensures everyone uses the same version until explicitly updated ## Usage Examples ```bash # Quick try without installation nix develop github:sst/opentui # Add to dev environment nix flake init -t github:sst/opentui # System-wide on NixOS environment.systemPackages = [ opentui.packages.${system}.default ]; ``` ## Notes - The flake downloads pre-built binaries from GitHub releases, matching the existing install.sh behavior - No changes to existing installation methods - this is purely additive - Follows Nix best practices for packaging external binaries - Includes development shell with common tools (Go, Bun, Zig) This enhancement makes OpenTUI more accessible to the growing Nix community while maintaining full compatibility with existing installation methods. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
kerem 2026-03-14 09:20:14 +03:00
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/opentui#1136
No description provided.