nixos-edit: command for adding packages

This commit is contained in:
Daniella / Tove 2024-10-23 10:00:30 +02:00
parent b1ea84e3ad
commit 42ddb11d3c
Signed by: TudbuT
GPG key ID: B3CF345217F202D3
2 changed files with 10 additions and 1 deletions

View file

@ -41,6 +41,7 @@ in
hyfetch
libreoffice
(import ./traewelling.script.nix)
#marker.pkgs.end#
] ++ (with pkgs; [
freecad
nheko

View file

@ -14,6 +14,7 @@ pkgs.writeShellScriptBin "nixos-edit" ''
echo " - update -- update the system"
echo " - clean -- does housekeeping"
echo " - init -- initialize the system (only run once)"
echo " - add -- installs a package"
echo
echo "edit is the default mode."
exit 0
@ -84,7 +85,10 @@ pkgs.writeShellScriptBin "nixos-edit" ''
exit
fi
[ "$1" = "edit" ] || [ "$1" = "" ] || [ "$1" = "push" ]
[ "$1" = "edit" ] ||
[ "$1" = "" ] ||
[ "$1" = "push" ] ||
[ "$1" = "add" ]
PUSH=$?
cd /etc/nixos
@ -94,6 +98,10 @@ pkgs.writeShellScriptBin "nixos-edit" ''
if [ "$1" = "edit" ] || [ "$1" = "" ] || [ "$1" = "test" ] ; then
sudo hx .
fi
if [ "$1" = "add" ] ; then
sed -i -E "s/#marker.pkgs.end#/$2\n #marker.pkgs.end#" home.nix
git diff
fi
if [ $PUSH = 0 ] ; then
git add .
EDITOR=hx git commit -a || exit