summary refs log tree commit diff
path: root/nixos/modules/system/boot/shutdown.nix
diff options
context:
space:
mode:
authorEelco Dolstra <eelco.dolstra@logicblox.com>2013-11-26 18:17:12 +0100
committerEelco Dolstra <eelco.dolstra@logicblox.com>2013-11-26 18:19:45 +0100
commit2b1f21249445991940c9d3ebbc54ce41b1eaf9c0 (patch)
tree3c7f98ee825b69af81ba7215b6ef2489375e37b3 /nixos/modules/system/boot/shutdown.nix
parentda093461a2ff09d6ea1071ff886866a1f85480c2 (diff)
downloadnixlib-2b1f21249445991940c9d3ebbc54ce41b1eaf9c0.tar
nixlib-2b1f21249445991940c9d3ebbc54ce41b1eaf9c0.tar.gz
nixlib-2b1f21249445991940c9d3ebbc54ce41b1eaf9c0.tar.bz2
nixlib-2b1f21249445991940c9d3ebbc54ce41b1eaf9c0.tar.lz
nixlib-2b1f21249445991940c9d3ebbc54ce41b1eaf9c0.tar.xz
nixlib-2b1f21249445991940c9d3ebbc54ce41b1eaf9c0.tar.zst
nixlib-2b1f21249445991940c9d3ebbc54ce41b1eaf9c0.zip
Disable various services when running inside a container
Diffstat (limited to 'nixos/modules/system/boot/shutdown.nix')
-rw-r--r--nixos/modules/system/boot/shutdown.nix28
1 files changed, 14 insertions, 14 deletions
diff --git a/nixos/modules/system/boot/shutdown.nix b/nixos/modules/system/boot/shutdown.nix
index ad71a2e816e3..44cadcd64a76 100644
--- a/nixos/modules/system/boot/shutdown.nix
+++ b/nixos/modules/system/boot/shutdown.nix
@@ -6,20 +6,20 @@ with pkgs.lib;
 
   # This unit saves the value of the system clock to the hardware
   # clock on shutdown.
-  systemd.units."save-hwclock.service" =
-    { wantedBy = [ "shutdown.target" ];
-
-      text =
-        ''
-          [Unit]
-          Description=Save Hardware Clock
-          DefaultDependencies=no
-          Before=shutdown.target
-
-          [Service]
-          Type=oneshot
-          ExecStart=${pkgs.utillinux}/sbin/hwclock --systohc ${if config.time.hardwareClockInLocalTime then "--localtime" else "--utc"}
-        '';
+  systemd.services.save-hwclock =
+    { description = "Save Hardware Clock";
+
+      wantedBy = [ "shutdown.target" ];
+
+      unitConfig = {
+        DefaultDependencies = false;
+        ConditionVirtualization = "!systemd-nspawn";
+      };
+
+      serviceConfig = {
+        Type = "oneshot";
+        ExecStart = "${pkgs.utillinux}/sbin/hwclock --systohc ${if config.time.hardwareClockInLocalTime then "--localtime" else "--utc"}";
+      };
     };
 
   boot.kernel.sysctl."kernel.poweroff_cmd" = "${config.systemd.package}/sbin/poweroff";