autogenerate type declarations via nix derivation
1 file changed, 20 insertions(+), 0 deletions(-)
changed files
M shell.nix → shell.nix
@@ -1,9 +1,29 @@ { pkgs ? (import <nixpkgs> { }), + lib ? pkgs.lib, }: +let + types = pkgs.runCommand "dnscontrol-types" { + runtimeInputs = [ pkgs.dnscontrol ]; + } "${lib.getExe pkgs.dnscontrol} write-types -o $out"; + update-types = '' + f="types-dnscontrol.d.ts" + if [[ -e "$f" && ! -L "$f" ]] + then + echo "warn: file $f already exists, not updating. Remove to enable automatic updates." >&2 + elif [[ ! ( -L "$f" && "$(readlink -f "$f")" == "${types}" ) ]] + then + ln -sf "${types}" "$f" + fi + ''; +in pkgs.mkShellNoCC { packages = with pkgs; [ dnscontrol prettier + + # fallback for using lorri (shellHook doesn't work as expected) + (writeShellScriptBin "update-types" update-types) ]; + shellHook = update-types; }