Auto-upgrade: Use builtins instead of some dependencies

This commit is contained in:
fruchti 2023-06-11 18:54:17 +02:00
parent d9611fade1
commit ef4ad4da58

View file

@ -44,9 +44,6 @@ in
let let
nixos-rebuild = "${config.system.build.nixos-rebuild}/bin/nixos-rebuild"; nixos-rebuild = "${config.system.build.nixos-rebuild}/bin/nixos-rebuild";
nix-store = "${pkgs.nix}/bin/nix-store"; nix-store = "${pkgs.nix}/bin/nix-store";
date = "${pkgs.coreutils}/bin/date";
readlink = "${pkgs.coreutils}/bin/readlink";
grep = "${pkgs.gnugrep}/bin/grep";
diff = "${pkgs.diffutils}/bin/diff"; diff = "${pkgs.diffutils}/bin/diff";
git = "${pkgs.git}/bin/git"; git = "${pkgs.git}/bin/git";
ssh = "${pkgs.openssh}/bin/ssh"; ssh = "${pkgs.openssh}/bin/ssh";
@ -64,7 +61,7 @@ in
done <<< "$1" done <<< "$1"
} }
start_time="$(${date})" start_time="$(date)"
reboot_allowed="no" reboot_allowed="no"
activate_configuration="yes" activate_configuration="yes"
do_reboot="no" do_reboot="no"
@ -135,8 +132,8 @@ in
<(printf "New generation\n--------------\n%s" "$built_packages") \ <(printf "New generation\n--------------\n%s" "$built_packages") \
| tee -a "$output_file" || true | tee -a "$output_file" || true
booted_version="$(${readlink} /run/booted-system/{initrd,kernel,kernel-modules})" booted_version="$(readlink /run/booted-system/{initrd,kernel,kernel-modules})"
built_version="$(${readlink} /nix/var/nix/profiles/system/{initrd,kernel,kernel-modules})" built_version="$(readlink /nix/var/nix/profiles/system/{initrd,kernel,kernel-modules})"
echo " Checking if a reboot is needed." | tee -a "$output_file" echo " Checking if a reboot is needed." | tee -a "$output_file"
if [ "$booted_version" != "$built_version" ] ; then if [ "$booted_version" != "$built_version" ] ; then
@ -181,7 +178,7 @@ in
upgrade_output="$(cat "$output_file")" upgrade_output="$(cat "$output_file")"
rm -f "$output_file" rm -f "$output_file"
possible_warnings="$(${grep} -e "^\(warning\|trace\):" <<<"$upgrade_output" || true)" possible_warnings="$(grep -e "^\(warning\|trace\):" <<<"$upgrade_output" || true)"
if [ "$possible_warnings" != "" ] ; then if [ "$possible_warnings" != "" ] ; then
send_email=yes send_email=yes
email_subject_additions="$email_subject_additions with warnings" email_subject_additions="$email_subject_additions with warnings"