Skip to content
This repository was archived by the owner on Apr 12, 2021. It is now read-only.
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: NixOS/nixpkgs-channels
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 985071630e01
Choose a base ref
...
head repository: NixOS/nixpkgs-channels
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: d676d5d11988
Choose a head ref

Commits on Jun 9, 2020

  1. fetchurl: allow empty hash

    Meant as a companion to NixOS/nix#3674
    
    This just resets outputHash if nothing is passed in.
    matthewbauer committed Jun 9, 2020
    Copy the full SHA
    f2e9046 View commit details
  2. Copy the full SHA
    a528cc1 View commit details
  3. fetchurl: only allow empty hash when cacert is available

    We can use cacert to validate that the data passes SSL certificates.
    Normally, this doesn’t happen because we already have the hash, but in
    the hash = "" case we don’t.
    matthewbauer committed Jun 9, 2020
    Copy the full SHA
    0046802 View commit details

Commits on Jun 18, 2020

  1. salt: 3000.3 -> 3001

    Flakebi committed Jun 18, 2020
    Copy the full SHA
    00e3f02 View commit details

Commits on Jul 2, 2020

  1. enlightenment: enlightenment setuid path patch

    (add correct nix path to setuid utility)
    bagnaram committed Jul 2, 2020
    Copy the full SHA
    f3d1a4f View commit details

Commits on Jul 4, 2020

  1. qemu-vm.nix: Do not mount /boot read-only.

    There does not seem to be a good reason to do this, and it breaks running
    `nixos-rebuild boot --install-bootloader` inside the VM.
    nh2 committed Jul 4, 2020
    Copy the full SHA
    2fa351b View commit details
  2. qemu-vm.nix: Fix device name hardcodes on useBootLoader.

    boot.loader.grub.device` was hardcoded to `bootDevice`, which is
    wrong, because that's the device for `/`, and with `useBootLoader`
    the boot loader is not on that device.
    
    This bug probably came into existence because of bad naming;
    `virtualisation.bootDevice` has description
    "The disk to be used for the root filesystem", which is very confusing;
    it should be `.rootDevice` then!
    Unfortunately, the description is right and the attribute name is wrong,
    so it is not easy to change this without deprecation.
    
    This commit ensures that even if you use `useBootLoader` and
    `diskInterface == "scsi"`, the created VM can boot through, and can run
    `nixos-rebuild afterwards.
    
    It also adds extra commentary to explain what's going on in this module
    in general in relation to `useBootLoader`.
    nh2 committed Jul 4, 2020
    Copy the full SHA
    5b16d4c View commit details

Commits on Jul 6, 2020

  1. Copy the full SHA
    f2cafb1 View commit details
  2. Copy the full SHA
    80ca70b View commit details
  3. Copy the full SHA
    19f7be3 View commit details
  4. deno: 1.1.2 -> 1.1.3

    06kellyjac committed Jul 6, 2020
    Copy the full SHA
    08b440b View commit details
  5. python27Packages.mwclient: 0.10.0 -> 0.10.1

    r-ryantm authored and Jon committed Jul 6, 2020
    Copy the full SHA
    9fec655 View commit details
  6. Merge pull request #91066 from Flakebi/salt

    salt: 3000.3 -> 3001
    mweinelt authored Jul 6, 2020
    Copy the full SHA
    2ca9cbc View commit details
  7. python3Package.nibabel: 3.1.0 -> 3.1.1

    tfmoraes authored and Jon committed Jul 6, 2020
    Copy the full SHA
    5cb5ccb View commit details
  8. pulseeffects: 4.7.2 -> 4.7.3

    r-ryantm authored and jtojnar committed Jul 6, 2020
    Copy the full SHA
    5befae9 View commit details
  9. python3Package.gdcm: 3.0.6 -> 3.0.7

    tfmoraes authored and Jon committed Jul 6, 2020
    Copy the full SHA
    956d7b8 View commit details
  10. Copy the full SHA
    89d4142 View commit details
  11. python27Packages.Nuitka: 0.6.8.1 -> 0.6.8.4

    r-ryantm authored and Jon committed Jul 6, 2020
    Copy the full SHA
    f925ce3 View commit details
  12. python37Packages.libevdev: 0.7 -> 0.9

    r-ryantm authored and Jon committed Jul 6, 2020
    Copy the full SHA
    275d34a View commit details
  13. python27Packages.latexcodec: 2.0.0 -> 2.0.1

    r-ryantm authored and Jon committed Jul 6, 2020
    Copy the full SHA
    5c60d0c View commit details
  14. python27Packages.paste: 3.4.0 -> 3.4.1

    r-ryantm authored and Jon committed Jul 6, 2020
    Copy the full SHA
    b7fd3f7 View commit details
  15. python27Packages.pep8-naming: 0.10.0 -> 0.11.1

    r-ryantm authored and Jon committed Jul 6, 2020
    Copy the full SHA
    84de929 View commit details
  16. python37Packages.ckcc-protocol: 1.0.1 -> 1.0.2

    r-ryantm authored and Jon committed Jul 6, 2020
    Copy the full SHA
    65c2c01 View commit details
  17. python27Packages.identify: 1.4.19 -> 1.4.21

    r-ryantm authored and Jon committed Jul 6, 2020
    Copy the full SHA
    7ce695f View commit details
  18. python27Packages.ipdb: 0.13.2 -> 0.13.3

    r-ryantm authored and Jon committed Jul 6, 2020
    Copy the full SHA
    11f0e9d View commit details
  19. python3Packages.mt-940: disable tests, no longer present

    Jonathan Ringer committed Jul 6, 2020
    Copy the full SHA
    fc06840 View commit details
  20. Copy the full SHA
    7971042 View commit details
  21. Copy the full SHA
    0848c2f View commit details
  22. nixos/ihatemoney: work around bug in uwsgi

    happens when dowbloading csv reports
    symphorien committed Jul 6, 2020
    Copy the full SHA
    3603c4e View commit details
  23. Copy the full SHA
    a71acfe View commit details
  24. Copy the full SHA
    7918f8c View commit details
  25. Copy the full SHA
    ed5b736 View commit details
  26. Copy the full SHA
    2720b53 View commit details
  27. Copy the full SHA
    7761494 View commit details
  28. python3Packages.ihatemoney: disable on python2

    it does not build and is not supported according to setup.cfg
    symphorien committed Jul 6, 2020
    Copy the full SHA
    4b819d4 View commit details
  29. Copy the full SHA
    bcafd84 View commit details
  30. Copy the full SHA
    2e342f4 View commit details
  31. Copy the full SHA
    826b7c1 View commit details
  32. Copy the full SHA
    2b0cfa4 View commit details
  33. python37Packages.geopandas: 0.7.0 -> 0.8.0

    r-ryantm authored and Jon committed Jul 6, 2020
    Copy the full SHA
    f166a13 View commit details
  34. python27Packages.dnslib: 0.9.13 -> 0.9.14

    r-ryantm authored and Jon committed Jul 6, 2020
    Copy the full SHA
    a5ac6d0 View commit details
  35. python37Packages.libversion: 1.2.0 -> 1.2.1

    r-ryantm authored and Jon committed Jul 6, 2020
    Copy the full SHA
    b7f5606 View commit details
  36. python27Packages.elasticsearch: 7.7.1 -> 7.8.0

    r-ryantm authored and Jon committed Jul 6, 2020
    Copy the full SHA
    32dd8df View commit details
  37. python37Packages.nbsphinx: 0.7.0 -> 0.7.1

    r-ryantm authored and Jon committed Jul 6, 2020
    Copy the full SHA
    8fc8153 View commit details
  38. Copy the full SHA
    a372677 View commit details
  39. python27Packages.geoalchemy2: 0.8.3 -> 0.8.4

    r-ryantm authored and Jon committed Jul 6, 2020
    Copy the full SHA
    918a651 View commit details
  40. Copy the full SHA
    fd263c2 View commit details
  41. python27Packages.azure-mgmt-eventhub: 3.1.0 -> 4.0.0

    r-ryantm authored and Jon committed Jul 6, 2020
    Copy the full SHA
    be75df9 View commit details
  42. python37Packages.azure-mgmt-security: 0.4.0 -> 0.4.1

    r-ryantm authored and Jon committed Jul 6, 2020
    Copy the full SHA
    636fec8 View commit details
  43. python27Packages.hvac: 0.10.3 -> 0.10.4

    r-ryantm authored and Jon committed Jul 6, 2020
    Copy the full SHA
    f650a87 View commit details
Showing with 707 additions and 224 deletions.
  1. +6 −0 maintainers/maintainer-list.nix
  2. +1 −1 nixos/doc/manual/man-nixos-rebuild.xml
  3. +29 −1 nixos/modules/system/boot/loader/grub/grub.nix
  4. +63 −27 nixos/modules/system/boot/loader/grub/install-grub.pl
  5. +80 −15 nixos/modules/virtualisation/qemu-vm.nix
  6. +1 −1 nixos/tests/all-tests.nix
  7. +10 −3 nixos/tests/ihatemoney.nix
  8. +32 −0 nixos/tests/systemd-boot.nix
  9. +2 −2 pkgs/applications/audio/pulseeffects/default.nix
  10. +8 −5 pkgs/applications/virtualization/OVMF/default.nix
  11. +7 −1 pkgs/build-support/fetchurl/builder.sh
  12. +8 −1 pkgs/build-support/fetchurl/default.nix
  13. +25 −0 pkgs/desktops/enlightenment/0003-setuid-missing-path.patch
  14. +1 −0 pkgs/desktops/enlightenment/enlightenment.nix
  15. +20 −24 pkgs/development/arduino/arduino-core/default.nix
  16. +1 −1 pkgs/development/libraries/argp-standalone/default.nix
  17. +19 −10 pkgs/development/libraries/gdcm/default.nix
  18. +2 −2 pkgs/development/python-modules/atlassian-python-api/default.nix
  19. +2 −2 pkgs/development/python-modules/azure-mgmt-appconfiguration/default.nix
  20. +2 −2 pkgs/development/python-modules/azure-mgmt-compute/default.nix
  21. +2 −2 pkgs/development/python-modules/azure-mgmt-containerinstance/default.nix
  22. +2 −2 pkgs/development/python-modules/azure-mgmt-containerservice/default.nix
  23. +2 −2 pkgs/development/python-modules/azure-mgmt-cosmosdb/default.nix
  24. +2 −2 pkgs/development/python-modules/azure-mgmt-datafactory/default.nix
  25. +2 −2 pkgs/development/python-modules/azure-mgmt-eventhub/default.nix
  26. +2 −2 pkgs/development/python-modules/azure-mgmt-hdinsight/default.nix
  27. +2 −2 pkgs/development/python-modules/azure-mgmt-iotcentral/default.nix
  28. +2 −2 pkgs/development/python-modules/azure-mgmt-media/default.nix
  29. +2 −2 pkgs/development/python-modules/azure-mgmt-network/default.nix
  30. +2 −2 pkgs/development/python-modules/azure-mgmt-recoveryservicesbackup/default.nix
  31. +2 −2 pkgs/development/python-modules/azure-mgmt-resource/default.nix
  32. +2 −2 pkgs/development/python-modules/azure-mgmt-security/default.nix
  33. +2 −2 pkgs/development/python-modules/azure-mgmt-sql/default.nix
  34. +2 −2 pkgs/development/python-modules/azure-mgmt-storage/default.nix
  35. +2 −2 pkgs/development/python-modules/azure-mgmt-subscription/default.nix
  36. +11 −2 pkgs/development/python-modules/azure-multiapi-storage/default.nix
  37. +2 −2 pkgs/development/python-modules/azure-storage-file-share/default.nix
  38. +2 −2 pkgs/development/python-modules/ckcc-protocol/default.nix
  39. +42 −0 pkgs/development/python-modules/debts/default.nix
  40. +2 −2 pkgs/development/python-modules/dnslib/default.nix
  41. +2 −2 pkgs/development/python-modules/elasticsearch/default.nix
  42. +2 −2 pkgs/development/python-modules/geoalchemy2/default.nix
  43. +2 −2 pkgs/development/python-modules/geopandas/default.nix
  44. +2 −2 pkgs/development/python-modules/hvac/default.nix
  45. +2 −2 pkgs/development/python-modules/identify/default.nix
  46. +41 −7 pkgs/development/python-modules/ihatemoney/default.nix
  47. +2 −2 pkgs/development/python-modules/ipdb/default.nix
  48. +2 −2 pkgs/development/python-modules/jupyterlab/default.nix
  49. +2 −2 pkgs/development/python-modules/latexcodec/default.nix
  50. +2 −2 pkgs/development/python-modules/libevdev/default.nix
  51. +2 −2 pkgs/development/python-modules/libversion/default.nix
  52. +4 −0 pkgs/development/python-modules/mt-940/default.nix
  53. +2 −2 pkgs/development/python-modules/mwclient/default.nix
  54. +2 −2 pkgs/development/python-modules/nbsphinx/default.nix
  55. +4 −4 pkgs/development/python-modules/nibabel/default.nix
  56. +2 −2 pkgs/development/python-modules/nuitka/default.nix
  57. +2 −2 pkgs/development/python-modules/paste/default.nix
  58. +2 −2 pkgs/development/python-modules/pep8-naming/default.nix
  59. +2 −2 pkgs/development/python-modules/pymupdf/default.nix
  60. +46 −0 pkgs/development/python-modules/sqlalchemy-continuum/default.nix
  61. +32 −0 pkgs/development/python-modules/sqlalchemy-i18n/default.nix
  62. +2 −2 pkgs/development/python-modules/twilio/default.nix
  63. +7 −2 pkgs/development/tools/misc/elfutils/default.nix
  64. +46 −0 pkgs/development/tools/misc/nxpmicro-mfgtools/default.nix
  65. +2 −2 pkgs/development/tools/scalafmt/default.nix
  66. +3 −3 pkgs/development/web/deno/default.nix
  67. +2 −2 pkgs/servers/uwsgi/default.nix
  68. +2 −2 pkgs/tools/admin/azure-cli/default.nix
  69. +19 −16 pkgs/tools/admin/azure-cli/python-packages.nix
  70. +4 −3 pkgs/tools/admin/salt/default.nix
  71. +7 −8 pkgs/tools/admin/salt/fix-libcrypto-loading.patch
  72. +3 −3 pkgs/tools/misc/starship/default.nix
  73. +4 −2 pkgs/tools/security/eid-mw/default.nix
  74. +3 −0 pkgs/top-level/all-packages.nix
  75. +25 −0 pkgs/top-level/perl-packages.nix
  76. +11 −0 pkgs/top-level/python-packages.nix
6 changes: 6 additions & 0 deletions maintainers/maintainer-list.nix
Original file line number Diff line number Diff line change
@@ -1055,6 +1055,12 @@
githubId = 16330;
name = "Mathijs Kwik";
};
bmilanov = {
name = "Biser Milanov";
email = "bmilanov11+nixpkgs@gmail.com";
github = "bmilanov";
githubId = 30090366;
};
bobakker = {
email = "bobakk3r@gmail.com";
github = "bobakker";
2 changes: 1 addition & 1 deletion nixos/doc/manual/man-nixos-rebuild.xml
Original file line number Diff line number Diff line change
@@ -315,7 +315,7 @@
switch</command>), because the hardware and boot loader configuration in
the VM are different. The boot loader is installed on an automatically
generated virtual disk containing a <filename>/boot</filename>
partition, which is mounted read-only in the VM.
partition.
</para>
</listitem>
</varlistentry>
30 changes: 29 additions & 1 deletion nixos/modules/system/boot/loader/grub/grub.nix
Original file line number Diff line number Diff line change
@@ -61,6 +61,7 @@ let
inherit (efi) canTouchEfiVariables;
inherit (cfg)
version extraConfig extraPerEntryConfig extraEntries forceInstall useOSProber
extraGrubInstallArgs
extraEntriesBeforeNixOS extraPrepareConfig configurationLimit copyKernels
default fsIdentifier efiSupport efiInstallAsRemovable gfxmodeEfi gfxmodeBios gfxpayloadEfi gfxpayloadBios;
path = with pkgs; makeBinPath (
@@ -298,6 +299,33 @@ in
'';
};

extraGrubInstallArgs = mkOption {
default = [ ];
example = [ "--modules=nativedisk ahci pata part_gpt part_msdos diskfilter mdraid1x lvm ext2" ];
type = types.listOf types.str;
description = ''
Additional arguments passed to <literal>grub-install</literal>.
A use case for this is to build specific GRUB2 modules
directly into the GRUB2 kernel image, so that they are available
and activated even in the <literal>grub rescue</literal> shell.
They are also necessary when the BIOS/UEFI is bugged and cannot
correctly read large disks (e.g. above 2 TB), so GRUB2's own
<literal>nativedisk</literal> and related modules can be used
to use its own disk drivers. The example shows one such case.
This is also useful for booting from USB.
See the
<link xlink:href="http://git.savannah.gnu.org/cgit/grub.git/tree/grub-core/commands/nativedisk.c?h=grub-2.04#n326">
GRUB source code
</link>
for which disk modules are available.
The list elements are passed directly as <literal>argv</literal>
arguments to the <literal>grub-install</literal> program, in order.
'';
};

extraPerEntryConfig = mkOption {
default = "";
example = "root (hd0)";
@@ -669,7 +697,7 @@ in
in pkgs.writeScript "install-grub.sh" (''
#!${pkgs.runtimeShell}
set -e
export PERL5LIB=${with pkgs.perlPackages; makePerlPath [ FileSlurp XMLLibXML XMLSAX XMLSAXBase ListCompare ]}
export PERL5LIB=${with pkgs.perlPackages; makePerlPath [ FileSlurp XMLLibXML XMLSAX XMLSAXBase ListCompare JSON ]}
${optionalString cfg.enableCryptodisk "export GRUB_ENABLE_CRYPTODISK=y"}
'' + flip concatMapStrings cfg.mirroredBoots (args: ''
${pkgs.perl}/bin/perl ${install-grub-pl} ${grubConfig args} $@
90 changes: 63 additions & 27 deletions nixos/modules/system/boot/loader/grub/install-grub.pl
Original file line number Diff line number Diff line change
@@ -8,6 +8,7 @@
use File::Copy;
use File::Slurp;
use File::Temp;
use JSON;
require List::Compare;
use POSIX;
use Cwd;
@@ -20,6 +21,16 @@

sub get { my ($name) = @_; return $dom->findvalue("/expr/attrs/attr[\@name = '$name']/*/\@value"); }

sub getList {
my ($name) = @_;
my @list = ();
foreach my $entry ($dom->findnodes("/expr/attrs/attr[\@name = '$name']/list/string/\@value")) {
$entry = $entry->findvalue(".") or die;
push(@list, $entry);
}
return @list;
}

sub readFile {
my ($fn) = @_; local $/ = undef;
open FILE, "<$fn" or return undef; my $s = <FILE>; close FILE;
@@ -241,7 +252,7 @@ sub GrubFs {
timeout $timeout
";
if ($splashImage) {
copy $splashImage, "$bootPath/background.xpm.gz" or die "cannot copy $splashImage to $bootPath\n";
copy $splashImage, "$bootPath/background.xpm.gz" or die "cannot copy $splashImage to $bootPath: $!\n";
$conf .= "splashimage " . ($grubBoot->path eq "/" ? "" : $grubBoot->path) . "/background.xpm.gz\n";
}
}
@@ -319,7 +330,7 @@ sub GrubFs {
";

if ($font) {
copy $font, "$bootPath/converted-font.pf2" or die "cannot copy $font to $bootPath\n";
copy $font, "$bootPath/converted-font.pf2" or die "cannot copy $font to $bootPath: $!\n";
$conf .= "
insmod font
if loadfont " . ($grubBoot->path eq "/" ? "" : $grubBoot->path) . "/converted-font.pf2; then
@@ -347,7 +358,7 @@ sub GrubFs {
background_color '$backgroundColor'
";
}
copy $splashImage, "$bootPath/background$suffix" or die "cannot copy $splashImage to $bootPath\n";
copy $splashImage, "$bootPath/background$suffix" or die "cannot copy $splashImage to $bootPath: $!\n";
$conf .= "
insmod " . substr($suffix, 1) . "
if background_image --mode '$splashMode' " . ($grubBoot->path eq "/" ? "" : $grubBoot->path) . "/background$suffix; then
@@ -381,8 +392,8 @@ sub copyToKernelsDir {
# kernels or initrd if this script is ever interrupted.
if (! -e $dst) {
my $tmp = "$dst.tmp";
copy $path, $tmp or die "cannot copy $path to $tmp\n";
rename $tmp, $dst or die "cannot rename $tmp to $dst\n";
copy $path, $tmp or die "cannot copy $path to $tmp: $!\n";
rename $tmp, $dst or die "cannot rename $tmp to $dst: $!\n";
}
$copied{$dst} = 1;
return ($grubBoot->path eq "/" ? "" : $grubBoot->path) . "/kernels/$name";
@@ -405,10 +416,10 @@ sub addEntry {
# Make sure initrd is not world readable (won't work if /boot is FAT)
umask 0137;
my $initrdSecretsPathTemp = File::Temp::mktemp("$initrdSecretsPath.XXXXXXXX");
system("$path/append-initrd-secrets", $initrdSecretsPathTemp) == 0 or die "failed to create initrd secrets\n";
system("$path/append-initrd-secrets", $initrdSecretsPathTemp) == 0 or die "failed to create initrd secrets: $!\n";
# Check whether any secrets were actually added
if (-e $initrdSecretsPathTemp && ! -z _) {
rename $initrdSecretsPathTemp, $initrdSecretsPath or die "failed to move initrd secrets into place\n";
rename $initrdSecretsPathTemp, $initrdSecretsPath or die "failed to move initrd secrets into place: $!\n";
$copied{$initrdSecretsPath} = 1;
$initrd .= " " . ($grubBoot->path eq "/" ? "" : $grubBoot->path) . "/kernels/$initrdName-secrets";
} else {
@@ -575,7 +586,7 @@ sub getEfiTarget {
}

# Atomically switch to the new config
rename $tmpFile, $confFile or die "cannot rename $tmpFile to $confFile\n";
rename $tmpFile, $confFile or die "cannot rename $tmpFile to $confFile: $!\n";


# Remove obsolete files from $bootPath/kernels.
@@ -596,9 +607,12 @@ sub getEfiTarget {
efi => '$',
devices => '$',
efiMountPoint => '$',
extraGrubInstallArgs => '@',
});
# If you add something to the state file, only add it to the end
# because it is read line-by-line.
sub readGrubState {
my $defaultGrubState = GrubState->new(name => "", version => "", efi => "", devices => "", efiMountPoint => "" );
my $defaultGrubState = GrubState->new(name => "", version => "", efi => "", devices => "", efiMountPoint => "", extraGrubInstallArgs => () );
open FILE, "<$bootPath/grub/state" or return $defaultGrubState;
local $/ = "\n";
my $name = <FILE>;
@@ -611,24 +625,34 @@ sub readGrubState {
chomp($devices);
my $efiMountPoint = <FILE>;
chomp($efiMountPoint);
# Historically, arguments in the state file were one per each line, but that
# gets really messy when newlines are involved, structured arguments
# like lists are needed (they have to have a separator encoding), or even worse,
# when we need to remove a setting in the future. Thus, the 6th line is a JSON
# object that can store structured data, with named keys, and all new state
# should go in there.
my $jsonStateLine = <FILE>;
# For historical reasons we do not check the values above for un-definedness
# (that is, when the state file has too few lines and EOF is reached),
# because the above come from the first version of this logic and are thus
# guaranteed to be present.
$jsonStateLine = defined $jsonStateLine ? $jsonStateLine : '{}'; # empty JSON object
chomp($jsonStateLine);
my %jsonState = %{decode_json($jsonStateLine)};
my @extraGrubInstallArgs = @{$jsonState{'extraGrubInstallArgs'}};
close FILE;
my $grubState = GrubState->new(name => $name, version => $version, efi => $efi, devices => $devices, efiMountPoint => $efiMountPoint );
my $grubState = GrubState->new(name => $name, version => $version, efi => $efi, devices => $devices, efiMountPoint => $efiMountPoint, extraGrubInstallArgs => \@extraGrubInstallArgs );
return $grubState
}

sub getDeviceTargets {
my @devices = ();
foreach my $dev ($dom->findnodes('/expr/attrs/attr[@name = "devices"]/list/string/@value')) {
$dev = $dev->findvalue(".") or die;
push(@devices, $dev);
}
return @devices;
}
my @deviceTargets = getDeviceTargets();
my @deviceTargets = getList('devices');
my $prevGrubState = readGrubState();
my @prevDeviceTargets = split/,/, $prevGrubState->devices;
my @extraGrubInstallArgs = getList('extraGrubInstallArgs');
my @prevExtraGrubInstallArgs = $prevGrubState->extraGrubInstallArgs;

my $devicesDiffer = scalar (List::Compare->new( '-u', '-a', \@deviceTargets, \@prevDeviceTargets)->get_symmetric_difference());
my $extraGrubInstallArgsDiffer = scalar (List::Compare->new( '-u', '-a', \@extraGrubInstallArgs, \@prevExtraGrubInstallArgs)->get_symmetric_difference());
my $nameDiffer = get("fullName") ne $prevGrubState->name;
my $versionDiffer = get("fullVersion") ne $prevGrubState->version;
my $efiDiffer = $efiTarget ne $prevGrubState->efi;
@@ -637,33 +661,33 @@ sub getDeviceTargets {
warn "NIXOS_INSTALL_GRUB env var deprecated, use NIXOS_INSTALL_BOOTLOADER";
$ENV{'NIXOS_INSTALL_BOOTLOADER'} = "1";
}
my $requireNewInstall = $devicesDiffer || $nameDiffer || $versionDiffer || $efiDiffer || $efiMountPointDiffer || (($ENV{'NIXOS_INSTALL_BOOTLOADER'} // "") eq "1");
my $requireNewInstall = $devicesDiffer || $extraGrubInstallArgsDiffer || $nameDiffer || $versionDiffer || $efiDiffer || $efiMountPointDiffer || (($ENV{'NIXOS_INSTALL_BOOTLOADER'} // "") eq "1");

# install a symlink so that grub can detect the boot drive
my $tmpDir = File::Temp::tempdir(CLEANUP => 1) or die "Failed to create temporary space";
symlink "$bootPath", "$tmpDir/boot" or die "Failed to symlink $tmpDir/boot";
my $tmpDir = File::Temp::tempdir(CLEANUP => 1) or die "Failed to create temporary space: $!";
symlink "$bootPath", "$tmpDir/boot" or die "Failed to symlink $tmpDir/boot: $!";

# install non-EFI GRUB
if (($requireNewInstall != 0) && ($efiTarget eq "no" || $efiTarget eq "both")) {
foreach my $dev (@deviceTargets) {
next if $dev eq "nodev";
print STDERR "installing the GRUB $grubVersion boot loader on $dev...\n";
my @command = ("$grub/sbin/grub-install", "--recheck", "--root-directory=$tmpDir", Cwd::abs_path($dev));
my @command = ("$grub/sbin/grub-install", "--recheck", "--root-directory=$tmpDir", Cwd::abs_path($dev), @extraGrubInstallArgs);
if ($forceInstall eq "true") {
push @command, "--force";
}
if ($grubTarget ne "") {
push @command, "--target=$grubTarget";
}
(system @command) == 0 or die "$0: installation of GRUB on $dev failed\n";
(system @command) == 0 or die "$0: installation of GRUB on $dev failed: $!\n";
}
}


# install EFI GRUB
if (($requireNewInstall != 0) && ($efiTarget eq "only" || $efiTarget eq "both")) {
print STDERR "installing the GRUB $grubVersion EFI boot loader into $efiSysMountPoint...\n";
my @command = ("$grubEfi/sbin/grub-install", "--recheck", "--target=$grubTargetEfi", "--boot-directory=$bootPath", "--efi-directory=$efiSysMountPoint");
my @command = ("$grubEfi/sbin/grub-install", "--recheck", "--target=$grubTargetEfi", "--boot-directory=$bootPath", "--efi-directory=$efiSysMountPoint", @extraGrubInstallArgs);
if ($forceInstall eq "true") {
push @command, "--force";
}
@@ -674,17 +698,29 @@ sub getDeviceTargets {
push @command, "--removable" if $efiInstallAsRemovable eq "true";
}

(system @command) == 0 or die "$0: installation of GRUB EFI into $efiSysMountPoint failed\n";
(system @command) == 0 or die "$0: installation of GRUB EFI into $efiSysMountPoint failed: $!\n";
}


# update GRUB state file
if ($requireNewInstall != 0) {
open FILE, ">$bootPath/grub/state" or die "cannot create $bootPath/grub/state: $!\n";
# Temp file for atomic rename.
my $stateFile = "$bootPath/grub/state";
my $stateFileTmp = $stateFile . ".tmp";

open FILE, ">$stateFileTmp" or die "cannot create $stateFileTmp: $!\n";
print FILE get("fullName"), "\n" or die;
print FILE get("fullVersion"), "\n" or die;
print FILE $efiTarget, "\n" or die;
print FILE join( ",", @deviceTargets ), "\n" or die;
print FILE $efiSysMountPoint, "\n" or die;
my %jsonState = (
extraGrubInstallArgs => \@extraGrubInstallArgs
);
my $jsonStateLine = encode_json(\%jsonState);
print FILE $jsonStateLine, "\n" or die;
close FILE or die;

# Atomically switch to the new state file
rename $stateFileTmp, $stateFile or die "cannot rename $stateFileTmp to $stateFile: $!\n";
}
Loading