shell.nix (view raw)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 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;
}
|