Commit c11c9293 authored by Christopher League's avatar Christopher League
Browse files

check latest version before updating

parent c17913cd
......@@ -16,6 +16,7 @@ in
./backgrounds.nix
./skel.nix
./fonts.nix
./version.nix
];
config = {
......@@ -58,7 +59,6 @@ in
firefox
flameshot
tmux
(pkgs.callPackage ./update.nix {})
];
};
}
{pkgs, ...}:
pkgs.writeShellScriptBin "liucs-update" ''
# run as root
[[ $(id -un) == root ]] || {
exec sudo -H $0 "$@"
}
set -o xtrace
nix-channel --update liucs
nixos-rebuild switch
''
{
{pkgs, ...}:
let
hash = "$Format:%H$";
date = "$Format:%ci$";
repo = "https://gitlab.liu.edu/league/nixvm.git";
ref = "master";
showVersion = ''
echo '${hash} (${date})'
latest=$(${pkgs.git}/bin/git ls-remote ${repo} ${ref}|cut -f1)
if [[ "${hash}" == "$latest" ]]; then
echo Your system is up to date.
else
echo An update is available.
fi
'';
doUpdate = ''
[[ $(id -un) == root ]] || {
exec sudo -H $0 "$@"
}
set -o xtrace
latest=$(${pkgs.git}/bin/git ls-remote ${repo} ${ref}|cut -f1)
if [[ "${hash}" == "$latest" ]]; then
echo Already up to date.
else
nix-channel --update liucs
nixos-rebuild switch
fi
'';
in
{
environment.systemPackages = [
(pkgs.writeShellScriptBin "liucs-version" showVersion)
(pkgs.writeShellScriptBin "liucs-update" doUpdate)
];
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment