Change:
Switching NIxOS configurations when using produces the following warning: Steps to reproduce the behavior: (current master) file in the directory with the following content: test fails and produces the warning should not produce warnings. It looks like currently can't handle service file names containing a . I tracked the first failing commit down to . The warning seems to not create any problems for me at the moment and all services are running.
Great… I'll take a look

Discussion:
# # If a directory with the same basename ending in .d exists next to the unit file, it will be # assumed to contain override files which will be parsed as well and handled properly. <del> sub parseUnit { my ($unitPath) = @_; </del> <ins> sub parse_unit { my ($unit_path) = @_; </ins> # Parse the main unit and all overrides <del> my %unitData; parseSystemdIni(%unitData, $_) for glob("${unitPath}{,.d/*.conf}"); return %unitData; </del> <ins> my %unit_data; # Replace  with  so glob() still works with units that have a  in them # Valid characters in unit names are ASCII letters, digits, ":", "-", "_", ".", and "" $unit_path =~ s///gmsx; foreach (glob "${unit_path}{,.d/*.conf}") { parseSystemdIni(%unit_data, "$_") } return %unit_data; </ins> } # Checks whether a specified boolean in a systemd unit is true

# Revert of the attempt: https://github.com/NixOS/nixpkgs/pull/147609 # More details: https://github.com/NixOS/nixpkgs/issues/74899#issuecomment-981142430 } else { <del> my %unitInfo = $newUnitInfo ? %{$newUnitInfo} : parseUnit($newUnitFile); </del> <ins> my %unitInfo = $newUnitInfo ? %{$newUnitInfo} : parse_unit($newUnitFile); </ins> if (parseSystemdBool(%unitInfo, "Service", "X-ReloadIfChanged", 0) and not $unitsToRestart->{$unit} and not $unitsToStop->{$unit}) { $unitsToReload->{$unit} = 1; recordUnit($reloadListFile, $unit);

if (-e $prevUnitFile && ($state->{state} eq "active" || $state->{state} eq "activating")) { if (! -e $newUnitFile || abs_path($newUnitFile) eq "/dev/null") { <del> my %unitInfo = parseUnit($prevUnitFile); </del> <ins> my %unitInfo = parse_unit($prevUnitFile); </ins> $unitsToStop{$unit} = 1 if parseSystemdBool(%unitInfo, "Unit", "X-StopOnRemoval", 1); } elsif ($unit =~ /.target$/) { <del> my %unitInfo = parseUnit($newUnitFile); </del> <ins> my %unitInfo = parse_unit($newUnitFile); </ins> # Cause all active target units to be restarted below. # This should start most changed units we stop here as

} else { <del> my %old_unit_info = parseUnit($prevUnitFile); my %new_unit_info = parseUnit($newUnitFile); </del> <ins> my %old_unit_info = parse_unit($prevUnitFile); my %new_unit_info = parse_unit($newUnitFile); </ins> my $diff = compare_units(%old_unit_info, %new_unit_info); if ($diff eq 1) { handleModifiedUnit($unit, $baseName, $newUnitFile, %new_unit_info, $activePrev, %unitsToStop, %unitsToStart, %unitsToReload, %unitsToRestart, %unitsToSkip);

systemd.services.test.serviceConfig."X-Test" = "test"; }; <ins> unitWithBackslash.configuration = { systemd.services."escapedx2ddash" = { wantedBy = [ "multi-user.target" ]; serviceConfig = { Type = "oneshot"; RemainAfterExit = true; ExecStart = "${pkgs.coreutils}/bin/true"; ExecReload = "${pkgs.coreutils}/bin/true"; }; }; }; unitWithBackslashModified.configuration = { imports = [ unitWithBackslash.configuration ]; systemd.services."escapedx2ddash".serviceConfig.X-Test = "test"; }; </ins> restart-and-reload-by-activation-script.configuration = { systemd.services = rec { simple-service = {

assert_lacks(out, "as well:") assert_contains(out, "would start the following units: test.servicen") <ins> # Ensure  works in unit names out = switch_to_specialisation("${machine}", "unitWithBackslash") assert_contains(out, "stopping the following units: test.servicen") assert_lacks(out, "NOT restarting the following changed units:") assert_lacks(out, "reloading the following units:") assert_lacks(out, "nrestarting the following units:") assert_lacks(out, "nstarting the following units:") assert_contains(out, "the following new units were started: escapedx2ddash.servicen") assert_lacks(out, "as well:") out = switch_to_specialisation("${machine}", "unitWithBackslashModified") assert_contains(out, "stopping the following units: escapedx2ddash.servicen") assert_lacks(out, "NOT restarting the following changed units:") assert_lacks(out, "reloading the following units:") assert_lacks(out, "nrestarting the following units:") assert_contains(out, "nstarting the following units: escapedx2ddash.servicen") assert_lacks(out, "the following new units were started:") assert_lacks(out, "as well:") </ins> with subtest("failing units"): # Let the simple service fail switch_to_specialisation("${machine}", "simpleServiceModified")