mirror of
https://codeberg.org/mtxyz/nixconf.git
synced 2024-11-09 10:01:57 +00:00
26 lines
556 B
Nix
26 lines
556 B
Nix
|
{
|
||
|
pkgs,
|
||
|
...
|
||
|
}:
|
||
|
|
||
|
pkgs.writeShellApplication {
|
||
|
name = "sysupdate";
|
||
|
|
||
|
runtimeInputs = with pkgs; [
|
||
|
nix-output-monitor nixos-rebuild home-manager
|
||
|
];
|
||
|
|
||
|
text = ''
|
||
|
NIXCONF="''${NIXCONF:-.}"
|
||
|
echo Building config from flake at: "$NIXCONF" 1>&2
|
||
|
[[ "''${1:-}" == "home" ]] && \
|
||
|
home-manager switch -L --flake "$NIXCONF" |& nom && \
|
||
|
exit 0
|
||
|
[ "$EUID" -eq 0 ] && \
|
||
|
nixos-rebuild switch --log-format internal-json -v --flake "$NIXCONF" |& nom --json && \
|
||
|
exit 0
|
||
|
echo Please rerun as root. 1>&2
|
||
|
exit 1
|
||
|
'';
|
||
|
}
|