Skip to content

Commit

Permalink
feat: add nvfetcher blocktype
Browse files Browse the repository at this point in the history
  • Loading branch information
blaggacao committed Feb 18, 2024
1 parent f7e9aaf commit d3873fc
Showing 1 changed file with 47 additions and 0 deletions.
47 changes: 47 additions & 0 deletions src/std/fwlib/blockTypes/nvfetcher.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
{
root,
super,
}:
/*
Use the nvfetcher Blocktype in order to instrucement sources
with nvfetcher. See its docs for more details.
Available actions:
- fetch
*/
let
inherit (root) mkCommand actions;
inherit (super) addSelectorFunctor;
in
name: {
__functor = addSelectorFunctor;
inherit name;
type = "nvfetcher";
actions = {
currentSystem,
fragment,
fragmentRelPath,
target,
inputs,
}: let
pkgs = inputs.nixpkgs.${currentSystem};
inherit (pkgs) lib;
inherit (pkgs.stdenv) isLinux;
in [
(mkCommand currentSystem "fetch" "update source" [pkgs.nvfetcher] ''
targetname="$(basename ${fragmentRelPath})"
blockpath="$(dirname ${fragmentRelPath})"
cellpath="$(dirname "$blockpath")"
tmpfile="$(mktemp)"
updates="$PRJ_ROOT/${fragmentRelPath}.md"
nvfetcher \
--config "$PRJ_ROOT/$cellpath/nvfetcher.toml" \
--build-dir "$PRJ_ROOT/$blockpath" \
--changelog "$tmpfile" \
--filter "^$targetname$"
sed -i -e "s|^|- \`$(date --iso-8601=m)\` |" "$tmpfile"
cat "$tmpfile" >> "$updates"
'' {})
];
}

0 comments on commit d3873fc

Please sign in to comment.