mirror of
https://github.com/nix-community/disko.git
synced 2024-09-11 06:25:33 +03:00
add zapCreateMount script for idempodents install from iso/kexec
This commit is contained in:
parent
417ad31ca5
commit
9cf4f170ae
2
cli.nix
2
cli.nix
@ -16,6 +16,8 @@ let
|
||||
disko.createScript diskFormat pkgs
|
||||
else if (mode == "mount") then
|
||||
disko.mountScript diskFormat pkgs
|
||||
else if (mode = "zap_create_mount") then
|
||||
disko.zapCreateMount diskFormat pkgs
|
||||
else
|
||||
builtins.abort "invalid mode"
|
||||
;
|
||||
|
@ -24,6 +24,10 @@ in {
|
||||
export PATH=${lib.makeBinPath (types.diskoLib.packages (eval cfg).config.devices pkgs)}
|
||||
${types.diskoLib.mount (eval cfg).config.devices}
|
||||
'';
|
||||
zapCreateMount = cfg: pkgs: pkgs.writeScript "disko-zap-create-mount" ''
|
||||
export PATH=${lib.makeBinPath (types.diskoLib.packages (eval cfg).config.devices pkgs)}
|
||||
${types.diskoLib.zapCreateMount (eval cfg).config.devices}
|
||||
'';
|
||||
config = cfg: { imports = types.diskoLib.config (eval cfg).config.devices; };
|
||||
packages = cfg: types.diskoLib.packages (eval cfg).config.devices;
|
||||
}
|
||||
|
4
disko
4
disko
@ -87,8 +87,8 @@ while [[ $# -gt 0 ]]; do
|
||||
shift
|
||||
done
|
||||
|
||||
if ! ([[ $mode = "create" ]] || [[ $mode = "mount" ]]); then
|
||||
abort "mode must be either create or mount"
|
||||
if ! ([[ $mode = "create" ]] || [[ $mode = "mount" ]] || [[ $mode = "zap_create_mount" ]]); then
|
||||
abort "mode must be either create, mount or zap_create_mount"
|
||||
fi
|
||||
|
||||
if [[ ! -z "${flake+x}" ]]; then
|
||||
|
20
types.nix
20
types.nix
@ -146,6 +146,26 @@ rec {
|
||||
# ensures that "/" is processed before "/foo" etc.
|
||||
${concatStrings (attrValues fsMounts)}
|
||||
'';
|
||||
/* takes a disko device specification and returns a string which unmounts, destroys all disks and then runs create and mount
|
||||
|
||||
zapCreateMount :: types.devices -> str
|
||||
*/
|
||||
zapCreateMount = devices: ''
|
||||
set -efux
|
||||
# print existing disks
|
||||
lsblk
|
||||
|
||||
# TODO get zap the same way we get create
|
||||
# make partitioning idempotent by dismounting already mounted filesystems
|
||||
if findmnt /mnt; then
|
||||
umount -Rlv /mnt
|
||||
fi
|
||||
|
||||
echo 'creating partitions...'
|
||||
${diskoLib.create devices}
|
||||
echo 'mounting partitions...'
|
||||
${diskoLib.mount devices}
|
||||
'';
|
||||
/* Takes a disko device specification and returns a nixos configuration
|
||||
|
||||
config :: types.devices -> nixosConfig
|
||||
|
Loading…
Reference in New Issue
Block a user