Skip to content

Commit 71dccce

Browse files
authored
feat: add Nix flake and improve installation options (#51)
- Add flake.nix for Nix package manager integration - Document npx usage options in README - Add prepare script to ensure build runs before publishing
1 parent 025fc29 commit 71dccce

File tree

4 files changed

+110
-1
lines changed

4 files changed

+110
-1
lines changed

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ Via npm:
2828
npm install -g @mistweaverco/kulala-fmt
2929
```
3030

31+
You can also run it directly without installation using npx:
32+
33+
```sh
34+
# From npm registry
35+
npx @mistweaverco/kulala-fmt format file.http
36+
37+
# Directly from GitHub
38+
npx github:mistweaverco/kulala-fmt format file.http
39+
```
40+
3141
## Usage
3242

3343
kulala-fmt can `format` and `check` `.http` and `.rest` files.

flake.lock

Lines changed: 48 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
#NOTE: This is quite bad way to do this, but until Nix have a proper way to package bun projects it works. See https://github.com/NixOS/nixpkgs/issues/255890
2+
{
3+
description = "A formatter for the Kulala language";
4+
5+
inputs = {
6+
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
7+
8+
flake-parts.url = "github:hercules-ci/flake-parts";
9+
flake-parts.inputs.nixpkgs-lib.follows = "nixpkgs";
10+
};
11+
12+
outputs = inputs @ {
13+
self,
14+
flake-parts,
15+
...
16+
}:
17+
flake-parts.lib.mkFlake {inherit inputs;} {
18+
systems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];
19+
20+
perSystem = {pkgs, ...}: let
21+
# Create a simple wrapper script that uses npx to run kulala-fmt
22+
kulala-fmt = pkgs.writeShellApplication {
23+
name = "kulala-fmt";
24+
runtimeInputs = [pkgs.nodejs];
25+
text = ''
26+
# Run kulala-fmt using npx
27+
exec npx github:mistweaverco/kulala-fmt "$@"
28+
'';
29+
};
30+
in {
31+
packages = {
32+
default = kulala-fmt;
33+
kulala-fmt = kulala-fmt;
34+
};
35+
36+
devShells.default = pkgs.mkShell {
37+
buildInputs = [
38+
pkgs.nodejs
39+
pkgs.bun
40+
];
41+
42+
shellHook = ''
43+
echo "Kulala formatter development environment"
44+
echo "Run 'bun install' to install dependencies"
45+
echo "Run 'bun run build' to build the project"
46+
'';
47+
};
48+
};
49+
};
50+
}

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"type": "module",
55
"scripts": {
66
"build": "rollup -c",
7-
"lint": "eslint ."
7+
"lint": "eslint .",
8+
"prepare": "rollup -c"
89
},
910
"bin": {
1011
"kulala-fmt": "dist/cli.cjs"

0 commit comments

Comments
 (0)