Skip to content

Commit

Permalink
Enforce synchronisation of pin-depends with flake.lock (#24)
Browse files Browse the repository at this point in the history
  • Loading branch information
Niols authored May 1, 2023
1 parent b83c012 commit f32658c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
29 changes: 29 additions & 0 deletions .nix/sync-pin-depends.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
{ ... }: {
perSystem = { pkgs, ... }:
let
sync-pin-depends = pkgs.writeShellApplication {
name = "sync-pin-depends";
text = ''
printf "Finding revision or Morbig in \`flake.lock\`... "
rev=$(jq -r .nodes.morbig.locked.rev flake.lock)
printf 'done! got %s.\n' "$rev"
printf "Writing it in \`morsmall.opam.template\`... "
sed -i "s|morbig#\(.*\)\"|morbig#$rev\"|" morsmall.opam.template
printf 'done.\n'
'';
runtimeInputs = with pkgs; [ jq ];
};
in {
apps.sync-pin-depends = {
type = "app";
program = sync-pin-depends;
};

pre-commit.settings.hooks.sync-pin-depends = {
enable = true;
entry = "${sync-pin-depends}/bin/sync-pin-depends";
files = "(flake\\.lock$)|(\\.opam\\.template$)";
pass_filenames = false;
};
};
}
1 change: 1 addition & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
imports = [
./.nix/with-nixpkgs.nix
./.nix/with-opam-nix.nix
./.nix/sync-pin-depends.nix
inputs.pre-commit-hooks.flakeModule
];

Expand Down

0 comments on commit f32658c

Please sign in to comment.