mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-13 05:05:29 +03:00
fix bug where nix store DB would not be loadable if root was not mounted on /
This commit is contained in:
parent
52bb3ddb86
commit
08afe03265
1 changed files with 13 additions and 3 deletions
|
@ -150,6 +150,15 @@ in
|
||||||
Whether to configure the sd image to expand it's partition on boot.
|
Whether to configure the sd image to expand it's partition on boot.
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
nixPathRegistrationFile = mkOption {
|
||||||
|
type = types.str;
|
||||||
|
default = "/nix-path-registration";
|
||||||
|
description = ''
|
||||||
|
Location of the file containing the input for nix-store --load-db once the machine has booted.
|
||||||
|
If overriding fileSystems."/" then you should to set this to the root mount + /nix-path-registration
|
||||||
|
'';
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
config = {
|
config = {
|
||||||
|
@ -267,23 +276,24 @@ in
|
||||||
${pkgs.parted}/bin/partprobe
|
${pkgs.parted}/bin/partprobe
|
||||||
${pkgs.e2fsprogs}/bin/resize2fs $rootPart
|
${pkgs.e2fsprogs}/bin/resize2fs $rootPart
|
||||||
'';
|
'';
|
||||||
|
nixPathRegistrationFile = config.sdImage.nixPathRegistrationFile;
|
||||||
in ''
|
in ''
|
||||||
# On the first boot do some maintenance tasks
|
# On the first boot do some maintenance tasks
|
||||||
if [ -f /nix-path-registration ]; then
|
if [ -f ${nixPathRegistrationFile} ]; then
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
set -x
|
set -x
|
||||||
|
|
||||||
${expandOnBoot}
|
${expandOnBoot}
|
||||||
|
|
||||||
# Register the contents of the initial Nix store
|
# Register the contents of the initial Nix store
|
||||||
${config.nix.package.out}/bin/nix-store --load-db < /nix-path-registration
|
${config.nix.package.out}/bin/nix-store --load-db < ${nixPathRegistrationFile}
|
||||||
|
|
||||||
# nixos-rebuild also requires a "system" profile and an /etc/NIXOS tag.
|
# nixos-rebuild also requires a "system" profile and an /etc/NIXOS tag.
|
||||||
touch /etc/NIXOS
|
touch /etc/NIXOS
|
||||||
${config.nix.package.out}/bin/nix-env -p /nix/var/nix/profiles/system --set /run/current-system
|
${config.nix.package.out}/bin/nix-env -p /nix/var/nix/profiles/system --set /run/current-system
|
||||||
|
|
||||||
# Prevents this from running on later boots.
|
# Prevents this from running on later boots.
|
||||||
rm -f /nix-path-registration
|
rm -f ${nixPathRegistrationFile}
|
||||||
fi
|
fi
|
||||||
'';
|
'';
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue