From 4b7e18a7177f25270106d87978fcfd13ab5faa2f Mon Sep 17 00:00:00 2001 From: Ignacio Perez Date: Sat, 14 Mar 2026 18:40:01 -0300 Subject: [PATCH] build(nix): add flake for reproducible builds Introduce a flake.nix to allow building and running engram with Nix. Usage: nix build nix run nix develop --- .gitignore | 3 +++ README.md | 62 ++++++++++++++++++++++++++++++++++++++++++++++ flake.lock | 61 +++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 198 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.gitignore b/.gitignore index 128fa60..3889db2 100644 --- a/.gitignore +++ b/.gitignore @@ -26,3 +26,6 @@ Thumbs.db .codex/skills .github/skills .gemini/skills + +# Nix output +result diff --git a/README.md b/README.md index 97a5855..a158531 100644 --- a/README.md +++ b/README.md @@ -53,6 +53,68 @@ brew update && brew upgrade engram > brew uninstall --cask engram 2>/dev/null; brew install gentleman-programming/tap/engram > ``` +### Install via Nix + +Run directly without installing: + +```bash +nix run github:Gentleman-Programming/engram +```` + +Build locally: + +```bash +nix build +./result/bin/engram +``` + +Enter a development shell: + +```bash +nix develop +``` + +
+Home Manager / NixOS integration + +You can also add Engram from this repository flake into your own Nix configuration. + +#### As a flake input + +```nix +{ + inputs.engram.url = "github:Gentleman-Programming/engram"; +} +``` + +#### Home Manager + +```nix +{ inputs, pkgs, ... }: + +{ + home.packages = [ + inputs.engram.packages.${pkgs.system}.default + ]; +} +``` + +#### NixOS + +```nix +{ inputs, pkgs, ... }: + +{ + environment.systemPackages = [ + inputs.engram.packages.${pkgs.system}.default + ]; +} +``` + +This makes the `engram` binary available in your environment without installing Go manually. + +
+ ### Install on Windows **Option A: Download the binary (recommended)** diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..25ec39a --- /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": 1773389992, + "narHash": "sha256-wvfdLLWJ2I9oEpDd9PfMA8osfIZicoQ5MT1jIwNs9Tk=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "c06b4ae3d6599a672a6210b7021d699c351eebda", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-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..045017c --- /dev/null +++ b/flake.nix @@ -0,0 +1,72 @@ +{ + description = "engram - Persistent memory for AI coding agents"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = + { + self, + nixpkgs, + flake-utils, + }: + flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = import nixpkgs { inherit system; }; + + pname = "engram"; + version = "1.10.0"; + + engram = pkgs.buildGoModule { + inherit pname; + inherit version; + vendorHash = "sha256-wnRtuBn5H+UdWkXucpfHPEbFosVCUa8i9hVRXg5Wqc4="; + proxyVendor = true; + + src = ./.; + subPackages = [ "cmd/engram" ]; + + env = { + CGO_ENABLED = "0"; + }; + + ldflags = [ + "-s" + "-w" + "-X main.version=${version}" + ]; + + meta = with pkgs.lib; { + description = "Persistent memory for AI coding agents"; + homepage = "https://github.com/Gentleman-Programming/engram"; + license = licenses.mit; + mainProgram = "engram"; + platforms = platforms.linux ++ platforms.darwin; + }; + }; + in + { + packages.default = engram; + packages.engram = engram; + + apps.default = flake-utils.lib.mkApp { + drv = engram; + }; + + devShells.default = pkgs.mkShell { + packages = with pkgs; [ + go_1_25 + gopls + gotools + golangci-lint + delve + ]; + }; + + formatter = pkgs.nixfmt-rfc-style; + } + ); +}