Move custom packages

This commit is contained in:
Oliver Davies 2025-08-25 18:35:31 +01:00
parent 386c68813a
commit 23cc6c99a0
7 changed files with 87 additions and 66 deletions

View file

@ -0,0 +1,33 @@
{
perSystem =
{ pkgs, ... }:
{
packages.new-draft = pkgs.writeShellApplication {
name = "new-draft";
runtimeInputs = with pkgs; [
coreutils
git
];
text = ''
title="$1"
exclude_words="for|at|and"
filtered_title=$(echo "$title" | sed -E "s/\b($exclude_words)\b//g")
slug=$(echo "$filtered_title" | tr '[:upper:]' '[:lower:]' | sed -e 's/[^a-z0-9]/-/g' -e 's/-\+/-/g' -e 's/^-//g' -e 's/-$//g')
file="source/_posts/$slug.md"
echo -e "---\ntitle: $title\ndate: ~\ndraft: true\n---" > "$file"
echo "File created: $file"
git add "$file"
git commit -s -m "Add draft: $title"
'';
};
};
}