git.iko.soy/typeable/nixpkgs
on master help sign in
installation-cd-base.nix: Add 'live.nixos.passwd' boot option

For interactive SSH access to a system without a (working) keyboard and monitor, without rebuilding the image itself.

commit2e4849b84104b20a275c1ac6cba150c679bc3992 authorjakobrs <jakobrs100@gmail.com> dateSat 26 Dec 2020, 10:55 (6 years ago) parentfa1d025
3 files changed+34
nixos/doc/manual/administration/boot-problems.section.md+6 nixos/doc/manual/from_md/administration/boot-problems.section.xml+17 nixos/modules/installer/cd-dvd/installation-cd-base.nix+11
nixos/doc/manual/administration/boot-problems.section.md+6
@@ -30,6 +30,12 @@ If NixOS fails to boot, there are a number of kernel command line parameters tha
3030
3131: Make systemd very verbose and send log messages to the console instead of the journal. For more parameters recognised by systemd, see systemd(1).
3232
33+In addition, these arguments are recognised by the live image only:
34+
35+`live.nixos.passwd=password`
36+
37+: Set the password for the `nixos` live user. This can be used for SSH access if there are issues using the terminal.
38+
3339Notice that for `boot.shell_on_fail`, `boot.debug1`, `boot.debug1devices`, and `boot.debug1mounts`, if you did **not** select "start the new shell as pid 1", and you `exit` from the new shell, boot will proceed normally from the point where it failed, as if you'd chosen "ignore the error and continue".
3440
3541If no login prompts or X11 login screens appear (e.g. due to hanging dependencies), you can press Alt+ArrowUp. If you’re lucky, this will start rescue mode (described above). (Also note that since most units have a 90-second timeout before systemd gives up on them, the `agetty` login prompts should appear eventually unless something is very wrong.)
nixos/doc/manual/from_md/administration/boot-problems.section.xml+17
@@ -106,6 +106,23 @@
106106 </listitem>
107107 </varlistentry>
108108 </variablelist>
109+ <para>
110+ In addition, these arguments are recognised by the live image only:
111+ </para>
112+ <variablelist>
113+ <varlistentry>
114+ <term>
115+ <literal>live.nixos.passwd=password</literal>
116+ </term>
117+ <listitem>
118+ <para>
119+ Set the password for the <literal>nixos</literal> live user.
120+ This can be used for SSH access if there are issues using the
121+ terminal.
122+ </para>
123+ </listitem>
124+ </varlistentry>
125+ </variablelist>
109126 <para>
110127 Notice that for <literal>boot.shell_on_fail</literal>,
111128 <literal>boot.debug1</literal>,
nixos/modules/installer/cd-dvd/installation-cd-base.nix+11
@@ -30,5 +30,16 @@ with lib;
3030 # Add Memtest86+ to the CD.
3131 boot.loader.grub.memtest86.enable = true;
3232
33+ boot.postBootCommands = ''
34+ for o in $(</proc/cmdline); do
35+ case "$o" in
36+ live.nixos.passwd=*)
37+ set -- $(IFS==; echo $o)
38+ echo "nixos:$2" | ${pkgs.shadow}/bin/chpasswd
39+ ;;
40+ esac
41+ done
42+ '';
43+
3344 system.stateVersion = mkDefault "18.03";
3445}