about summary refs log tree commit diff
path: root/nixos/modules/system/activation
diff options
context:
space:
mode:
authorVladimír Čunát <vcunat@gmail.com>2016-03-08 09:57:58 +0100
committerVladimír Čunát <vcunat@gmail.com>2016-03-08 09:58:19 +0100
commit09af15654f0c8091f1b9e0bbb2e523cdee194442 (patch)
treee648edef1ce4c64c533f2593aa22b8015cf0e506 /nixos/modules/system/activation
parentf306e67e15bdbe9a8358c9f81319fc4fcbadc2eb (diff)
parent0ee75214f336474e127c2e3546c0406a0c4d5fa7 (diff)
downloadnixlib-09af15654f0c8091f1b9e0bbb2e523cdee194442.tar
nixlib-09af15654f0c8091f1b9e0bbb2e523cdee194442.tar.gz
nixlib-09af15654f0c8091f1b9e0bbb2e523cdee194442.tar.bz2
nixlib-09af15654f0c8091f1b9e0bbb2e523cdee194442.tar.lz
nixlib-09af15654f0c8091f1b9e0bbb2e523cdee194442.tar.xz
nixlib-09af15654f0c8091f1b9e0bbb2e523cdee194442.tar.zst
nixlib-09af15654f0c8091f1b9e0bbb2e523cdee194442.zip
Merge master into closure-size
The kde-5 stuff still didn't merge well.
I hand-fixed what I saw, but there may be more problems.
Diffstat (limited to 'nixos/modules/system/activation')
-rw-r--r--nixos/modules/system/activation/activation-script.nix25
-rw-r--r--nixos/modules/system/activation/switch-to-configuration.pl14
-rw-r--r--nixos/modules/system/activation/top-level.nix11
3 files changed, 27 insertions, 23 deletions
diff --git a/nixos/modules/system/activation/activation-script.nix b/nixos/modules/system/activation/activation-script.nix
index 72dd9b94a94e..9d61d64f7553 100644
--- a/nixos/modules/system/activation/activation-script.nix
+++ b/nixos/modules/system/activation/activation-script.nix
@@ -31,18 +31,19 @@ in
     system.activationScripts = mkOption {
       default = {};
 
-      example = {
-        stdio = {
-          text = ''
-            # Needed by some programs.
-            ln -sfn /proc/self/fd /dev/fd
-            ln -sfn /proc/self/fd/0 /dev/stdin
-            ln -sfn /proc/self/fd/1 /dev/stdout
-            ln -sfn /proc/self/fd/2 /dev/stderr
-          '';
-          deps = [];
-        };
-      };
+      example = literalExample ''
+        { stdio = {
+            text = '''
+              # Needed by some programs.
+              ln -sfn /proc/self/fd /dev/fd
+              ln -sfn /proc/self/fd/0 /dev/stdin
+              ln -sfn /proc/self/fd/1 /dev/stdout
+              ln -sfn /proc/self/fd/2 /dev/stderr
+            ''';
+            deps = [];
+          };
+        }
+      '';
 
       description = ''
         A set of shell script fragments that are executed when a NixOS
diff --git a/nixos/modules/system/activation/switch-to-configuration.pl b/nixos/modules/system/activation/switch-to-configuration.pl
index d9048427801f..093b7f1ff225 100644
--- a/nixos/modules/system/activation/switch-to-configuration.pl
+++ b/nixos/modules/system/activation/switch-to-configuration.pl
@@ -261,12 +261,12 @@ while (my ($unit, $state) = each %{$activePrev}) {
 
 sub pathToUnitName {
     my ($path) = @_;
-    die unless substr($path, 0, 1) eq "/";
-    return "-" if $path eq "/";
-    $path = substr($path, 1);
-    $path =~ s/\//-/g;
-    # FIXME: handle - and unprintable characters.
-    return $path;
+    open my $cmd, "-|", "systemd-escape", "--suffix=mount", "-p", $path
+        or die "Unable to escape $path!\n";
+    my $escaped = join "", <$cmd>;
+    chomp $escaped;
+    close $cmd or die;
+    return $escaped;
 }
 
 sub unique {
@@ -290,7 +290,7 @@ my ($newFss, $newSwaps) = parseFstab "$out/etc/fstab";
 foreach my $mountPoint (keys %$prevFss) {
     my $prev = $prevFss->{$mountPoint};
     my $new = $newFss->{$mountPoint};
-    my $unit = pathToUnitName($mountPoint) . ".mount";
+    my $unit = pathToUnitName($mountPoint);
     if (!defined $new) {
         # Filesystem entry disappeared, so unmount it.
         $unitsToStop{$unit} = 1;
diff --git a/nixos/modules/system/activation/top-level.nix b/nixos/modules/system/activation/top-level.nix
index d66580b7b9be..2d1b0ffb54ce 100644
--- a/nixos/modules/system/activation/top-level.nix
+++ b/nixos/modules/system/activation/top-level.nix
@@ -178,9 +178,10 @@ in
       default = false;
       description = ''
         If enabled, copies the NixOS configuration file
-        <literal>$NIXOS_CONFIG</literal> (usually
-        <filename>/etc/nixos/configuration.nix</filename>)
-        to the system store path.
+        (usually <filename>/etc/nixos/configuration.nix</filename>)
+        and links it from the resulting system
+        (getting to <filename>/run/current-system/configuration.nix</filename>).
+        Note that only this single file is copied, even if it imports others.
       '';
     };
 
@@ -238,7 +239,9 @@ in
     system.extraSystemBuilderCmds =
       optionalString
         config.system.copySystemConfiguration
-        "cp ${maybeEnv "NIXOS_CONFIG" "/etc/nixos/configuration.nix"} $out";
+        ''ln -s '${import ../../../lib/from-env.nix "NIXOS_CONFIG" <nixos-config>}' \
+            "$out/configuration.nix"
+        '';
 
     system.build.toplevel = system;