summary refs log tree commit diff
path: root/nixos/modules/system
diff options
context:
space:
mode:
authorwmertens <Wout.Mertens@gmail.com>2014-11-13 10:26:30 +0100
committerwmertens <Wout.Mertens@gmail.com>2014-11-13 10:26:30 +0100
commit5c19521c6e3b79ae42ab928494490876a9c47a27 (patch)
tree9d10862d5ea8d1a26f65d81780fa4e4c0338268b /nixos/modules/system
parentcd6bb77a9e420291c329aaff0fbe11e870621be0 (diff)
parent7a7bf8368e25d13b1f2e915514c804728b7648ef (diff)
downloadnixlib-5c19521c6e3b79ae42ab928494490876a9c47a27.tar
nixlib-5c19521c6e3b79ae42ab928494490876a9c47a27.tar.gz
nixlib-5c19521c6e3b79ae42ab928494490876a9c47a27.tar.bz2
nixlib-5c19521c6e3b79ae42ab928494490876a9c47a27.tar.lz
nixlib-5c19521c6e3b79ae42ab928494490876a9c47a27.tar.xz
nixlib-5c19521c6e3b79ae42ab928494490876a9c47a27.tar.zst
nixlib-5c19521c6e3b79ae42ab928494490876a9c47a27.zip
Merge pull request #4807 from wizeman/u/zfs-improvements
ZFS improvements
Diffstat (limited to 'nixos/modules/system')
-rw-r--r--nixos/modules/system/boot/stage-1-init.sh3
-rw-r--r--nixos/modules/system/boot/stage-1.nix9
2 files changed, 12 insertions, 0 deletions
diff --git a/nixos/modules/system/boot/stage-1-init.sh b/nixos/modules/system/boot/stage-1-init.sh
index f0a96edd14af..da1963f98043 100644
--- a/nixos/modules/system/boot/stage-1-init.sh
+++ b/nixos/modules/system/boot/stage-1-init.sh
@@ -122,6 +122,9 @@ for o in $(cat /proc/cmdline); do
     esac
 done
 
+# Set hostid before modules are loaded.
+# This is needed by the spl/zfs modules.
+@setHostId@
 
 # Load the required kernel modules.
 mkdir -p /lib
diff --git a/nixos/modules/system/boot/stage-1.nix b/nixos/modules/system/boot/stage-1.nix
index 33c9a70eb1b2..45229e871ab6 100644
--- a/nixos/modules/system/boot/stage-1.nix
+++ b/nixos/modules/system/boot/stage-1.nix
@@ -188,6 +188,15 @@ let
     fsInfo =
       let f = fs: [ fs.mountPoint (if fs.device != null then fs.device else "/dev/disk/by-label/${fs.label}") fs.fsType fs.options ];
       in pkgs.writeText "initrd-fsinfo" (concatStringsSep "\n" (concatMap f fileSystems));
+
+    setHostId = optionalString (config.networking.hostId != null) ''
+      hi="${config.networking.hostId}"
+      ${if pkgs.stdenv.isBigEndian then ''
+        echo -ne "\x''${hi:0:2}\x''${hi:2:2}\x''${hi:4:2}\x''${hi:6:2}" > /etc/hostid
+      '' else ''
+        echo -ne "\x''${hi:6:2}\x''${hi:4:2}\x''${hi:2:2}\x''${hi:0:2}" > /etc/hostid
+      ''}
+    '';
   };