Changes sysupdate to package instead of shell.
This commit is contained in:
parent
75a2a93d37
commit
0959b72aa1
25
packages/sysupdate/default.nix
Normal file
25
packages/sysupdate/default.nix
Normal file
|
@ -0,0 +1,25 @@
|
|||
{
|
||||
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
|
||||
'';
|
||||
}
|
|
@ -1,21 +0,0 @@
|
|||
{
|
||||
pkgs,
|
||||
inputs,
|
||||
...
|
||||
}:
|
||||
|
||||
pkgs.mkShell {
|
||||
packages = with pkgs; [
|
||||
nix-output-monitor nixos-rebuild home-manager
|
||||
];
|
||||
|
||||
NIXCONF = inputs.self;
|
||||
|
||||
shellHook = ''
|
||||
alias sysupdate-nixos='sudo echo -n; sudo nixos-rebuild switch --log-format internal-json -v --flake "$NIXCONF" |& nom --json'
|
||||
alias sysupdate-home='home-manager switch -L --flake "$NIXCONF" |& nom'
|
||||
echo System Update Shell for flake at $NIXCONF
|
||||
echo Run 'sysupdate-nixos' to update system,
|
||||
echo then 'sysupdate-home' to update user profile.
|
||||
'';
|
||||
}
|
Loading…
Reference in a new issue