From 80d9b426638563a6d8b6dc1604180cc60b4b2862 Mon Sep 17 00:00:00 2001 From: Eelco Dolstra Date: Fri, 7 Aug 2015 05:25:59 +0200 Subject: [PATCH] Allow units to specify that they shouldn't be stopped when removed --- nixos/modules/system/activation/switch-to-configuration.pl | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/nixos/modules/system/activation/switch-to-configuration.pl b/nixos/modules/system/activation/switch-to-configuration.pl index 4289740322ad..655fbab2a843 100644 --- a/nixos/modules/system/activation/switch-to-configuration.pl +++ b/nixos/modules/system/activation/switch-to-configuration.pl @@ -97,7 +97,7 @@ sub parseFstab { sub parseUnit { my ($filename) = @_; my $info = {}; - parseKeyValues($info, read_file($filename)); + parseKeyValues($info, read_file($filename)) if -f $filename; parseKeyValues($info, read_file("${filename}.d/overrides.conf")) if -f "${filename}.d/overrides.conf"; return $info; } @@ -157,7 +157,8 @@ while (my ($unit, $state) = each %{$activePrev}) { if (-e $prevUnitFile && ($state->{state} eq "active" || $state->{state} eq "activating")) { if (! -e $newUnitFile || abs_path($newUnitFile) eq "/dev/null") { - $unitsToStop{$unit} = 1; + my $unitInfo = parseUnit($prevUnitFile); + $unitsToStop{$unit} = 1 if boolIsTrue($unitInfo->{'X-StopOnRemoval'} // "yes"); } elsif ($unit =~ /\.target$/) {