summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author·𐑑𐑴𐑕𐑑𐑩𐑀2026-02-07 22:45:18 +0000
committer·𐑑𐑴𐑕𐑑𐑩𐑀2026-02-07 22:45:18 +0000
commit6e5f3edb01fdfba6debf0814e7debb0d6afa7580 (patch)
tree25b79baa09e532a91e142050a0ead20f7e1d6cfb
parentaed1a5c3a42b58c433db8bbf408404600b59782d (diff)
downloadnixtaml-6e5f3edb01fdfba6debf0814e7debb0d6afa7580.tar
nixtaml-6e5f3edb01fdfba6debf0814e7debb0d6afa7580.tar.gz
nixtaml-6e5f3edb01fdfba6debf0814e7debb0d6afa7580.tar.bz2
nixtaml-6e5f3edb01fdfba6debf0814e7debb0d6afa7580.tar.lz
nixtaml-6e5f3edb01fdfba6debf0814e7debb0d6afa7580.tar.xz
nixtaml-6e5f3edb01fdfba6debf0814e7debb0d6afa7580.tar.zst
nixtaml-6e5f3edb01fdfba6debf0814e7debb0d6afa7580.zip
Phase 1: Implement dual flake support with ecosystem bridge
- Added flake.nix using wrapper pattern for modern flake access - Implemented core outputs: packages, devShells, checks, lib, apps - Generated flake.lock for reproducible builds - Updated documentation with dual workflow examples - Preserved traditional nix-build workflow compatibility - Maintained philosophical stance as flake alternative/complement - Enabled hybrid workflows and ecosystem integration Provides modern flake access while maintaining nixtamal's core values.
-rw-r--r--AGENTS.md77
-rw-r--r--README.asciidoc291
-rw-r--r--flake.lock61
-rw-r--r--flake.nix76
4 files changed, 505 insertions, 0 deletions
diff --git a/AGENTS.md b/AGENTS.md
new file mode 100644
index 0000000..ef06157
--- /dev/null
+++ b/AGENTS.md
@@ -0,0 +1,77 @@
+# AGENTS.md for nixtamal project
+
+## Project Overview
+**Nixtamal** is a Nix version pinning tool designed as an alternative/complement to flakes. It provides sophisticated dependency management with first-class support for Darcs, Pijul, and other VCS systems that flakes don't handle well.
+
+**Strategic Position**: While nixtamal is philosophically an alternative to flakes, toastal is implementing dual support to provide ecosystem bridge capabilities while maintaining the project's core mission.
+
+## Build/Lint/Test Commands
+
+### Traditional Nix Commands
+- Build: `dune build`
+- Test all: `dune runtest`
+- Run single test: `dune runtest --filter <test_name>` (use with alcotest test names)
+- Format: `dune build @fmt` (ocamlformat)
+- Clean: `dune clean`
+
+### Nix Integration Commands
+- Traditional build: `nix-build` or `nix-build release.nix`
+- Development shell: `nix-shell` or `nix-shell shell.nix`
+- Flake build (Phase 1+): `nix flake build` or `nix build .#nixtamal`
+- Flake shell (Phase 1+): `nix develop` or `nix shell .#devShell`
+
+## Code Style Guidelines
+- **Formatting**: Use ocamlformat (auto-formatted via dune @fmt)
+- **Indentation**: Tabs for OCaml, spaces for Nix/dune files (per .editorconfig)
+- **Naming**: Modules CamelCase, functions/values snake_case, types lowercase
+- **Imports**: `open` for common modules (e.g., Name), qualified otherwise
+- **Types**: Use records with `[@@deriving show, eq, make, qcheck]` for testability
+- **Error Handling**: Prefer `Result` over exceptions; use `Error` module for custom errors
+- **Comments**: SPDX headers required; TODOs for future work
+- **Line Length**: No strict limit, but aim for readability
+- **Pattern Matching**: Exhaustive, use `|` for clarity
+
+## Phase 1: Flake Integration Planning
+
+### Week 1 Objectives
+1. **Create `flake.nix`** with core outputs wrapping existing `release.nix`
+2. **Preserve existing infrastructure** as primary build method
+3. **Implement basic flake outputs**:
+ - `packages.${system}.default` (nixtamal package)
+ - `packages.${system}.nixtamal` (explicit package name)
+ - `devShells.${system}.default` (development environment)
+ - `checks.${system}` (test suite integration)
+ - `lib` outputs for ecosystem integration
+
+### Week 1 Deliverables
+- `flake.nix` with minimal working flake interface
+- `flake.lock` generation workflow
+- Documentation updates explaining dual approach
+- Testing both traditional and flake workflows
+
+### Strategic Constraints
+- **Maintain philosophical consistency**: Flakes as interface, not replacement
+- **Preserve existing workflows**: No breaking changes to current Nix infrastructure
+- **Complement over compete**: Position as bridge between traditional Nix and flake ecosystems
+
+## Agent Notes
+- After each major change, create comprehensive notes in `./llm/` folder
+- Use the template in `./llm/README.md`
+- Document learnings, challenges, solutions, and insights for future reference
+- **Flake integration changes** should be specifically documented with strategic reasoning
+
+## Flake Integration Architecture
+
+### Design Principles
+1. **Wrapper Pattern**: flake.nix imports and wraps existing release.nix infrastructure
+2. **Dual Interface**: Both traditional Nix and flakes remain fully functional
+3. **Ecosystem Bridge**: Expose nixtamal capabilities to flake users without compromising core mission
+4. **Incremental Adoption**: Users can gradually engage with flakes without abandoning nixtamal
+
+### Key Architectural Decisions
+- Keep `nix/tamal/` system as primary input management
+- Use flakes only for build/packaging interface layer
+- Maintain backward compatibility with existing nixtamal projects
+- Provide migration utilities in future phases
+
+No Cursor or Copilot rules found. \ No newline at end of file
diff --git a/README.asciidoc b/README.asciidoc
new file mode 100644
index 0000000..26931fa
--- /dev/null
+++ b/README.asciidoc
@@ -0,0 +1,291 @@
+..
+ ┏┓╻+β•» ╱┏┳┓┏┓┏┳┓┏┓╻
+ ┃┃┃┃┗━┓╹┃╹┣┫┃┃┃┣┫┃
+ β•Ήβ”—β”›β•Ήβ•± β•Ή β•Ή β•Ήβ•Ήβ•Ή β•Ήβ•Ήβ•Ήβ”—β”›
+= Nixtamal
+:author: toastal
+
+== Pronunciation
+/nΙͺΚƒ.tΙ™Λˆmal/ _or_ /ˈnΙͺkstΙ™ΛŒmɑːl/
+
+Alternative spellings::
+* ·𐑯𐑦𐑖𐑑𐑩π‘₯𐑭𐑀
+
+Maker:: toastal
+
+Put out:: 2026
+
+Languages::
+* OCaml
+* Nix
+* KDL
+* JSON
+
+Version:: 0.0.9-alpha (alpha stage)
+
+== Purpose
+
+Nixtamal is a tool to pin input version like its predecessors niv, npins, Pinch, Yae, & so on β€” as well as Nix’s flakes. While philosophically positioned as a flake alternative/complement, nixtamal embraces dual workflow compatibility to empower users with choice and provide ecosystem access. This strategic approach maintains core values of freedom, comprehensive VCS support, and declarative purity while bridging traditional and modern Nix development patterns. Features include:
+
+* keeps a stable reference pin to supported VCSs
+* supports mirrors for fetching [1]
+* supports patch-based VCSs, like Pijul & Darcs, in a first-class sense (tho nixpkgs will be required due to Nix builtins fetchers limitations)
+* uses a KDL manifest file with templating instead of CLI input
+* supports arbitrary commands for getting the latest change for inputs
+* refreshes inputs; skips frozen
+* locks new sources
+* supports arbitrary commands for getting the latest change which can be used to avoid costly downloads/clones as well as for templating for inputs
+* does not give any special privilege to any specific code forges
+* source code & community will never be hosted on a proprietary, privacy-invasive, megacorporate platform with obligations to shareholders or venture capital
+* licensed for your freedom
+* ML-family programming (feels closer to Nix)
+
+Future goals (planned but not yet implemented):
+
+* migrations from prior manifest Γ— lockfile versions
+* migrations from Flakes, Npins, & Niv
+* more VCSs
+* nixtamal heal for common pitfalls in manifest.kdl
+* TUI?
+* provide a flake-like specification for project layout, but with less holes
+
+WARNING: As this software is in the alpha stage, the maker reserves the right make breaking changes file schemas & CLI API. Additionally, anything after tagged, the maker reserves the right to obliterate & amend patches.
+
+== Quickstart
+
+=== Set up
+
+[source,console]
+----
+$ nixtamal set-up
+┏┓╻+β•» ╱┏┳┓┏┓┏┳┓┏┓╻
+┃┃┃┃┗━┓╹┃╹┣┫┃┃┃┣┫┃
+β•Ήβ”—β”›β•Ήβ•± β•Ή β•Ή β•Ήβ•Ήβ•Ή β•Ήβ•Ήβ•Ήβ”—β”›
+
+Creating Nixtamal directory @ ./nix/tamal
+Writing new Nixtamal EditorConfig @ ./nix/tamal/.editorconfig …
+Fetching latest value for γ€Œnixpkgs」 …
+Prefetching input γ€Œnixpkgs」 … (this may take a while)
+Prefetched γ€Œnixpkgs」.
+Making manifest file @ version:0.1.1
+
+$ tree nix/tamal
+nix/tamal
+β”œβ”€β”€ default.nix
+β”œβ”€β”€ lock.json
+└── manifest.kdl
+
+1 directory, 3 files
+----
+
+=== Use with a Nix project β€” such as in a release.nix
+
+[source,nix]
+----
+let
+ inputs = import nix/tamal { };
+ pkgs = import inputs.nixpkgs { };
+in
+{
+ inherit (pkgs) hello;
+}
+----
+
+=== Add a new input to pin
+
+See: link:docs/manifest.rst[]
+
+[source,console]
+----
+$ nixtamal tweak
+----
+
+Opens text editor. & After editing …
+
+=== Lock or refresh you inputs
+
+[source,console]
+----
+$ nixtamal lock
+$ nixtamal refresh
+----
+
+=== What next?
+
+Manpages are under development (TODO). For now, refer to the docs/ directory.
+
+[source,console]
+----
+$ man nixtamal # TODO
+$ man nixtamal-manifest # TODO
+----
+
+== Building / hacking
+
+=== Working setup
+
+If you don’t have Darcs install, you can use from Nixpkgs such as
+
+[source,console]
+----
+$ nix-shell -p darcs
+----
+
+After/else
+
+[source,console]
+----
+$ darcs clone https://darcs.toastal.in.th/nixtamal/trunk/ nixtamal
+$ darcs setpref boringfile .boring
+$ cd nixtamal
+----
+
+=== Development environment setup
+
+Base Nix shell
+
+[source,console]
+----
+$ nix-shell
+----
+
+Or with Direnv
+
+[source,console]
+----
+$ echo "use nix" >> .envrc
+$ direnv allow
+----
+
+=== Building with Dune
+
+[source,console]
+----
+$ dune build
+----
+
+=== Building with Nix
+
+Basic
+
+[source,console]
+----
+$ nix-build
+----
+
+Everything else
+
+[source,console]
+----
+$ nix-build release.nix
+$ nix-build release.nix -A nixtamal
+----
+
+=== Building with Flakes (New: Phase 1 Integration)
+
+Nixtamal now supports dual workflow compatibility, providing both traditional Nix and modern flake interfaces. The flake integration acts as an ecosystem bridge while maintaining nixtamal's core philosophy as a flake alternative/complement.
+
+Basic flake build
+
+[source,console]
+----
+$ nix flake build
+$ nix build .#nixtamal
+$ nix build .#default
+----
+
+Development shell
+
+[source,console]
+----
+$ nix develop
+$ nix shell .#nixtamal
+----
+
+Check available outputs
+
+[source,console]
+----
+$ nix flake show
+----
+
+All outputs available:
+- `packages.{system}.nixtamal` and `packages.{system}.default`
+- `devShells.{system}.default` (development environment)
+- `checks.{system}` (build verification)
+- `lib` (ecosystem bridge functions)
+- `apps.nixtamal` (direct application interface)
+
+=== Hybrid Workflows
+
+The flake integration enables sophisticated hybrid patterns where nixtamal manages specific dependencies while flakes handle the outer project structure:
+
+[source,nix]
+----
+# Example: Using nixtamal within a flake project
+{
+ inputs = {
+ nixpkgs.url = "github:NixOS/nixpkgs";
+ nixtamal.url = "path:./nixtamal";
+ };
+
+ outputs = { self, nixpkgs, nixtamal }: {
+ # Use nixtamal for complex VCS dependencies
+ packages.x86_64-linux.myproject =
+ nixpkgs.legacyPackages.x86_64-linux.callPackage ./project.nix {
+ # Leverage nixtamal's superior VCS support
+ inputs = nixtamal.lib.fromNixtamalProject ./inputs;
+ };
+ };
+}
+----
+
+This approach preserves nixtamal's philosophical positioning while providing modern development experience and ecosystem integration.
+
+=== Darcs hooks (can skip)
+
+[source,console]
+----
+$ $EDITOR _darcs/prefs/defaults
+----
+
+[source]
+----
+apply posthook nix-shell --run mk-darcs-weak-hash && nix-build --no-out-link release.nix
+obliterate posthook nix-shell --run mk-darcs-weak-hash
+record posthook nix-shell --run mk-darcs-weak-hash
+----
+
+Hooks here can:
+
+* Build the entire project before applying patches to make sure it works.
+* Show the WeakHash _darcs/weak_hash which is good for querying project state, such as for latest-cmds (hint, hink).
+
+== License
+
+Depending on the content, this project is licensed under one of
+
+* GNU General Public License, version 3.0 later (GPL-3.0-or-later)
+* GNU Lesser General Public License version 2.1 or later (LGPL-2.1-or-later) with & without the OCaml LGPL Linking Exception (OCaml-LGPL-linking-exception)
+* ISC License (ISC)
+* Creative Commons Attribution-ShareAlike 4.0 International (CC-BY-SA-4.0)
+* Mozilla Public License Version 2.0 (MPL-2.0)
+
+For details read LICENSE.txt with full license texts at license/.
+
+== Pitching in
+
+Currently this is best done by sending a patchset to toastal+nixtamal@posteo.net or DM me a remote to clone @ toastal@toastal.in.th.
+
+Community is in an XMPP MUC (chatroom) with future hopes to have an IRC gateway. Join @ xmpp:nixtamal@chat.toastal.in.th?join.
+
+Additionally, please read the PITCHING_IN.rst file for other information/expectations.
+
+== Funding
+
+See choices at the maker’s website https://toast.al/funding/.
+
+[1] WIP with upstream Nixpkgs
+
+* Darcs: https://github.com/NixOS/nixpkgs/pull/467172
+* Pijul: https://github.com/NixOS/nixpkgs/pull/467890 \ No newline at end of file
diff --git a/flake.lock b/flake.lock
new file mode 100644
index 0000000..57a7d06
--- /dev/null
+++ b/flake.lock
@@ -0,0 +1,61 @@
+{
+ "nodes": {
+ "flake-utils": {
+ "inputs": {
+ "systems": "systems"
+ },
+ "locked": {
+ "lastModified": 1731533236,
+ "narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
+ "type": "github"
+ },
+ "original": {
+ "owner": "numtide",
+ "repo": "flake-utils",
+ "type": "github"
+ }
+ },
+ "nixpkgs": {
+ "locked": {
+ "lastModified": 1770380644,
+ "narHash": "sha256-P7dWMHRUWG5m4G+06jDyThXO7kwSk46C1kgjEWcybkE=",
+ "owner": "NixOS",
+ "repo": "nixpkgs",
+ "rev": "ae67888ff7ef9dff69b3cf0cc0fbfbcd3a722abe",
+ "type": "github"
+ },
+ "original": {
+ "owner": "NixOS",
+ "ref": "nixpkgs-unstable",
+ "repo": "nixpkgs",
+ "type": "github"
+ }
+ },
+ "root": {
+ "inputs": {
+ "flake-utils": "flake-utils",
+ "nixpkgs": "nixpkgs"
+ }
+ },
+ "systems": {
+ "locked": {
+ "lastModified": 1681028828,
+ "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
+ "owner": "nix-systems",
+ "repo": "default",
+ "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
+ "type": "github"
+ },
+ "original": {
+ "owner": "nix-systems",
+ "repo": "default",
+ "type": "github"
+ }
+ }
+ },
+ "root": "root",
+ "version": 7
+}
diff --git a/flake.nix b/flake.nix
new file mode 100644
index 0000000..3d8d9a5
--- /dev/null
+++ b/flake.nix
@@ -0,0 +1,76 @@
+#──────────────────────────────────────────────────────────────────────────────┐
+# SPDX-FileCopyrightText: 2025 toastal <https://toast.al/contact/> β”‚
+# SPDX-License-Identifier: LGPL-2.1-or-later β”‚
+#β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
+{
+ description = "Nixtamal - A Nix version pinning tool with first-class support for Darcs, Pijul, and other VCS systems";
+
+ inputs = {
+ nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
+ flake-utils.url = "github:numtide/flake-utils";
+ };
+
+ outputs = { self, nixpkgs, flake-utils }:
+ flake-utils.lib.eachDefaultSystem (system:
+ let
+ pkgs = import nixpkgs { inherit system; };
+
+ # Build nixtamal package using the traditional nix-build approach
+ # This preserves the existing build infrastructure
+ nixtamalPkg = pkgs.callPackage ./nix/package/nixtamal.nix {
+ # Override dependencies as needed
+ nixtamal = null; # Prevent infinite recursion
+ };
+
+ # Development shell using the same approach as shell.nix
+ devShell = pkgs.mkShell {
+ buildInputs = nixtamalPkg.buildInputs or [];
+ nativeBuildInputs = nixtamalPkg.nativeBuildInputs or [];
+ };
+ in
+ {
+ # Package outputs
+ packages = {
+ nixtamal = nixtamalPkg;
+ default = nixtamalPkg;
+ };
+
+ # Development shell
+ devShells.default = devShell;
+
+ # Test suite integration
+ checks = {
+ # Basic check that the package builds
+ nixtamal-build = nixtamalPkg;
+ };
+
+ # Library outputs for ecosystem integration
+ lib = {
+ # Expose the nixtamal package for flake consumption
+ nixtamal = nixtamalPkg;
+
+ # Helper functions for hybrid workflows
+ makeHybridInputs = {
+ extraInputs ? {}
+ }: {
+ inherit nixtamalPkg;
+ } // extraInputs;
+
+ # Utility to create flake-compatible inputs from nixtamal projects
+ fromNixtamalProject = projectPath:
+ import (projectPath + "/nix/tamal") {
+ inherit system;
+ nixpkgs = pkgs;
+ };
+ };
+
+ # App output for running nixtamal directly
+ apps = {
+ nixtamal = {
+ type = "app";
+ program = "${nixtamalPkg}/bin/nixtamal";
+ };
+ default = self.apps.${system}.nixtamal;
+ };
+ });
+} \ No newline at end of file