nix: add channel configuration and rework update process

This commit is contained in:
steveej 2018-11-03 11:45:40 +01:00
parent 239c2c9c44
commit dd4cd9aaf4
14 changed files with 137 additions and 51 deletions

View file

@ -1,33 +1,45 @@
_usage:
just -l
_device action dir +moreargs="":
#!/usr/bin/env bash
set -e
sudo $(nix-build --no-link --show-trace $(dirname {{dir}})/default.nix -A {{action}} --argstr dir {{dir}} {{moreargs}} )
set -ex
sudo $(set -x; nix-build --no-link --show-trace $(dirname {{dir}})/default.nix -A {{action}} --argstr dir {{dir}} {{moreargs}})
_rebuild-device dir rebuildarg="dry-activate" +moreargs="":
just -v _device rebuild {{dir}} --argstr rebuildarg {{rebuildarg}} {{moreargs}}
_rebuild-device dir rebuildarg="dry-activate":
just -v _device rebuild {{dir}} --argstr rebuildarg {{rebuildarg}}
# Rebulid this device's NixOS
rebuild-this-device rebuildarg="dry-activate":
just -v _rebuild-device nix/os/devices/$(hostname -s) {{rebuildarg}}
# This could be used to inject another channel
# --argstr moreargs "\'-I nixos-unstable=https://nixos.org/channels/nixos-unstable/nixexprs.tar.xz\'"
# Update nix-channels and switch to updated NixOS and home environments
update-this-device:
#!/usr/bin/env bash
export SYSUPDATE_LOG=.$(hostname -s)_sysupdate.log
export HOMEUPDATE_LOG=.$(hostname -s)_homeupdate.log
echo Updating system channels...
sudo nix-channel --update > .$(hostname -s)_sysupdate.log 2>&1
sudo nix-channel --update > ${SYSUPDATE_LOG} 2>&1
echo Updating system...
if just -v rebuild-this-device >> .$(hostname -s)_sysupdate.log 2>&1 ; then
if just -v rebuild-this-device switch >> ${SYSUPDATE_LOG} 2>&1 ; then
echo System update successful
else
System update failed
cat ${SYSUPDATE_LOG}
echo System update failed
fi
if type home-manager > /dev/null 2>&1; then
echo Updating home...
if home-manager -v switch > .$(hostname -s)_homeupdate.log 2>&1 ; then
if home-manager -v switch > ${HOMEUPDATE_LOG} 2>&1 ; then
echo Home update successful
else
else
cat ${HOMEUPDATE_LOG}
echo Home update failed
fi
fi