mirror of
https://github.com/nix-community/disko.git
synced 2026-11-30 21:13: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"
|
||||
fi
|
||||
|
||||
echo "Syncing filesystems" >&2
|
||||
fsync "${mountPoint}"
|
||||
|
||||
echo "Install NixOS" >&2
|
||||
nixos-install --no-channel-copy --no-root-password --system "$nixos_system" --root "$mountPoint"
|
||||
}
|
||||
|
||||
|
||||
Generated
+3
-3
@@ -2,11 +2,11 @@
|
||||
"nodes": {
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1721782431,
|
||||
"narHash": "sha256-UNDpwjYxNXQet/g3mgRLsQ9zxrbm9j2JEvP4ijF3AWs=",
|
||||
"lastModified": 1723221148,
|
||||
"narHash": "sha256-7pjpeQlZUNQ4eeVntytU3jkw9dFK3k1Htgk2iuXjaD8=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "4f02464258baaf54992debfd010a7a3662a25536",
|
||||
"rev": "154bcb95ad51bc257c2ce4043a725de6ca700ef6",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
|
||||
+3
-22
@@ -67,32 +67,13 @@ 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 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}
|
||||
# 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
|
||||
|
||||
${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}
|
||||
|
||||
+8
-13
@@ -98,21 +98,16 @@ in
|
||||
};
|
||||
};
|
||||
};
|
||||
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; } // {
|
||||
config = lib.mkIf (cfg.devices.disk != { }) {
|
||||
system.build = (cfg.devices._scripts { inherit pkgs; checked = cfg.checkScripts; }) // {
|
||||
|
||||
# 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;
|
||||
|
||||
diskoImages = diskoLib.makeDiskImages {
|
||||
nixosConfig = args;
|
||||
};
|
||||
|
||||
diskoImagesScript = diskoLib.makeDiskImagesScript {
|
||||
nixosConfig = args;
|
||||
};
|
||||
@@ -126,7 +121,7 @@ in
|
||||
extraSystemConfig = cfg.tests.extraConfig;
|
||||
extraTestScript = cfg.tests.extraChecks;
|
||||
};
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
# we need to specify the keys here, so we don't get an infinite recursion error
|
||||
|
||||
Reference in new issue
Block a user