Commit d560a5e0 authored by r-vdp's avatar r-vdp Committed by Jörg Thalheim
Browse files

nixos/update-users-groups: fix cross compilation

Since #246772, cross compiled NixOS is broken because the DateTime perl
package that was used in the update-users-groups.pl script depends on
Testutf8 which does not cross compile (see #198548).

This PR drops the DateTime dependency in favour of TimePiece, which has
less dependencies and whose closure does cross compile.
parent 0b39810f
Loading
Loading
Loading
Loading
+3 −12
Original line number Diff line number Diff line
@@ -4,7 +4,7 @@ use File::Path qw(make_path);
use File::Slurp;
use Getopt::Long;
use JSON;
use DateTime;
use Time::Piece;

# Keep track of deleted uids and gids.
my $uidMapFile = "/var/lib/nixos/uid-map";
@@ -26,17 +26,8 @@ sub updateFile {
# Converts an ISO date to number of days since 1970-01-01
sub dateToDays {
    my ($date) = @_;
    my ($year, $month, $day) = split('-', $date, -3);
    my $dt = DateTime->new(
        year      => $year,
        month     => $month,
        day       => $day,
        hour      => 0,
        minute    => 0,
        second    => 0,
        time_zone => 'UTC',
    );
    return $dt->epoch / 86400;
    my $time = Time::Piece->strptime($date, "%Y-%m-%d");
    return $time->epoch / 60 / 60 / 24;
}

sub nscdInvalidate {
+1 −1
Original line number Diff line number Diff line
@@ -648,7 +648,7 @@ in {
        install -m 0700 -d /root
        install -m 0755 -d /home

        ${pkgs.perl.withPackages (p: [ p.FileSlurp p.JSON p.DateTime ])}/bin/perl \
        ${pkgs.perl.withPackages (p: [ p.FileSlurp p.JSON p.TimePiece ])}/bin/perl \
        -w ${./update-users-groups.pl} ${spec}
      '';
    };