From 52a50108912010f9e194ff3e92ad1c2e93c43291 Mon Sep 17 00:00:00 2001 From: Lillian-Violet Date: Mon, 26 Feb 2024 14:17:34 +0100 Subject: [PATCH] add rebuild command (untested) --- nixos/shared/packages/default.nix | 12 ++++++++++++ pkgs/default.nix | 1 + pkgs/rebuild/default.nix | 27 +++++++++++++++++++++++++++ 3 files changed, 40 insertions(+) create mode 100644 pkgs/rebuild/default.nix diff --git a/nixos/shared/packages/default.nix b/nixos/shared/packages/default.nix index 5c6c5c2..1182fbb 100644 --- a/nixos/shared/packages/default.nix +++ b/nixos/shared/packages/default.nix @@ -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 diff --git a/pkgs/default.nix b/pkgs/default.nix index 998cdfa..7569bfa 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -4,4 +4,5 @@ pkgs: { dvd = pkgs.callPackage ./dvd {}; dvt = pkgs.callPackage ./dvt {}; servo = pkgs.callPackage ./servo {}; + rebuild = pkgs.callPackage ./rebuild {}; } diff --git a/pkgs/rebuild/default.nix b/pkgs/rebuild/default.nix new file mode 100644 index 0000000..50a57fc --- /dev/null +++ b/pkgs/rebuild/default.nix @@ -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 + ''; +}