<commit_before>#! @bash@/bin/sh -e

default=$1
if test -z "$1"; then
    echo "Syntax: grub-menu-builder.sh <DEFAULT-CONFIG>"
    exit 1
fi


target=/boot/grub/menu.lst
tmp=$target.tmp

cat > $tmp << GRUBEND
# Automatically generated.  DO NOT EDIT THIS FILE!
default=0
timeout=5
GRUBEND

addEntry() {
    name="$1"
    path="$2"

    cat >> $tmp << GRUBEND
title $name
GRUBEND

    #cat $path/menu.lst >> $tmp

    grep -v "title \|default=\|timeout=" < $path/menu.lst >> $tmp
}


if test -n "$tmp"; then
    addEntry "NixOS - Default" $default
fi


# Add all generations of the system profile to the menu, in reverse
# (most recent to least recent) order.
for generation in $(
    (cd /nix/var/nix/profiles && ls -d system-*-link) \
    | sed 's/system-\([0-9]\+\)-link/\1/' \
    | sort -n -r); do
    echo $generation
    addEntry "NixOS - Configuration $generation" \
        /nix/var/nix/profiles/system-$generation-link
done


cp $tmp $target<commit_msg>* Put the date of each configuration in the Grub menu.<commit_after>#! @bash@/bin/sh -e

default=$1
if test -z "$1"; then
    echo "Syntax: grub-menu-builder.sh <DEFAULT-CONFIG>"
    exit 1
fi


target=/boot/grub/menu.lst
tmp=$target.tmp

cat > $tmp << GRUBEND
# Automatically generated.  DO NOT EDIT THIS FILE!
default=0
timeout=5
GRUBEND

addEntry() {
    name="$1"
    path="$2"

    cat >> $tmp << GRUBEND
title $name
GRUBEND

    #cat $path/menu.lst >> $tmp

    grep -v "title \|default=\|timeout=" < $path/menu.lst >> $tmp
}


if test -n "$tmp"; then
    addEntry "NixOS - Default" $default
fi


# Add all generations of the system profile to the menu, in reverse
# (most recent to least recent) order.
for generation in $(
    (cd /nix/var/nix/profiles && ls -d system-*-link) \
    | sed 's/system-\([0-9]\+\)-link/\1/' \
    | sort -n -r); do
    echo $generation
    link=/nix/var/nix/profiles/system-$generation-link
    date=$(stat --printf="%y\n" $link | sed 's/\..*//')
    addEntry "NixOS - Configuration $generation ($date)" $link
        
done


cp $tmp $target
{'fraction_non_alphanumeric': 0.16478666012751347, 'fraction_numerical': 0.00980872976949485, 'mean_word_length': 2.79182156133829, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5293206', 'n_tokens_mistral': 763, 'n_tokens_neox': 723, 'n_words': 220}