mirror of
https://github.com/nix-community/disko.git
synced 2026-11-30 13:03:28 +01:00
Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a007e6f496 | ||
|
|
0d510fe40b | ||
|
|
ffc1f95f6c | ||
|
|
0257e44f4a | ||
|
|
7e1b215a0a | ||
|
|
1e6f8a7b46 | ||
|
|
5b01cea8b5 |
No files matched your search
@@ -240,6 +240,10 @@ main() {
|
|||||||
NIX_STATE_DIR=${mountPoint}/nix/var/nix nix-store --load-db < "${closure_info}/registration"
|
NIX_STATE_DIR=${mountPoint}/nix/var/nix nix-store --load-db < "${closure_info}/registration"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
echo "Syncing filesystems" >&2
|
||||||
|
fsync "${mountPoint}"
|
||||||
|
|
||||||
|
echo "Install NixOS" >&2
|
||||||
nixos-install --no-channel-copy --no-root-password --system "$nixos_system" --root "$mountPoint"
|
nixos-install --no-channel-copy --no-root-password --system "$nixos_system" --root "$mountPoint"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Generated
+3
-3
@@ -2,11 +2,11 @@
|
|||||||
"nodes": {
|
"nodes": {
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1721782431,
|
"lastModified": 1723221148,
|
||||||
"narHash": "sha256-UNDpwjYxNXQet/g3mgRLsQ9zxrbm9j2JEvP4ijF3AWs=",
|
"narHash": "sha256-7pjpeQlZUNQ4eeVntytU3jkw9dFK3k1Htgk2iuXjaD8=",
|
||||||
"owner": "NixOS",
|
"owner": "NixOS",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "4f02464258baaf54992debfd010a7a3662a25536",
|
"rev": "154bcb95ad51bc257c2ce4043a725de6ca700ef6",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
|||||||
+3
-22
@@ -67,32 +67,13 @@ 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 rsync because `nix copy` seems to have a large memory leak
|
# We copy files with cp because `nix copy` seems to have a large memory leak
|
||||||
${pkgs.rsync}/bin/rsync -rtpl --files-from=${closureInfo}/store-paths / ${systemToInstall.config.disko.rootMountPoint}
|
mkdir -p ${systemToInstall.config.disko.rootMountPoint}/nix/store
|
||||||
|
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}
|
||||||
|
|||||||
+22
-27
@@ -98,35 +98,30 @@ in
|
|||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
config = {
|
config = lib.mkIf (cfg.devices.disk != { }) {
|
||||||
system.build = lib.mapAttrs (name: cfg:
|
system.build = (cfg.devices._scripts { inherit pkgs; checked = cfg.checkScripts; }) // {
|
||||||
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;
|
|
||||||
};
|
|
||||||
|
|
||||||
diskoImagesScript = diskoLib.makeDiskImagesScript {
|
# we keep these old outputs for compatibility
|
||||||
nixosConfig = args;
|
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;
|
||||||
|
|
||||||
installTest = diskoLib.testLib.makeDiskoTest {
|
diskoImages = diskoLib.makeDiskImages {
|
||||||
inherit extendModules pkgs;
|
nixosConfig = args;
|
||||||
name = "${config.networking.hostName}-disko";
|
};
|
||||||
disko-config = builtins.removeAttrs config [ "_module" ];
|
diskoImagesScript = diskoLib.makeDiskImagesScript {
|
||||||
testMode = "direct";
|
nixosConfig = args;
|
||||||
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
|
# we need to specify the keys here, so we don't get an infinite recursion error
|
||||||
|
|||||||
Reference in new issue
Block a user