nixos-config/shell.nix

35 lines
957 B
Nix
Raw Normal View History

2020-11-14 10:15:41 +01:00
let
sources = import ./nix/sources.nix;
pkgs = import sources.nixpkgs { };
2020-08-22 17:44:39 +02:00
2020-11-14 10:15:41 +01:00
nix-pre-commit-hooks = import sources."pre-commit-hooks.nix";
pre-commit-check = nix-pre-commit-hooks.run {
src = ./.;
hooks = {
nixpkgs-fmt.enable = true;
};
};
2020-12-13 16:02:55 +01:00
update-sources = pkgs.writeShellScriptBin "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
'';
2020-11-14 10:15:41 +01:00
in
2020-08-22 17:44:39 +02:00
pkgs.mkShell {
2020-12-13 16:02:55 +01:00
nativeBuildInputs = (with pkgs; [
2020-11-14 10:15:41 +01:00
git
niv
2020-08-22 17:44:39 +02:00
nixpkgs-fmt
2020-12-13 16:02:55 +01:00
]) ++ [
update-sources
2020-08-22 17:44:39 +02:00
];
shellHook = ''
2020-11-14 10:15:41 +01:00
${pre-commit-check.shellHook}
2020-08-22 17:44:39 +02:00
'';
}