add rebuild command (untested)

This commit is contained in:
Lillian Violet 2024-02-26 14:17:34 +01:00
parent 983e994930
commit 52a5010891
3 changed files with 40 additions and 0 deletions

View file

@ -6,7 +6,19 @@
pkgs,
...
}: {
nixpkgs = {
# You can add overlays here
overlays = [
# Add overlays your own flake exports (from overlays and pkgs dir):
outputs.overlays.additions
outputs.overlays.modifications
];
};
environment.systemPackages = with pkgs; [
# Custom tools
rebuild
# System tools
age
alejandra

View file

@ -4,4 +4,5 @@ pkgs: {
dvd = pkgs.callPackage ./dvd {};
dvt = pkgs.callPackage ./dvt {};
servo = pkgs.callPackage ./servo {};
rebuild = pkgs.callPackage ./rebuild {};
}

27
pkgs/rebuild/default.nix Normal file
View file

@ -0,0 +1,27 @@
{
lib,
stdenv,
writeShellApplication,
}:
writeShellApplication
{
name = "rebuild";
runtimeInputs = [];
text = ''
# A rebuild script for NixOS
set -e
pushd /tmp
git clone forgejo@git.lillianviolet.dev:Lillian-Violet/NixOS-Config.git ./rebuild
$hostname=$(hostname)
pushd ./rebuild
echo "NixOS Rebuilding..."
sudo nixos-rebuild switch --flake #$hostname &>nixos-switch.log || (cat nixos-switch.log | grep --color error && false)
popd
echo "Cleaning up repository in tmp..."
rm -rf ./rebuild
popd
notify-send -e "NixOS Rebuilt OK!" --icon=software-update-available
'';
}