disko: add option to format without luks
This commit is contained in:
parent
ad86d6d59b
commit
6477422f89
|
@ -2,14 +2,27 @@
|
||||||
, name ? "chaos"
|
, name ? "chaos"
|
||||||
, disk ? "/dev/sda1"
|
, disk ? "/dev/sda1"
|
||||||
, enableCeph ? true
|
, enableCeph ? true
|
||||||
, enableZfs ? false
|
, enableLuks ? true
|
||||||
|
, enableZfs ? true
|
||||||
, ...
|
, ...
|
||||||
}:
|
}:
|
||||||
|
|
||||||
assert lib.assertMsg (enableCeph || enableZfs) "Must enable ceph or zfs!";
|
assert lib.assertMsg (enableCeph || enableZfs) "Must enable ceph or zfs!";
|
||||||
|
assert lib.assertMsg (enableCeph -> enableLuks) "Ceph requires Luks!";
|
||||||
|
|
||||||
{
|
{
|
||||||
disko.devices = {
|
disko.devices =
|
||||||
|
let
|
||||||
|
rootSize = 200;
|
||||||
|
zfs = {
|
||||||
|
size = if (!enableCeph) then "100%FREE" else "${toString rootSize}GiB";
|
||||||
|
content = {
|
||||||
|
pool = name;
|
||||||
|
type = "zfs";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
in
|
||||||
|
{
|
||||||
disk.${disk} = {
|
disk.${disk} = {
|
||||||
device = disk;
|
device = disk;
|
||||||
type = "disk";
|
type = "disk";
|
||||||
|
@ -27,14 +40,14 @@ assert lib.assertMsg (enableCeph || enableZfs) "Must enable ceph or zfs!";
|
||||||
format = "vfat";
|
format = "vfat";
|
||||||
mountpoint = "/boot";
|
mountpoint = "/boot";
|
||||||
};
|
};
|
||||||
}
|
} ++ [
|
||||||
++ [
|
|
||||||
{
|
{
|
||||||
name = "root";
|
name = "root";
|
||||||
start = if enableZfs then "512MiB" else "1MiB";
|
start = if enableZfs then "512MiB" else "1MiB";
|
||||||
end = "100%";
|
end = "100%";
|
||||||
part-type = "primary";
|
part-type = "primary";
|
||||||
content = {
|
content = lib.optionalAttrs enableLuks
|
||||||
|
{
|
||||||
type = "luks";
|
type = "luks";
|
||||||
name = "crypt-${name}";
|
name = "crypt-${name}";
|
||||||
# TODO: add password, otherwise prompt opens
|
# TODO: add password, otherwise prompt opens
|
||||||
|
@ -43,19 +56,15 @@ assert lib.assertMsg (enableCeph || enableZfs) "Must enable ceph or zfs!";
|
||||||
type = "lvm_pv";
|
type = "lvm_pv";
|
||||||
vg = "lvm-${name}";
|
vg = "lvm-${name}";
|
||||||
};
|
};
|
||||||
};
|
} // lib.optionalAttrs (!enableLuks) zfs.content;
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
} // lib.optionalAttrs enableLuks {
|
||||||
lvm_vg."lvm-${name}" = {
|
lvm_vg."lvm-${name}" = {
|
||||||
type = "lvm_vg";
|
type = "lvm_vg";
|
||||||
lvs =
|
lvs = lib.optionalAttrs enableCeph
|
||||||
let
|
|
||||||
rootSize = 200;
|
|
||||||
in
|
|
||||||
lib.optionalAttrs enableCeph
|
|
||||||
{
|
{
|
||||||
# the header is 3650 byte long and substract an additional 446 byte for aligment
|
# the header is 3650 byte long and substract an additional 446 byte for aligment
|
||||||
# error messages:
|
# error messages:
|
||||||
|
@ -71,17 +80,9 @@ assert lib.assertMsg (enableCeph || enableZfs) "Must enable ceph or zfs!";
|
||||||
bootOther = "-512-20";
|
bootOther = "-512-20";
|
||||||
in
|
in
|
||||||
"$((($(lsblk /dev/sda --noheadings --nodeps --output SIZE --bytes)-${toString rootSizeMiB})${roundToMiB}${bootOther}))MiB";
|
"$((($(lsblk /dev/sda --noheadings --nodeps --output SIZE --bytes)-${toString rootSizeMiB})${roundToMiB}${bootOther}))MiB";
|
||||||
} // lib.optionalAttrs enableZfs {
|
} // lib.optionalAttrs enableZfs { inherit zfs; };
|
||||||
zfs = {
|
|
||||||
size = if (!enableCeph) then "100%FREE" else "${toString rootSize}GiB";
|
|
||||||
content = {
|
|
||||||
pool = name;
|
|
||||||
type = "zfs";
|
|
||||||
};
|
};
|
||||||
};
|
} // {
|
||||||
};
|
|
||||||
};
|
|
||||||
|
|
||||||
zpool."${name}" = {
|
zpool."${name}" = {
|
||||||
type = "zpool";
|
type = "zpool";
|
||||||
mountRoot = "/mnt";
|
mountRoot = "/mnt";
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
ceph=true zfs=true
|
ceph=true luks=true zfs=true
|
||||||
|
|
||||||
while [[ $# -gt 0 ]]; do
|
while [[ $# -gt 0 ]]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
|
@ -18,6 +18,7 @@ while [[ $# -gt 0 ]]; do
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
"--no-ceph") ceph=false;;
|
"--no-ceph") ceph=false;;
|
||||||
|
"--no-luks") luks=false;;
|
||||||
"--no-zfs") zfs=false ;;
|
"--no-zfs") zfs=false ;;
|
||||||
*)
|
*)
|
||||||
echo "Argument $1 is not understood."
|
echo "Argument $1 is not understood."
|
||||||
|
@ -32,8 +33,7 @@ if [[ -z ${disk:-} || -z ${name:-} ]]; then
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
|
||||||
# TODO: wait for https://github.com/nix-community/disko/pull/211 to be merged
|
# TODO: wait for https://github.com/nix-community/disko/pull/211 to be merged
|
||||||
sudo nix run github:SuperSandro2000/disko/zpool-R -- --mode zap_create ./disko-config.nix --debug \
|
sudo nix run github:SuperSandro2000/disko/zpool-R -- --mode zap_create_mount ./disko-config.nix --debug \
|
||||||
--arg disk '"'"$disk"'"' --arg name '"'"$name"'"' \
|
--arg disk '"'"$disk"'"' --arg name '"'"$name"'"' \
|
||||||
--arg enableCeph "$ceph" --arg enableZfs "$zfs"
|
--arg enableCeph "$ceph" --arg enableLuks "$luks" --arg enableZfs "$zfs"
|
||||||
|
|
Loading…
Reference in New Issue
Block a user