summary refs log tree commit diff
path: root/nixos
diff options
context:
space:
mode:
authorobadz <obadz-git@obadz.com>2016-08-22 01:18:11 +0100
committerobadz <obadz-git@obadz.com>2016-08-22 01:18:11 +0100
commitba50fd71700bf796ea2339115733ca5a850015ea (patch)
tree60a0e395ca8e727e01da8837220b45b14beb9efc /nixos
parent2a552a0888808b8b66a8c7e241462f9a0353e664 (diff)
parent3d16af70bf894ce15ec9bdcad3c9ac736dc43630 (diff)
downloadnixlib-ba50fd71700bf796ea2339115733ca5a850015ea.tar
nixlib-ba50fd71700bf796ea2339115733ca5a850015ea.tar.gz
nixlib-ba50fd71700bf796ea2339115733ca5a850015ea.tar.bz2
nixlib-ba50fd71700bf796ea2339115733ca5a850015ea.tar.lz
nixlib-ba50fd71700bf796ea2339115733ca5a850015ea.tar.xz
nixlib-ba50fd71700bf796ea2339115733ca5a850015ea.tar.zst
nixlib-ba50fd71700bf796ea2339115733ca5a850015ea.zip
Merge branch 'master' into staging
Diffstat (limited to 'nixos')
-rw-r--r--nixos/modules/services/web-apps/mattermost.nix2
-rw-r--r--nixos/modules/system/boot/stage-1-init.sh42
-rw-r--r--nixos/modules/system/boot/stage-1.nix13
-rw-r--r--nixos/release-combined.nix1
4 files changed, 54 insertions, 4 deletions
diff --git a/nixos/modules/services/web-apps/mattermost.nix b/nixos/modules/services/web-apps/mattermost.nix
index 20d21c008c29..bf3a8eed6004 100644
--- a/nixos/modules/services/web-apps/mattermost.nix
+++ b/nixos/modules/services/web-apps/mattermost.nix
@@ -37,7 +37,7 @@ in
         type = types.str;
         example = "https://chat.example.com";
         description = ''
-          URL this Mattermost instance is reachable under, without trailing slash."
+          URL this Mattermost instance is reachable under, without trailing slash.
         '';
       };
 
diff --git a/nixos/modules/system/boot/stage-1-init.sh b/nixos/modules/system/boot/stage-1-init.sh
index fbb32901f64e..65d1dcb61681 100644
--- a/nixos/modules/system/boot/stage-1-init.sh
+++ b/nixos/modules/system/boot/stage-1-init.sh
@@ -312,8 +312,50 @@ mountFS() {
         echo "retrying..."
         n=$((n + 1))
     done
+
+    [ "$mountPoint" == "/" ] &&
+        [ -f "/mnt-root/etc/NIXOS_LUSTRATE" ] &&
+        lustrateRoot "/mnt-root"
 }
 
+lustrateRoot () {
+    local root="$1"
+
+    echo
+    echo -e "\e[1;33m<<< NixOS is now lustrating the root filesystem (cruft goes to /old-root) >>>\e[0m"
+    echo
+
+    mkdir -m 0755 -p "$root/old-root.tmp"
+
+    echo
+    echo "Moving impurities out of the way:"
+    for d in "$root"/*
+    do
+        [ "$d" == "$root/nix"          ] && continue
+        [ "$d" == "$root/boot"         ] && continue # Don't render the system unbootable
+        [ "$d" == "$root/old-root.tmp" ] && continue
+
+        mv -v "$d" "$root/old-root.tmp"
+    done
+
+    # Use .tmp to make sure subsequent invokations don't clash
+    mv -v "$root/old-root.tmp" "$root/old-root"
+
+    mkdir -m 0755 -p "$root/etc"
+    touch "$root/etc/NIXOS"
+
+    exec 4< "$root/old-root/etc/NIXOS_LUSTRATE"
+
+    echo
+    echo "Restoring selected impurities:"
+    while read -u 4 keeper; do
+        dirname="$(dirname "$keeper")"
+        mkdir -m 0755 -p "$root/$dirname"
+        cp -av "$root/old-root/$keeper" "$root/$keeper"
+    done
+
+    exec 4>&-
+}
 
 # Function for waiting a device to appear.
 waitDevice() {
diff --git a/nixos/modules/system/boot/stage-1.nix b/nixos/modules/system/boot/stage-1.nix
index baeba1d6b31d..9be7ad4ae077 100644
--- a/nixos/modules/system/boot/stage-1.nix
+++ b/nixos/modules/system/boot/stage-1.nix
@@ -131,9 +131,16 @@ let
   # The initrd only has to mount / or any FS marked as necessary for
   # booting (such as the FS containing /nix/store, or an FS needed for
   # mounting /, like / on a loopback).
-  fileSystems = filter
-    (fs: fs.neededForBoot || elem fs.mountPoint [ "/" "/nix" "/nix/store" "/var" "/var/log" "/var/lib" "/etc" ])
-    (attrValues config.fileSystems);
+  #
+  # We need to guarantee that / is the first filesystem in the list so
+  # that if and when lustrateRoot is invoked, nothing else is mounted
+  fileSystems = let
+    filterNeeded = filter
+      (fs: fs.mountPoint != "/" && (fs.neededForBoot || elem fs.mountPoint [ "/nix" "/nix/store" "/var" "/var/log" "/var/lib" "/etc" ]));
+    filterRoot = filter
+      (fs: fs.mountPoint == "/");
+    allFileSystems = attrValues config.fileSystems;
+  in (filterRoot allFileSystems) ++ (filterNeeded allFileSystems);
 
 
   udevRules = pkgs.stdenv.mkDerivation {
diff --git a/nixos/release-combined.nix b/nixos/release-combined.nix
index 4aa023854b67..f2ca6af7e3a4 100644
--- a/nixos/release-combined.nix
+++ b/nixos/release-combined.nix
@@ -68,6 +68,7 @@ in rec {
         (all nixos.tests.boot.uefiCdrom)
         (all nixos.tests.boot.uefiUsb)
         (all nixos.tests.boot-stage1)
+        (all nixos.tests.hibernate)
         (all nixos.tests.ecryptfs)
         (all nixos.tests.ipv6)
         (all nixos.tests.i3wm)