···33use Class::Struct;
44use XML::LibXML;
55use File::Basename;
66-use File::Path;
66+use File::Path qw(make_path);
77use File::stat;
88use File::Copy;
99use File::Copy::Recursive qw(rcopy pathrm);
···3737 my ($fn) = @_;
3838 # enable slurp mode: read entire file in one go
3939 local $/ = undef;
4040- open my $fh, "<$fn" or return undef;
4040+ open my $fh, "<", $fn
4141+ or return;
4142 my $s = <$fh>;
4243 close $fh;
4344 # disable slurp mode
···48494950sub writeFile {
5051 my ($fn, $s) = @_;
5151- open my $fh, ">$fn" or die "cannot create $fn: $!\n";
5252+ open my $fh, ">", $fn or die "cannot create $fn: $!\n";
5253 print $fh $s or die "cannot write to $fn: $!\n";
5354 close $fh or die "cannot close $fn: $!\n";
5455}
···989999100print STDERR "updating GRUB 2 menu...\n";
100101101101-mkpath("$bootPath/grub", 0, 0700);
102102+make_path("$bootPath/grub", { mode => 0700 });
102103103104# Discover whether the bootPath is on the same filesystem as / and
104105# /nix/store. If not, then all kernels and initrds must be copied to
···438439$conf .= "\n";
439440440441my %copied;
441441-mkpath("$bootPath/kernels", 0, 0755) if $copyKernels;
442442+make_path("$bootPath/kernels", { mode => 0755 }) if $copyKernels;
442443443444sub copyToKernelsDir {
444445 my ($path) = @_;
···471472 my $systemName = basename(Cwd::abs_path("$path"));
472473 my $initrdSecretsPath = "$bootPath/kernels/$systemName-secrets";
473474474474- mkpath(dirname($initrdSecretsPath), 0, 0755);
475475+ make_path(dirname($initrdSecretsPath), { mode => 0755 });
475476 my $oldUmask = umask;
476477 # Make sure initrd is not world readable (won't work if /boot is FAT)
477478 umask 0137;
···690691# because it is read line-by-line.
691692sub readGrubState {
692693 my $defaultGrubState = GrubState->new(name => "", version => "", efi => "", devices => "", efiMountPoint => "", extraGrubInstallArgs => () );
693693- open FILE, "<$bootPath/grub/state" or return $defaultGrubState;
694694+ open my $fh, "<", "$bootPath/grub/state" or return $defaultGrubState;
694695 local $/ = "\n";
695695- my $name = <FILE>;
696696+ my $name = <$fh>;
696697 chomp($name);
697697- my $version = <FILE>;
698698+ my $version = <$fh>;
698699 chomp($version);
699699- my $efi = <FILE>;
700700+ my $efi = <$fh>;
700701 chomp($efi);
701701- my $devices = <FILE>;
702702+ my $devices = <$fh>;
702703 chomp($devices);
703703- my $efiMountPoint = <FILE>;
704704+ my $efiMountPoint = <$fh>;
704705 chomp($efiMountPoint);
705706 # Historically, arguments in the state file were one per each line, but that
706707 # gets really messy when newlines are involved, structured arguments
···708709 # when we need to remove a setting in the future. Thus, the 6th line is a JSON
709710 # object that can store structured data, with named keys, and all new state
710711 # should go in there.
711711- my $jsonStateLine = <FILE>;
712712+ my $jsonStateLine = <$fh>;
712713 # For historical reasons we do not check the values above for un-definedness
713714 # (that is, when the state file has too few lines and EOF is reached),
714715 # because the above come from the first version of this logic and are thus
···720721 }
721722 my %jsonState = %{decode_json($jsonStateLine)};
722723 my @extraGrubInstallArgs = exists($jsonState{'extraGrubInstallArgs'}) ? @{$jsonState{'extraGrubInstallArgs'}} : ();
723723- close FILE;
724724+ close $fh;
724725 my $grubState = GrubState->new(name => $name, version => $version, efi => $efi, devices => $devices, efiMountPoint => $efiMountPoint, extraGrubInstallArgs => \@extraGrubInstallArgs );
725726 return $grubState
726727}
···787788 my $stateFile = "$bootPath/grub/state";
788789 my $stateFileTmp = $stateFile . ".tmp";
789790790790- open FILE, ">$stateFileTmp" or die "cannot create $stateFileTmp: $!\n";
791791- print FILE get("fullName"), "\n" or die;
792792- print FILE get("fullVersion"), "\n" or die;
793793- print FILE $efiTarget, "\n" or die;
794794- print FILE join( ",", @deviceTargets ), "\n" or die;
795795- print FILE $efiSysMountPoint, "\n" or die;
791791+ open my $fh, ">", "$stateFileTmp" or die "cannot create $stateFileTmp: $!\n";
792792+ print $fh get("fullName"), "\n" or die;
793793+ print $fh get("fullVersion"), "\n" or die;
794794+ print $fh $efiTarget, "\n" or die;
795795+ print $fh join( ",", @deviceTargets ), "\n" or die;
796796+ print $fh $efiSysMountPoint, "\n" or die;
796797 my %jsonState = (
797798 extraGrubInstallArgs => \@extraGrubInstallArgs
798799 );
799800 my $jsonStateLine = encode_json(\%jsonState);
800800- print FILE $jsonStateLine, "\n" or die;
801801- close FILE or die;
801801+ print $fh $jsonStateLine, "\n" or die;
802802+ close $fh or die;
802803803804 # Atomically switch to the new state file
804805 rename $stateFileTmp, $stateFile or die "cannot rename $stateFileTmp to $stateFile: $!\n";
···5050 oneDNN
5151 re2
5252 onnxruntime.protobuf
5353+5454+ # https://github.com/NixOS/nixpkgs/pull/357656 patches the onnx lib to ${pkgs.onnxruntime}/lib
5555+ # but these files are copied into this package too. If the origional non-python onnxruntime
5656+ # package is GC-ed, cuda support in this python package will break.
5757+ # Two options, rebuild onnxruntime twice with the different paths hard-coded, or just hold a runtime
5858+ # dependency between the two. Option 2, because onnxruntime takes forever to build with cuda support.
5959+ onnxruntime
5360 ]
5461 ++ lib.optionals onnxruntime.passthru.cudaSupport (
5562 with onnxruntime.passthru.cudaPackages;