about summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorJörg Thalheim <Mic92@users.noreply.github.com>2021-07-03 18:47:50 +0100
committerGitHub <noreply@github.com>2021-07-03 18:47:50 +0100
commitb11897615150d25e07b16ab00398accbce1b77f6 (patch)
treeaf2b8769db29db6061e5aa7a6cfe16543abd0d79 /nixos
parent2b0da61cbdeda741bc661db58b8484b725cacff5 (diff)
parent2e4849b84104b20a275c1ac6cba150c679bc3992 (diff)
Merge pull request #107626 from jakobrs/passwd
installation-cd-base.nix: Add 'live.nixos.passwd' boot option
Diffstat (limited to 'nixos')
-rw-r--r--nixos/doc/manual/administration/boot-problems.section.md6
-rw-r--r--nixos/doc/manual/from_md/administration/boot-problems.section.xml17
-rw-r--r--nixos/modules/installer/cd-dvd/installation-cd-base.nix11
3 files changed, 34 insertions, 0 deletions
diff --git a/nixos/doc/manual/administration/boot-problems.section.md b/nixos/doc/manual/administration/boot-problems.section.md
index eb9209602a320..dee83e7ec2252 100644
--- a/nixos/doc/manual/administration/boot-problems.section.md
+++ b/nixos/doc/manual/administration/boot-problems.section.md
@@ -30,6 +30,12 @@ If NixOS fails to boot, there are a number of kernel command line parameters tha
 
 : Make systemd very verbose and send log messages to the console instead of the journal. For more parameters recognised by systemd, see systemd(1).
 
+In addition, these arguments are recognised by the live image only:
+
+`live.nixos.passwd=password`
+
+: Set the password for the `nixos` live user. This can be used for SSH access if there are issues using the terminal.
+
 Notice 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".
 
 If 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.)
diff --git a/nixos/doc/manual/from_md/administration/boot-problems.section.xml b/nixos/doc/manual/from_md/administration/boot-problems.section.xml
index b484d075818a4..4ea01e78f32f2 100644
--- a/nixos/doc/manual/from_md/administration/boot-problems.section.xml
+++ b/nixos/doc/manual/from_md/administration/boot-problems.section.xml
@@ -107,6 +107,23 @@
     </varlistentry>
   </variablelist>
   <para>
+    In addition, these arguments are recognised by the live image only:
+  </para>
+  <variablelist>
+    <varlistentry>
+      <term>
+        <literal>live.nixos.passwd=password</literal>
+      </term>
+      <listitem>
+        <para>
+          Set the password for the <literal>nixos</literal> live user.
+          This can be used for SSH access if there are issues using the
+          terminal.
+        </para>
+      </listitem>
+    </varlistentry>
+  </variablelist>
+  <para>
     Notice that for <literal>boot.shell_on_fail</literal>,
     <literal>boot.debug1</literal>,
     <literal>boot.debug1devices</literal>, and
diff --git a/nixos/modules/installer/cd-dvd/installation-cd-base.nix b/nixos/modules/installer/cd-dvd/installation-cd-base.nix
index 6c7ea293e8ac8..aecb65b8c5769 100644
--- a/nixos/modules/installer/cd-dvd/installation-cd-base.nix
+++ b/nixos/modules/installer/cd-dvd/installation-cd-base.nix
@@ -30,5 +30,16 @@ with lib;
   # Add Memtest86+ to the CD.
   boot.loader.grub.memtest86.enable = true;
 
+  boot.postBootCommands = ''
+    for o in $(</proc/cmdline); do
+      case "$o" in
+        live.nixos.passwd=*)
+          set -- $(IFS==; echo $o)
+          echo "nixos:$2" | ${pkgs.shadow}/bin/chpasswd
+          ;;
+      esac
+    done
+  '';
+
   system.stateVersion = mkDefault "18.03";
 }