diff --git a/Justfile b/Justfile index c7e157e..a70e622 100755 --- a/Justfile +++ b/Justfile @@ -68,15 +68,32 @@ rebuild-this-device rebuildarg="dry-activate": # --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: +# Update the channel versions and (by default) switch to new environment +update-this-device rebuild-mode='switch': #!/usr/bin/env bash - set -e - export SYSREBUILD_LOG=.$(hostname -s)_sysrebuild.log + set -xe - echo Updating system channels... - sudo nix-channel --update - just -v rebuild-this-device switch + template=nix/os/devices/$(hostname -s)/versions.tmpl.nix + outfile=nix/os/devices/$(hostname -s)/versions.nix + + esh -o ${outfile} ${template} + if ! test "$(git diff ${outfile})"; then + echo Already on latest versions + exit 0 + fi + + export SYSREBUILD_LOG=.$(hostname -s)_sysrebuild.log + just -v rebuild-this-device dry-activate || { + echo ERROR: Update failed, reverting ${outfile}... + git checkout ${outfile} + exit 1 + } + + git commit -v ${outfile} -m "nix/os/devices/$(hostname -s): bump versions" + + just -v rebuild-this-device {{rebuild-mode}} || { + echo WARNING: Rebuilding in {{rebuild-mode}}-mode failed + } # Iterate on a qtile config by running it inside Xephyr. (un-/grab the mouse with Ctrl + Shift-L) hm-iterate-qtile: diff --git a/nix/os/devices/steveej-t480s-work/versions.tmpl.nix b/nix/os/devices/steveej-t480s-work/versions.tmpl.nix new file mode 100644 index 0000000..655e1b1 --- /dev/null +++ b/nix/os/devices/steveej-t480s-work/versions.tmpl.nix @@ -0,0 +1,10 @@ +{ + channelsNixosStable = { + ref = "nixos-18.09"; + rev = "<% git ls-remote https://github.com/nixos/nixpkgs-channels nixos-18.09 | awk '{ print $1 }' | tr -d '\n' -%>"; + }; + channelsNixosUnstable = { + ref = "nixos-unstable"; + rev = "<% git ls-remote https://github.com/nixos/nixpkgs-channels nixos-unstable | awk '{ print $1 }' | tr -d '\n' -%>"; + }; +} diff --git a/shell.nix b/shell.nix index 1c73ef9..d83e92f 100644 --- a/shell.nix +++ b/shell.nix @@ -18,6 +18,8 @@ stdenv.mkDerivation { vncdo tesseract imagemagick + + esh ]; # Set Environment Variables