40 lines
1.1 KiB
Nix
40 lines
1.1 KiB
Nix
let
|
|
sources = import ./nix/sources.nix;
|
|
pkgs = import sources.nixpkgs { };
|
|
|
|
nix-pre-commit-hooks = import sources."pre-commit-hooks.nix";
|
|
|
|
pre-commit-check = nix-pre-commit-hooks.run {
|
|
src = ./.;
|
|
hooks = {
|
|
nixpkgs-fmt.enable = true;
|
|
};
|
|
};
|
|
|
|
scripts = {
|
|
update-sources = ''
|
|
set -e
|
|
git diff --exit-code -s nix/sources.json || (echo "File nix/sources.json has unstaged changes, refusing to update." >&2 && exit 1)
|
|
git diff --cached --exit-code -s nix/sources.json || (echo "File nix/sources.json has staged changes, refusing to update." >&2 && exit 1)
|
|
niv update
|
|
git diff --exit-code -s nix/sources.json && echo "Already up to date." && exit 0
|
|
git commit -m "Update sources" nix/sources.json
|
|
'';
|
|
|
|
deploy = ''
|
|
set -e
|
|
$(nix-build --no-out-link deploy.nix -A "$1")
|
|
'';
|
|
};
|
|
in
|
|
pkgs.mkShell {
|
|
buildInputs = (with pkgs; [
|
|
git
|
|
niv
|
|
nixpkgs-fmt
|
|
]) ++ (builtins.attrValues (builtins.mapAttrs pkgs.writeShellScriptBin scripts));
|
|
shellHook = ''
|
|
${pre-commit-check.shellHook}
|
|
'';
|
|
}
|