24 current 2024-04-17 17:19:51 23.11.20240405.72da83d 6.1.84 *
This commit is contained in:
25
modules/bin/nix-scripts.nix
Normal file
25
modules/bin/nix-scripts.nix
Normal file
@@ -0,0 +1,25 @@
|
||||
{
|
||||
config,
|
||||
pkgs,
|
||||
...
|
||||
}: let
|
||||
rebuild =
|
||||
pkgs.writeShellScriptBin ".nixos-rebuild"
|
||||
''
|
||||
set -e
|
||||
pushd ~/.nixos/
|
||||
${pkgs.alejandra}/bin/alejandra . &>/dev/null
|
||||
${pkgs.git}/bin/git diff -U0 *.nix
|
||||
echo "NixOS Rebuilding..."
|
||||
sudo nixos-rebuild switch --flake . &>nixos-switch.log || (
|
||||
${pkgs.coreutils-full}/bin/cat nixos-switch.log | ${pkgs.gnugrep}/bin/grep --color error && false)
|
||||
gen=$(nixos-rebuild list-generations | ${pkgs.gnugrep}/bin/grep current)
|
||||
${pkgs.git}/bin/git commit -am "$gen"
|
||||
popd
|
||||
'';
|
||||
in {
|
||||
environment.systemPackages = [
|
||||
pkgs.bash
|
||||
rebuild
|
||||
];
|
||||
}
|
||||
Reference in New Issue
Block a user