Skip to content

Commit

Permalink
emacsPackages: combine elpa-* and nongnu-* update scripts
Browse files Browse the repository at this point in the history
They are identical except for the parameters they use.
Let's merge them in a single script.

Now they can be called via `./update-package-sets <package sets>`.
  • Loading branch information
AndersonTorres committed Dec 6, 2024
1 parent 565c2f3 commit ef1aa4e
Show file tree
Hide file tree
Showing 5 changed files with 54 additions and 24 deletions.
6 changes: 0 additions & 6 deletions pkgs/applications/editors/emacs/elisp-packages/update-elpa

This file was deleted.

This file was deleted.

6 changes: 0 additions & 6 deletions pkgs/applications/editors/emacs/elisp-packages/update-nongnu

This file was deleted.

This file was deleted.

54 changes: 54 additions & 0 deletions pkgs/applications/editors/emacs/elisp-packages/update-package-sets
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
#! /usr/bin/env nix-shell
#! nix-shell --show-trace ./emacs2nix.nix -i bash

usage(){
cat<<-EOF
Usage: update-package-sets args
args can be at least one from: elpa-devel, elpa, nongnu-devel, nongnu.
EOF
}

update_set(){
local PKGSET="$1"

local output="${PKGSET}-generated.nix"
local script="${PKGSET}-packages.sh"

eval "${script} --names ${EMACS2NIX}/names.nix -o ${output}"
nixfmt "${output}"
}

main(){
local SETS=( )

while (( $# )); do
case $1 in
"elpa-devel" | "elpa" | "nongnu-devel" | "nongnu")
# Do not include duplicates
if [[ ! ${SETS[@]} =~ $1 ]]; then
SETS+=( "$1" )
fi
shift
;;
"melpa" | "melpa-stable")
# Let's warn the user of the correct script and go on
echo "This script does not generate the MELPA package set."
echo "Use update-melpa script instead."
shift
;;
*)
echo "Unknown package set: $1"
usage
exit 1
;;
esac
done

for SET in "${SETS[@]}"; do
echo "${SET}: updating..."
update_set "${SET}"
echo "${SET}: updated"
done
}

main "$@"

0 comments on commit ef1aa4e

Please sign in to comment.