From 74eb3db41ac5e85207ac0c9dad30bb615f2e5a18 Mon Sep 17 00:00:00 2001 From: Lillian-Violet Date: Tue, 12 Mar 2024 14:42:33 +0100 Subject: [PATCH] Add update and upgrade commands --- pkgs/update/default.nix | 29 +++++++++++++++++++++++++++++ pkgs/upgrade/default.nix | 17 +++++++++++++++++ 2 files changed, 46 insertions(+) create mode 100644 pkgs/update/default.nix create mode 100644 pkgs/upgrade/default.nix diff --git a/pkgs/update/default.nix b/pkgs/update/default.nix new file mode 100644 index 0000000..dd7dc4e --- /dev/null +++ b/pkgs/update/default.nix @@ -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!" + ''; +} diff --git a/pkgs/upgrade/default.nix b/pkgs/upgrade/default.nix new file mode 100644 index 0000000..c1e91b0 --- /dev/null +++ b/pkgs/upgrade/default.nix @@ -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 + ''; +}