Skip to content

Commit

Permalink
Revert "switch-to-configuration: use Net::DBus to retrieve the list o…
Browse files Browse the repository at this point in the history
…f units"

This reverts commit 54a13b0.
  • Loading branch information
ElvishJerricco committed Aug 5, 2018
1 parent 89c9ec4 commit cc09310
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
19 changes: 10 additions & 9 deletions nixos/modules/system/activation/switch-to-configuration.pl
Expand Up @@ -4,7 +4,6 @@
use warnings;
use File::Basename;
use File::Slurp;
use Net::DBus;
use Sys::Syslog qw(:standard :macros);
use Cwd 'abs_path';

Expand Down Expand Up @@ -68,15 +67,17 @@
$SIG{PIPE} = "IGNORE";

sub getActiveUnits {
my $mgr = Net::DBus->system->get_service("org.freedesktop.systemd1")->get_object("/org/freedesktop/systemd1");
my $units = $mgr->ListUnitsByPatterns([], []);
# FIXME: use D-Bus or whatever to query this, since parsing the
# output of list-units is likely to break.
# Use current version of systemctl binary before daemon is reexeced.
my $lines = `LANG= /run/current-system/sw/bin/systemctl list-units --full --no-legend`;
my $res = {};
for my $item (@$units) {
my ($id, $description, $load_state, $active_state, $sub_state,
$following, $unit_path, $job_id, $job_type, $job_path) = @$item;
next unless $following eq '';
next if $job_id == 0 and $active_state eq 'inactive';
$res->{$id} = { load => $load_state, state => $active_state, substate => $sub_state };
foreach my $line (split '\n', $lines) {
chomp $line;
last if $line eq "";
$line =~ /^(\S+)\s+(\S+)\s+(\S+)\s+(\S+)\s/ or next;
next if $1 eq "UNIT";
$res->{$1} = { load => $2, state => $3, substate => $4 };
}
return $res;
}
Expand Down
3 changes: 1 addition & 2 deletions nixos/modules/system/activation/top-level.nix
Expand Up @@ -127,8 +127,7 @@ let
configurationName = config.boot.loader.grub.configurationName;

# Needed by switch-to-configuration.

perl = "${pkgs.perl}/bin/perl " + (concatMapStringsSep " " (lib: "-I${lib}/${pkgs.perl.libPrefix}") (with pkgs.perlPackages; [ FileSlurp NetDBus XMLParser XMLTwig ]));
perl = "${pkgs.perl}/bin/perl -I${pkgs.perlPackages.FileSlurp}/lib/perl5/site_perl";
} else throw "\nFailed assertions:\n${concatStringsSep "\n" (map (x: "- ${x}") failed)}");

# Replace runtime dependencies
Expand Down

0 comments on commit cc09310

Please sign in to comment.