nixconf/packages/sysupdate/default.nix

26 lines
556 B
Nix
Raw Normal View History

{
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
'';
}