mirror of
https://github.com/nix-community/disko.git
synced 2026-11-30 13:03:28 +01:00
Compare commits
2
Commits
v1.8.2
...
better-error
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
d4c64aee75 | ||
|
|
54bf06ba8c |
No files matched your search
+22
-3
@@ -67,13 +67,32 @@ let
|
|||||||
'';
|
'';
|
||||||
|
|
||||||
installer = ''
|
installer = ''
|
||||||
|
if [[ -f /sys/module/zfs/parameters/zfs_arc_max ]]; then
|
||||||
|
# We have seen `cp` run out of memory when copying the store paths and using zfs.
|
||||||
|
# Default for ARC is 1/2 of RAM, we choose 1/4 of RAM.
|
||||||
|
# Since we mostly write to the store and don't read from it, we don't need a large ARC.
|
||||||
|
# This hopefully gives zfs enough time to free up memory.
|
||||||
|
QUARTER_RAM=$(($(grep MemTotal /proc/meminfo | awk '{print $2 * 1024}') / 4))
|
||||||
|
echo "$QUARTER_RAM" > /sys/module/zfs/parameters/zfs_arc_max
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Useful for monitoring memory usage
|
||||||
|
#echo $(($(cat /sys/module/zfs/parameters/zfs_arc_max) / 1024 / 1024)) MB
|
||||||
|
#(while true; do
|
||||||
|
# ${pkgs.procps}/bin/free -h
|
||||||
|
# if [[ -f /sys/module/zfs/parameters/zfs_arc_max ]]; then ${pkgs.zfs}/bin/arcstat; fi
|
||||||
|
# ${pkgs.procps}/bin/ps -eo pid,ppid,comm,%mem,%cpu --sort=-%mem | head -n 4
|
||||||
|
# # this can be very verbose
|
||||||
|
# # ${pkgs.linuxPackages_latest.mm-tools}/bin/slabinfo
|
||||||
|
# sleep 1
|
||||||
|
#done) &
|
||||||
|
|
||||||
# populate nix db, so nixos-install doesn't complain
|
# populate nix db, so nixos-install doesn't complain
|
||||||
export NIX_STATE_DIR=${systemToInstall.config.disko.rootMountPoint}/nix/var/nix
|
export NIX_STATE_DIR=${systemToInstall.config.disko.rootMountPoint}/nix/var/nix
|
||||||
nix-store --load-db < "${closureInfo}/registration"
|
nix-store --load-db < "${closureInfo}/registration"
|
||||||
|
|
||||||
# We copy files with cp because `nix copy` seems to have a large memory leak
|
# We copy files with rsync because `nix copy` seems to have a large memory leak
|
||||||
mkdir -p ${systemToInstall.config.disko.rootMountPoint}/nix/store
|
${pkgs.rsync}/bin/rsync -rtpl --files-from=${closureInfo}/store-paths / ${systemToInstall.config.disko.rootMountPoint}
|
||||||
xargs cp --recursive --target ${systemToInstall.config.disko.rootMountPoint}/nix/store < ${closureInfo}/store-paths
|
|
||||||
|
|
||||||
${systemToInstall.config.system.build.nixos-install}/bin/nixos-install --root ${systemToInstall.config.disko.rootMountPoint} --system ${systemToInstall.config.system.build.toplevel} --keep-going --no-channel-copy -v --no-root-password --option binary-caches ""
|
${systemToInstall.config.system.build.nixos-install}/bin/nixos-install --root ${systemToInstall.config.disko.rootMountPoint} --system ${systemToInstall.config.system.build.toplevel} --keep-going --no-channel-copy -v --no-root-password --option binary-caches ""
|
||||||
umount -Rv ${systemToInstall.config.disko.rootMountPoint}
|
umount -Rv ${systemToInstall.config.disko.rootMountPoint}
|
||||||
|
|||||||
+27
-22
@@ -98,30 +98,35 @@ in
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
config = lib.mkIf (cfg.devices.disk != { }) {
|
config = {
|
||||||
system.build = (cfg.devices._scripts { inherit pkgs; checked = cfg.checkScripts; }) // {
|
system.build = lib.mapAttrs (name: cfg:
|
||||||
|
if cfg.devices.disk == {} then
|
||||||
|
throw ''
|
||||||
|
Cannot provide ${name} without disks configured.
|
||||||
|
Current value of disko.devices.disk is empty.
|
||||||
|
Set up a disk configuration according to:
|
||||||
|
https://github.com/nix-community/disko/blob/master/docs/quickstart.md#step-1-choose-a-disk-configuration
|
||||||
|
''
|
||||||
|
else cfg)
|
||||||
|
(cfg.devices._scripts { inherit pkgs; checked = cfg.checkScripts; } // {
|
||||||
|
diskoImages = diskoLib.makeDiskImages {
|
||||||
|
nixosConfig = args;
|
||||||
|
};
|
||||||
|
|
||||||
# we keep these old outputs for compatibility
|
diskoImagesScript = diskoLib.makeDiskImagesScript {
|
||||||
disko = builtins.trace "the .disko output is deprecated, please use .diskoScript instead" (cfg.devices._scripts { inherit pkgs; }).diskoScript;
|
nixosConfig = args;
|
||||||
diskoNoDeps = builtins.trace "the .diskoNoDeps output is deprecated, please use .diskoScriptNoDeps instead" (cfg.devices._scripts { inherit pkgs; }).diskoScriptNoDeps;
|
};
|
||||||
|
|
||||||
diskoImages = diskoLib.makeDiskImages {
|
installTest = diskoLib.testLib.makeDiskoTest {
|
||||||
nixosConfig = args;
|
inherit extendModules pkgs;
|
||||||
};
|
name = "${config.networking.hostName}-disko";
|
||||||
diskoImagesScript = diskoLib.makeDiskImagesScript {
|
disko-config = builtins.removeAttrs config [ "_module" ];
|
||||||
nixosConfig = args;
|
testMode = "direct";
|
||||||
};
|
efi = cfg.tests.efi;
|
||||||
|
extraSystemConfig = cfg.tests.extraConfig;
|
||||||
installTest = diskoLib.testLib.makeDiskoTest {
|
extraTestScript = cfg.tests.extraChecks;
|
||||||
inherit extendModules pkgs;
|
};
|
||||||
name = "${config.networking.hostName}-disko";
|
});
|
||||||
disko-config = builtins.removeAttrs config [ "_module" ];
|
|
||||||
testMode = "direct";
|
|
||||||
efi = cfg.tests.efi;
|
|
||||||
extraSystemConfig = cfg.tests.extraConfig;
|
|
||||||
extraTestScript = cfg.tests.extraChecks;
|
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
# we need to specify the keys here, so we don't get an infinite recursion error
|
# we need to specify the keys here, so we don't get an infinite recursion error
|
||||||
|
|||||||
Reference in new issue
Block a user