From 2445d9f8d4ca74e7fed7099b935c344ca718857c Mon Sep 17 00:00:00 2001 From: Winter Date: Sun, 10 Aug 2025 02:55:09 -0400 Subject: [PATCH] nix: add script to do the lexgen dance Change-Id: yswowtpnywsowlxvvpnouplzmsvqutto h/t https://github.com/bluesky-social/indigo/issues/931#issuecomment-2635675099 for the inspiration Signed-off-by: Winter --- flake.nix | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/flake.nix b/flake.nix index 41522b5..af0e8e7 100644 --- a/flake.nix +++ b/flake.nix @@ -189,6 +189,31 @@ ${gomod2nix.legacyPackages.${system}.gomod2nix}/bin/gomod2nix generate --outdir ./nix ''); }; + lexgen = { + type = "app"; + program = + (pkgs.writeShellApplication { + name = "lexgen"; + text = '' + if ! command -v lexgen > /dev/null; then + echo "error: must be executed from devshell" + exit 1 + fi + + rootDir=$(jj --ignore-working-copy root || git rev-parse --show-toplevel) || (echo "error: can't find repo root?"; exit 1) + cd "$rootDir" + + rm api/tangled/* + lexgen --build-file lexicon-build-config.json lexicons + sed -i.bak 's/\tutil/\/\/\tutil/' api/tangled/* + ${pkgs.gotools}/bin/goimports -w api/tangled/* + go run cmd/gen.go + lexgen --build-file lexicon-build-config.json lexicons + rm api/tangled/*.bak + ''; + }) + + /bin/lexgen; + }; }); nixosModules.appview = { -- 2.43.0