Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

nixos/switch-to-configuration: avoid Array::Compare dependency #160176

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions nixos/modules/system/activation/switch-to-configuration.pl
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

use strict;
use warnings;
use Array::Compare;
use Config::IniFiles;
use File::Path qw(make_path);
use File::Basename;
Expand Down Expand Up @@ -221,9 +220,13 @@ sub unrecord_unit {
# - 2 if the units are different and a reload action is required
sub compare_units {
my ($old_unit, $new_unit) = @_;
my $comp = Array::Compare->new;
my $ret = 0;

my $comp_array = sub {
my ($a, $b) = @_;
return join("\0", @{$a}) eq join("\0", @{$b});
};

# Comparison hash for the sections
my %section_cmp = map { $_ => 1 } keys %{$new_unit};
# Iterate over the sections
Expand Down Expand Up @@ -255,7 +258,7 @@ sub compare_units {
}
my @new_value = @{$new_unit->{$section_name}{$ini_key}};
# If the contents are different, the units are different
if (not $comp->compare(\@old_value, \@new_value)) {
if (not $comp_array->(\@old_value, \@new_value)) {
# Check if only the reload triggers changed
if ($section_name eq 'Unit' and $ini_key eq 'X-Reload-Triggers') {
$ret = 2;
Expand Down
2 changes: 1 addition & 1 deletion nixos/modules/system/activation/top-level.nix
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ let
configurationName = config.boot.loader.grub.configurationName;

# Needed by switch-to-configuration.
perl = pkgs.perl.withPackages (p: with p; [ ArrayCompare ConfigIniFiles FileSlurp NetDBus ]);
perl = pkgs.perl.withPackages (p: with p; [ ConfigIniFiles FileSlurp NetDBus ]);
};

# Handle assertions and warnings
Expand Down