diff options
author | r-vdp <ramses@well-founded.dev> | 2023-08-27 22:46:41 +0200 |
---|---|---|
committer | Jörg Thalheim <Mic92@users.noreply.github.com> | 2023-09-03 11:26:37 +0200 |
commit | d560a5e07dc4125ef116f1806f447e59e1642b45 (patch) | |
tree | 341b14f899d94b1331c5c8b6bf49374cbb208434 | |
parent | 0b39810fe654b880c6ec0a75f8ba45b84a7c7758 (diff) |
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.
-rw-r--r-- | nixos/modules/config/update-users-groups.pl | 15 | ||||
-rw-r--r-- | nixos/modules/config/users-groups.nix | 2 |
2 files changed, 4 insertions, 13 deletions
diff --git a/nixos/modules/config/update-users-groups.pl b/nixos/modules/config/update-users-groups.pl index 5236264e16b7..3785ba8c5fb8 100644 --- a/nixos/modules/config/update-users-groups.pl +++ b/nixos/modules/config/update-users-groups.pl @@ -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 { diff --git a/nixos/modules/config/users-groups.nix b/nixos/modules/config/users-groups.nix index 9629e3964c96..9c2ead47c925 100644 --- a/nixos/modules/config/users-groups.nix +++ b/nixos/modules/config/users-groups.nix @@ -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} ''; }; |