Justfile: implement update-remote-device
This bumps the versions for the remote device, attempts a rebuild and commits the resulting versions if the rebuild succeeded.
This commit is contained in:
parent
5f2f499471
commit
2c9da1f12e
2 changed files with 47 additions and 4 deletions
36
Justfile
36
Justfile
|
@ -1,3 +1,6 @@
|
||||||
|
_DEFAULT_VERSION_TMPL:
|
||||||
|
echo "{{invocation_directory()}}/nix/variables/versions.tmpl.nix"
|
||||||
|
|
||||||
_usage:
|
_usage:
|
||||||
just -l
|
just -l
|
||||||
|
|
||||||
|
@ -21,10 +24,10 @@ _rebuild-device dir rebuildarg="dry-activate" +moreargs="": _render_templates
|
||||||
set -ex
|
set -ex
|
||||||
just -v _device rebuild {{dir}} --argstr rebuildarg {{rebuildarg}} {{moreargs}}
|
just -v _device rebuild {{dir}} --argstr rebuildarg {{rebuildarg}} {{moreargs}}
|
||||||
|
|
||||||
rebuild-remote-device dir target rebuildarg="dry-activate" :
|
rebuild-remote-device device target rebuildarg="dry-activate" :
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
set -ex
|
set -ex
|
||||||
just -v _rebuild-device {{dir}} {{rebuildarg}} --argstr moreargs "'--target-host\ {{target}}'"
|
just -v _rebuild-device nix/os/devices/{{device}} {{rebuildarg}} --argstr moreargs "'--target-host\ {{target}}'"
|
||||||
|
|
||||||
# Rebuild this device's NixOS
|
# Rebuild this device's NixOS
|
||||||
rebuild-this-device rebuildarg="dry-activate":
|
rebuild-this-device rebuildarg="dry-activate":
|
||||||
|
@ -66,9 +69,34 @@ rebuild-this-device rebuildarg="dry-activate":
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# This could be used to inject another channel
|
update-remote-device device target rebuildmode='switch':
|
||||||
# --argstr moreargs "\'-I nixos-unstable=https://nixos.org/channels/nixos-unstable/nixexprs.tar.xz\'"
|
#!/usr/bin/env bash
|
||||||
|
set -e
|
||||||
|
|
||||||
|
template=nix/os/devices/{{device}}/versions.tmpl.nix
|
||||||
|
outfile=nix/os/devices/{{device}}/versions.nix
|
||||||
|
|
||||||
|
if ! test -e ${template}; then
|
||||||
|
template="$(just _DEFAULT_VERSION_TMPL)"
|
||||||
|
fi
|
||||||
|
|
||||||
|
esh -o ${outfile} ${template}
|
||||||
|
if ! test "$(git diff ${outfile})"; then
|
||||||
|
echo Already on latest versions
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
just -v rebuild-remote-device {{device}} {{target}} dry-activate || {
|
||||||
|
echo ERROR: rebuild in mode 'dry-active' failed after updating ${outfile}
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
just -v rebuild-remote-device {{ device }} {{ target }} {{ rebuildmode }} || {
|
||||||
|
echo ERROR: rebuild in mode '{{ rebuildmode }}' failed after updating ${outfile}
|
||||||
|
exit 1
|
||||||
|
}
|
||||||
|
|
||||||
|
git commit -v ${outfile} -m "nix/os/devices/{{ device }}: bump versions"
|
||||||
|
|
||||||
# Update the channel versions and (by default) switch to new environment
|
# Update the channel versions and (by default) switch to new environment
|
||||||
update-this-device rebuild-mode='switch':
|
update-this-device rebuild-mode='switch':
|
||||||
|
|
15
nix/variables/versions.tmpl.nix
Normal file
15
nix/variables/versions.tmpl.nix
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
channelsNixosStable = {
|
||||||
|
ref = "nixos-19.03";
|
||||||
|
rev = "<% git ls-remote https://github.com/nixos/nixpkgs-channels nixos-19.03 | 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' -%>";
|
||||||
|
};
|
||||||
|
homeManagerModule = {
|
||||||
|
url = "https://github.com/rycee/home-manager";
|
||||||
|
ref = "master";
|
||||||
|
rev = "<% git ls-remote https://github.com/rycee/home-manager.git master | awk '{ print $1 }' | tr -d '\n' -%>";
|
||||||
|
};
|
||||||
|
}
|
Loading…
Add table
Add a link
Reference in a new issue