1
0
Fork 0
mirror of https://github.com/nix-community/home-manager.git synced 2025-11-08 19:46:05 +01:00
home-manager/modules/misc/news/create-news-entry.sh
Austin Horstman bc13c13ed7 news: reorganize news into YYYY/MM directory structure
- Update news.nix to recursively search for news entries in
subdirectories
- Update create-news-entry.sh to place new entries in YYYY/MM/
directories
- Move existing 2025 news entries to the new structure

This makes the news directory more organized and easier to navigate.
2025-05-12 22:14:03 -05:00

29 lines
848 B
Bash
Executable file

#!/usr/bin/env nix-shell
#! nix-shell -I https://github.com/NixOS/nixpkgs/archive/05f0934825c2a0750d4888c4735f9420c906b388.tar.gz -i bash -p coreutils
DATE="$(date --iso-8601=second --universal)"
YEAR="$(date --date="$DATE" +"%Y")"
MONTH="$(date --date="$DATE" +"%m")"
FILENAME_BASE="$(date --date="$DATE" +"%Y-%m-%d_%H-%M-%S")"
DIRNAME="$(dirname -- "${BASH_SOURCE[0]}")"
# Create year/month directory structure if it doesn't exist
mkdir -p "$DIRNAME/$YEAR/$MONTH"
cd "$DIRNAME" || {
>&2 echo "Failed to change to the script directory: $DIRNAME"
exit 1
}
cat - << EOF > "$YEAR/$MONTH/$FILENAME_BASE.nix"
{
time = "$DATE";
condition = true;
message = ''
PLACEHOLDER
'';
}
EOF
echo "Successfully created a news file: $DIRNAME/$YEAR/$MONTH/$FILENAME_BASE.nix"
echo "You can open the file above in your text editor and edit now."