Add update and upgrade commands

This commit is contained in:
Lillian Violet 2024-03-12 14:42:33 +01:00
parent 50f21e221a
commit 74eb3db41a
2 changed files with 46 additions and 0 deletions

29
pkgs/update/default.nix Normal file
View file

@ -0,0 +1,29 @@
{
lib,
stdenv,
writeShellApplication,
}:
writeShellApplication
{
name = "update";
runtimeInputs = [];
text = ''
# A script to update the flake lock for NixOS
set -e
pushd /tmp > /dev/null
rm -rf ./update
git clone https://git.lillianviolet.dev/Lillian-Violet/NixOS-Config.git ./update
pushd ./update > /dev/null
echo "Updating flake lock..."
nix flake update
git commit -m "update flake lock"
git push
popd > /dev/null
echo "Cleaning up repository in '/tmp/update'..."
rm -rf ./update
popd > /dev/null
echo "Flake lock update OK!"
'';
}

17
pkgs/upgrade/default.nix Normal file
View file

@ -0,0 +1,17 @@
{
lib,
stdenv,
writeShellApplication,
}:
writeShellApplication
{
name = "rebuild";
runtimeInputs = [];
text = ''
# An upgrade script for nixos
sudo systemd-inhibit --who="NixOS Updater" --why="Updating flake lock" update
sudo systemd-inhibit --who="NixOS Updater" --why="Updating system configuration" rebuild-no-inhibit
'';
}