feat: add flake.nix (#86)

This commit is contained in:
Jari Vetoniemi 2026-03-23 14:55:49 +09:00 committed by GitHub
parent c85ba484b3
commit 994df50dc7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 62 additions and 0 deletions

27
flake.lock generated Normal file
View File

@ -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
}

35
flake.nix Normal file
View File

@ -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";
};
});
};
}