mirror of
https://github.com/nix-community/home-manager.git
synced 2025-12-16 14:01:08 +01:00
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.
This commit is contained in:
parent
f0a7db5ec1
commit
bc13c13ed7
27 changed files with 28 additions and 6 deletions
|
|
@ -55,12 +55,29 @@ let
|
||||||
);
|
);
|
||||||
|
|
||||||
isNixFile = n: v: v == "regular" && lib.hasSuffix ".nix" n;
|
isNixFile = n: v: v == "regular" && lib.hasSuffix ".nix" n;
|
||||||
# builtins.attrNames return the values in alphabetical order
|
isDirectory = n: v: v == "directory";
|
||||||
newsFiles = builtins.attrNames (lib.filterAttrs isNixFile (builtins.readDir ./news));
|
|
||||||
|
# Recursively collect all .nix files from a directory
|
||||||
|
collectNixFiles =
|
||||||
|
dir:
|
||||||
|
let
|
||||||
|
contents = builtins.readDir dir;
|
||||||
|
files = lib.filterAttrs isNixFile contents;
|
||||||
|
fileList = map (file: dir + "/${file}") (builtins.attrNames files);
|
||||||
|
|
||||||
|
# Process subdirectories
|
||||||
|
subdirs = lib.filterAttrs isDirectory contents;
|
||||||
|
subdirFiles = lib.concatMap (subdir: collectNixFiles (dir + "/${subdir}")) (
|
||||||
|
builtins.attrNames subdirs
|
||||||
|
);
|
||||||
|
in
|
||||||
|
fileList ++ subdirFiles;
|
||||||
|
|
||||||
|
newsFiles = collectNixFiles ./news;
|
||||||
newsEntries = builtins.map (
|
newsEntries = builtins.map (
|
||||||
newsFile:
|
newsFile:
|
||||||
let
|
let
|
||||||
imported = import (./news + "/${newsFile}");
|
imported = import newsFile;
|
||||||
in
|
in
|
||||||
if builtins.isFunction imported then imported { inherit config lib pkgs; } else imported
|
if builtins.isFunction imported then imported { inherit config lib pkgs; } else imported
|
||||||
) newsFiles;
|
) newsFiles;
|
||||||
|
|
|
||||||
|
|
@ -2,15 +2,20 @@
|
||||||
#! nix-shell -I https://github.com/NixOS/nixpkgs/archive/05f0934825c2a0750d4888c4735f9420c906b388.tar.gz -i bash -p coreutils
|
#! nix-shell -I https://github.com/NixOS/nixpkgs/archive/05f0934825c2a0750d4888c4735f9420c906b388.tar.gz -i bash -p coreutils
|
||||||
|
|
||||||
DATE="$(date --iso-8601=second --universal)"
|
DATE="$(date --iso-8601=second --universal)"
|
||||||
FILENAME="$(date --date="$DATE" +"%Y-%m-%d_%H-%M-%S").nix"
|
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]}")"
|
DIRNAME="$(dirname -- "${BASH_SOURCE[0]}")"
|
||||||
|
|
||||||
|
# Create year/month directory structure if it doesn't exist
|
||||||
|
mkdir -p "$DIRNAME/$YEAR/$MONTH"
|
||||||
|
|
||||||
cd "$DIRNAME" || {
|
cd "$DIRNAME" || {
|
||||||
>&2 echo "Failed to change to the script directory: $DIRNAME"
|
>&2 echo "Failed to change to the script directory: $DIRNAME"
|
||||||
exit 1
|
exit 1
|
||||||
}
|
}
|
||||||
|
|
||||||
cat - << EOF > "$FILENAME"
|
cat - << EOF > "$YEAR/$MONTH/$FILENAME_BASE.nix"
|
||||||
{
|
{
|
||||||
time = "$DATE";
|
time = "$DATE";
|
||||||
condition = true;
|
condition = true;
|
||||||
|
|
@ -20,5 +25,5 @@ cat - << EOF > "$FILENAME"
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
echo "Successfully created a news file: $DIRNAME/$FILENAME"
|
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."
|
echo "You can open the file above in your text editor and edit now."
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue