Compare commits

...
2 Commits
Author SHA1 Message Date
Jörg Thalheim d4c64aee75 better error if no disks are configured 2024-08-26 18:13:17 +02:00
Jörg Thalheim 54bf06ba8c debug memory usage 2024-08-15 15:07:22 +02:00
2 changed files with 49 additions and 25 deletions

No files matched your search

+22 -3
View File
@@ -67,13 +67,32 @@ let
'';
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
export NIX_STATE_DIR=${systemToInstall.config.disko.rootMountPoint}/nix/var/nix
nix-store --load-db < "${closureInfo}/registration"
# We copy files with cp because `nix copy` seems to have a large memory leak
mkdir -p ${systemToInstall.config.disko.rootMountPoint}/nix/store
xargs cp --recursive --target ${systemToInstall.config.disko.rootMountPoint}/nix/store < ${closureInfo}/store-paths
# We copy files with rsync because `nix copy` seems to have a large memory leak
${pkgs.rsync}/bin/rsync -rtpl --files-from=${closureInfo}/store-paths / ${systemToInstall.config.disko.rootMountPoint}
${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}
+27 -22
View File
@@ -98,30 +98,35 @@ in
};
};
};
config = lib.mkIf (cfg.devices.disk != { }) {
system.build = (cfg.devices._scripts { inherit pkgs; checked = cfg.checkScripts; }) // {
config = {
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
disko = builtins.trace "the .disko output is deprecated, please use .diskoScript instead" (cfg.devices._scripts { inherit pkgs; }).diskoScript;
diskoNoDeps = builtins.trace "the .diskoNoDeps output is deprecated, please use .diskoScriptNoDeps instead" (cfg.devices._scripts { inherit pkgs; }).diskoScriptNoDeps;
diskoImagesScript = diskoLib.makeDiskImagesScript {
nixosConfig = args;
};
diskoImages = diskoLib.makeDiskImages {
nixosConfig = args;
};
diskoImagesScript = diskoLib.makeDiskImagesScript {
nixosConfig = args;
};
installTest = diskoLib.testLib.makeDiskoTest {
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;
};
};
installTest = diskoLib.testLib.makeDiskoTest {
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