disko: add WIP module
This commit is contained in:
parent
9cd9f6edcd
commit
9b70709d50
|
@ -1,5 +1,7 @@
|
|||
{ lib
|
||||
, name ? "chaos"
|
||||
, useConfig ? false
|
||||
, config ? ""
|
||||
, disk ? "/dev/sda1"
|
||||
, enableCeph ? true
|
||||
, enableLuks ? true
|
||||
|
@ -11,7 +13,19 @@ assert lib.assertMsg (enableCeph || enableZfs) "Must enable ceph or zfs!";
|
|||
assert lib.assertMsg (enableCeph -> enableLuks) "Ceph requires Luks!";
|
||||
|
||||
{
|
||||
disko.devices =
|
||||
imports = [
|
||||
../modules/disko.nix
|
||||
] ++ lib.optional useConfig config;
|
||||
|
||||
disko = {
|
||||
# TODO: deprecate?
|
||||
name.default = name;
|
||||
rootDisk.default = disk;
|
||||
enableCeph.default = enableCeph;
|
||||
enableLuks.default = enableLuks;
|
||||
enableZfs.default = enableZfs;
|
||||
|
||||
devices =
|
||||
let
|
||||
rootSize = 200;
|
||||
zfs = {
|
||||
|
@ -37,7 +51,7 @@ assert lib.assertMsg (enableCeph -> enableLuks) "Ceph requires Luks!";
|
|||
bootable = true;
|
||||
content = {
|
||||
type = "filesystem";
|
||||
format = "fat32";
|
||||
format = "vfat";
|
||||
mountpoint = "/boot";
|
||||
};
|
||||
} ++ [
|
||||
|
@ -85,7 +99,7 @@ assert lib.assertMsg (enableCeph -> enableLuks) "Ceph requires Luks!";
|
|||
} // {
|
||||
zpool."${name}" = {
|
||||
type = "zpool";
|
||||
mountpoint = "none";
|
||||
mountpoint = null;
|
||||
mountRoot = "/mnt";
|
||||
rootFsOptions.acltype = "posixacl";
|
||||
options = {
|
||||
|
@ -143,4 +157,5 @@ assert lib.assertMsg (enableCeph -> enableLuks) "Ceph requires Luks!";
|
|||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
@ -1,22 +1,35 @@
|
|||
#!/usr/bin/env bash
|
||||
useConfig=false config="" ceph=true luks=true zfs=true
|
||||
|
||||
ceph=true luks=true zfs=true
|
||||
cd "$(dirname "${BASH_SOURCE[0]}")" >/dev/null || exit 1
|
||||
|
||||
while [[ $# -gt 0 ]]; do
|
||||
case "$1" in
|
||||
"-h" | "--help")
|
||||
echo "Usage:"
|
||||
echo "$0 [-h|--help] --disk /dev/sdx --name chaos [--no-ceph] [--no-luks] [--no-zfs]"
|
||||
echo "$0 [-h|--help] --name chaos [--config [hosts/\$name/default.nix]] [--disk /dev/sdx] [--no-ceph] [--no-luks] [--no-zfs]"
|
||||
echo
|
||||
echo "If only --config is supplied, the script tries to guess the nix file to import from --name."
|
||||
echo "Note: --config is none working"
|
||||
exit 0
|
||||
;;
|
||||
"--disk")
|
||||
disk=$2
|
||||
shift
|
||||
;;
|
||||
"--name")
|
||||
name=$2
|
||||
shift
|
||||
;;
|
||||
"--config")
|
||||
useConfig=true
|
||||
if [[ $2 =~ ^-- ]]; then
|
||||
config=$2
|
||||
shift
|
||||
else
|
||||
config=../hosts/$name/default.nix
|
||||
fi
|
||||
shift
|
||||
;;
|
||||
"--disk")
|
||||
disk=$2
|
||||
;;
|
||||
"--no-ceph") ceph=false;;
|
||||
"--no-luks") luks=false;;
|
||||
"--no-zfs") zfs=false ;;
|
||||
|
@ -28,12 +41,13 @@ while [[ $# -gt 0 ]]; do
|
|||
shift
|
||||
done
|
||||
|
||||
if [[ -z ${disk:-} || -z ${name:-} ]]; then
|
||||
echo "--disk and --name must be supplied!"
|
||||
if [[ -z ${name:-} || (-n ${config:-} && -n ${disk:-}) ]]; then
|
||||
# echo "--name and either config or disk must be supplied!"
|
||||
echo "--name and disk must be supplied!"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 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_mount ./disko-config.nix --debug \
|
||||
--arg disk '"'"$disk"'"' --arg name '"'"$name"'"' \
|
||||
--arg disk '"'"$disk"'"' --arg name '"'"$name"'"' --arg useConfig "$useConfig" --arg config "$config" \
|
||||
--arg enableCeph "$ceph" --arg enableLuks "$luks" --arg enableZfs "$zfs"
|
||||
|
|
|
@ -0,0 +1,37 @@
|
|||
{ lib, ... }:
|
||||
|
||||
# none functional until https://github.com/nix-community/disko/issues/219 is resolved
|
||||
|
||||
{
|
||||
options.disko = {
|
||||
name = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
example = "chaos";
|
||||
description = "Machine name used in eg zpool name.";
|
||||
};
|
||||
|
||||
rootDisk = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
example = "/dev/sda";
|
||||
description = "Path of the root disk.";
|
||||
};
|
||||
|
||||
enableCeph = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
description = "Wether to include a ceph on the root disk.";
|
||||
};
|
||||
|
||||
enableLuks = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
description = "Wether to encrypt the root disk.";
|
||||
};
|
||||
|
||||
enableZfs = lib.mkOption {
|
||||
type = lib.types.bool;
|
||||
default = true;
|
||||
description = "Wether to include a zfs on the root disk.";
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue