Skip to content

Instantly share code, notes, and snippets.

@cleverca22
Created April 12, 2020 16:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cleverca22/7c3abf475b1ef649ab1ed6d042ee72ab to your computer and use it in GitHub Desktop.
Save cleverca22/7c3abf475b1ef649ab1ed6d042ee72ab to your computer and use it in GitHub Desktop.
[clever@amd-nixos:~]$ cat /etc/systemd/system/kexec.target.wants/prepare-kexec.service
[Unit]
Before=systemd-kexec.service
DefaultDependencies=false
Description=Preparation for kexec
[Service]
Environment="LOCALE_ARCHIVE=/nix/store/bxvgw2bw2xsjpl132q5553c3dbmk8a8z-glibc-locales-2.27/lib/locale/locale-archive"
Environment="PATH=/nix/store/v1qk9fda4xgdsn3ik96cxdzlmbli9mpp-kexec-tools-2.0.20/bin:/nix/store/gnw6yrqy249n62r4q8vy12ispviv3dav-coreutils-8.31/bin:/nix/store/5khv52whjiwr3ajszxqwz5rgjms8g3mb-findutils-4.7.0/bin:/nix/store/adg7sif4n4v679ibxqzjp59x15nplbnx-gnugrep-3.3/bin:/nix/store/sqwrm4jpc3j5ghfm1rv8rnkqvifqqbs2-gnused-4.7/bin:/nix/store/xdmdlw4m1ad99xm6y5wrmx655iadfza7-systemd-243/bin:/nix/store/v1qk9fda4xgdsn3ik96cxdzlmbli9mpp-kexec-tools-2.0.20/sbin:/nix/store/gnw6yrqy249n62r4q8vy12ispviv3dav-coreutils-8.31/sbin:/nix/store/5khv52whjiwr3ajszxqwz5rgjms8g3mb-findutils-4.7.0/sbin:/nix/store/adg7sif4n4v679ibxqzjp59x15nplbnx-gnugrep-3.3/sbin:/nix/store/sqwrm4jpc3j5ghfm1rv8rnkqvifqqbs2-gnused-4.7/sbin:/nix/store/xdmdlw4m1ad99xm6y5wrmx655iadfza7-systemd-243/sbin"
Environment="TZDIR=/nix/store/l2z3c3p95f4125x2gjmvn93qriisfcxk-tzdata-2019b/share/zoneinfo"
ExecStart=/nix/store/2claa6ilb3ksamdw3mj6qcm402lrajf6-unit-script-prepare-kexec-start
Type=oneshot
[clever@amd-nixos:~]$ cat /nix/store/2claa6ilb3ksamdw3mj6qcm402lrajf6-unit-script-prepare-kexec-start
#! /nix/store/wd1jazzawjk4w1d31ism7fm7vdg4ma9l-bash-4.4-p23/bin/bash -e
# Don't load the current system profile if we already have a kernel loaded
if [[ 1 = "$(</sys/kernel/kexec_loaded)" ]] ; then
echo "kexec kernel has already been loaded, prepare-kexec skipped"
exit 0
fi
p=$(readlink -f /nix/var/nix/profiles/system)
if ! [[ -d $p ]]; then
echo "Could not find system profile for prepare-kexec"
exit 1
fi
echo "Loading NixOS system via kexec."
exec kexec --load $p/kernel --initrd=$p/initrd --append="$(cat $p/kernel-params) init=$p/init"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment