From 994df50dc70f62d064bc2aad921cde023b8dd90b Mon Sep 17 00:00:00 2001 From: Jari Vetoniemi Date: Mon, 23 Mar 2026 14:55:49 +0900 Subject: [PATCH] feat: add flake.nix (#86) --- flake.lock | 27 +++++++++++++++++++++++++++ flake.nix | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/flake.lock b/flake.lock new file mode 100644 index 00000000..ac0370f8 --- /dev/null +++ b/flake.lock @@ -0,0 +1,27 @@ +{ + "nodes": { + "nixpkgs": { + "locked": { + "lastModified": 1773840656, + "narHash": "sha256-9tpvMGFteZnd3gRQZFlRCohVpqooygFuy9yjuyRL2C0=", + "owner": "nixos", + "repo": "nixpkgs", + "rev": "9cf7092bdd603554bd8b63c216e8943cf9b12512", + "type": "github" + }, + "original": { + "owner": "nixos", + "ref": "nixpkgs-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 00000000..cda4461b --- /dev/null +++ b/flake.nix @@ -0,0 +1,35 @@ +# This flake does not package ziex. +# It allows nix users to `nix run github:ziex-dev/ziex` which builds +# and runs the `zx` binary. The build is not done inside a sandbox. +# +# This allows you to bootstrap a ziex project and then use whatever +# zig dev environment you are comfortable with. +{ + description = "Framework for building web applications with zig"; + inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + + outputs = {nixpkgs, ...}: + with builtins; + with nixpkgs.lib; + let + forAllSystems = f: genAttrs systems.flakeExposed (s: f nixpkgs.legacyPackages.${s}); + src = cleanSource ./.; + in { + apps = forAllSystems (pkgs: { + default = { + type = "app"; + meta.description = "zx: framework for building web applications with zig"; + program = toString (pkgs.writeShellApplication { + name = "zx"; + runtimeInputs = [pkgs.zig_0_15]; + text = '' + tmp="$(mktemp -d)" + trap 'rm -rf "$tmp"' EXIT + (cd "${src}" && ZIG_LOCAL_CACHE_DIR="$tmp" zig build -p "$tmp" -Doptimize=Debug) + "$tmp/bin/zx" "$@" + ''; + }) + "/bin/zx"; + }; + }); + }; +} \ No newline at end of file