mirror of
https://github.com/nix-community/disko
synced 2024-09-20 05:51:54 +00:00
nix fmt
This commit is contained in:
parent
e8e8d9a3a9
commit
6208b31a73
5 changed files with 49 additions and 45 deletions
|
@ -41,9 +41,9 @@ recursive layouts.
|
||||||
|
|
||||||
Disko doesn't require installation: it can be run directly from nix-community
|
Disko doesn't require installation: it can be run directly from nix-community
|
||||||
repository. The [Quickstart Guide](./docs/quickstart.md) documents how to run
|
repository. The [Quickstart Guide](./docs/quickstart.md) documents how to run
|
||||||
Disko in its simplest form when installing NixOS. Alternatively, you can
|
Disko in its simplest form when installing NixOS. Alternatively, you can also
|
||||||
also use the new [disko-install](./docs/disko-install.md) tool, which combines
|
use the new [disko-install](./docs/disko-install.md) tool, which combines the
|
||||||
the `disko` and `nixos-install` into one step.
|
`disko` and `nixos-install` into one step.
|
||||||
|
|
||||||
For information on other use cases, including upgrading from an older version of
|
For information on other use cases, including upgrading from an older version of
|
||||||
**disko**, using **disko** without NixOS and downloading the module, see the
|
**disko**, using **disko** without NixOS and downloading the module, see the
|
||||||
|
|
|
@ -15,7 +15,8 @@ existing partitions. Dual booting with other operating systems is not supported.
|
||||||
|
|
||||||
### Step 1: Choose a Disk Configuration
|
### Step 1: Choose a Disk Configuration
|
||||||
|
|
||||||
Real-world templates are provided in this [repository](https://github.com/nix-community/disko-templates).
|
Real-world templates are provided in this
|
||||||
|
[repository](https://github.com/nix-community/disko-templates).
|
||||||
|
|
||||||
More disk layouts for all filesystems can be also found in the
|
More disk layouts for all filesystems can be also found in the
|
||||||
[example](https://github.com/nix-community/disko/tree/master/example) directory
|
[example](https://github.com/nix-community/disko/tree/master/example) directory
|
||||||
|
|
|
@ -45,14 +45,15 @@ in
|
||||||
};
|
};
|
||||||
priority = lib.mkOption {
|
priority = lib.mkOption {
|
||||||
type = lib.types.int;
|
type = lib.types.int;
|
||||||
default = if partition.config.size or "" == "100%" then
|
default =
|
||||||
9001
|
if partition.config.size or "" == "100%" then
|
||||||
else if partition.config.type == "EF02" then
|
9001
|
||||||
|
else if partition.config.type == "EF02" then
|
||||||
# Boot partition should be created first, because some BIOS implementations require it.
|
# Boot partition should be created first, because some BIOS implementations require it.
|
||||||
# Priority defaults to 100 here to support any potential use-case for placing partitions prior to EF02
|
# Priority defaults to 100 here to support any potential use-case for placing partitions prior to EF02
|
||||||
100
|
100
|
||||||
else
|
else
|
||||||
1000;
|
1000;
|
||||||
defaultText = ''
|
defaultText = ''
|
||||||
1000: normal partitions
|
1000: normal partitions
|
||||||
9001: partitions with 100% size
|
9001: partitions with 100% size
|
||||||
|
|
|
@ -3,7 +3,7 @@ let
|
||||||
# Load kernel modules to ensure device mapper types are available
|
# Load kernel modules to ensure device mapper types are available
|
||||||
kernelModules = lib.filter (x: x != "") (map
|
kernelModules = lib.filter (x: x != "") (map
|
||||||
(lv: lib.optionalString (lv.lvm_type != null && lv.lvm_type != "thinlv") "dm-${lv.lvm_type}")
|
(lv: lib.optionalString (lv.lvm_type != null && lv.lvm_type != "thinlv") "dm-${lv.lvm_type}")
|
||||||
(lib.attrValues config.lvs));
|
(lib.attrValues config.lvs));
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
options = {
|
options = {
|
||||||
|
@ -125,7 +125,7 @@ in
|
||||||
_config = lib.mkOption {
|
_config = lib.mkOption {
|
||||||
internal = true;
|
internal = true;
|
||||||
readOnly = true;
|
readOnly = true;
|
||||||
default = [ { boot.initrd.kernelModules = kernelModules; } ] ++
|
default = [{ boot.initrd.kernelModules = kernelModules; }] ++
|
||||||
map
|
map
|
||||||
(lv: [
|
(lv: [
|
||||||
(lib.optional (lv.content != null) lv.content._config)
|
(lib.optional (lv.content != null) lv.content._config)
|
||||||
|
|
|
@ -59,40 +59,42 @@
|
||||||
# important to prevent accidental shadowing of mount points
|
# important to prevent accidental shadowing of mount points
|
||||||
# since (create order != mount order)
|
# since (create order != mount order)
|
||||||
# -p creates parents automatically
|
# -p creates parents automatically
|
||||||
default = let
|
default =
|
||||||
createOptions = (lib.optionalAttrs (config.mountpoint != null) { mountpoint = config.mountpoint; }) // config.options;
|
let
|
||||||
# All options defined as PROP_ONETIME or PROP_ONETIME_DEFAULT in https://github.com/openzfs/zfs/blob/master/module/zcommon/zfs_prop.c
|
createOptions = (lib.optionalAttrs (config.mountpoint != null) { mountpoint = config.mountpoint; }) // config.options;
|
||||||
onetimeProperties = [
|
# All options defined as PROP_ONETIME or PROP_ONETIME_DEFAULT in https://github.com/openzfs/zfs/blob/master/module/zcommon/zfs_prop.c
|
||||||
"encryption"
|
onetimeProperties = [
|
||||||
"casesensitivity"
|
"encryption"
|
||||||
"utf8only"
|
"casesensitivity"
|
||||||
"normalization"
|
"utf8only"
|
||||||
"volblocksize"
|
"normalization"
|
||||||
"pbkdf2iters"
|
"volblocksize"
|
||||||
"pbkdf2salt"
|
"pbkdf2iters"
|
||||||
"keyformat"
|
"pbkdf2salt"
|
||||||
];
|
"keyformat"
|
||||||
updateOptions = builtins.removeAttrs config.options onetimeProperties;
|
];
|
||||||
mountpoint = config.options.mountpoint or config.mountpoint;
|
updateOptions = builtins.removeAttrs config.options onetimeProperties;
|
||||||
in ''
|
mountpoint = config.options.mountpoint or config.mountpoint;
|
||||||
if ! zfs get type ${config._name} >/dev/null 2>&1; then
|
in
|
||||||
zfs create -up ${config._name} \
|
''
|
||||||
${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "-o ${n}=${v}") (createOptions))}
|
if ! zfs get type ${config._name} >/dev/null 2>&1; then
|
||||||
${lib.optionalString (updateOptions != {}) ''
|
zfs create -up ${config._name} \
|
||||||
else
|
${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "-o ${n}=${v}") (createOptions))}
|
||||||
zfs set ${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "${n}=${v}") updateOptions)} ${config._name}
|
${lib.optionalString (updateOptions != {}) ''
|
||||||
${lib.optionalString (mountpoint != null) ''
|
else
|
||||||
# zfs will try unmount the dataset to change the mountpoint
|
zfs set ${lib.concatStringsSep " " (lib.mapAttrsToList (n: v: "${n}=${v}") updateOptions)} ${config._name}
|
||||||
# but this might fail if the dataset is in use
|
${lib.optionalString (mountpoint != null) ''
|
||||||
if ! zfs set mountpoint=${mountpoint} ${config._name}; then
|
# zfs will try unmount the dataset to change the mountpoint
|
||||||
echo "Failed to set mountpoint to '${mountpoint}' for ${config._name}." >&2
|
# but this might fail if the dataset is in use
|
||||||
echo "You may need to run when the pool is not mounted i.e. in a recovery system:" >&2
|
if ! zfs set mountpoint=${mountpoint} ${config._name}; then
|
||||||
echo " zfs set mountpoint=${mountpoint} ${config._name}" >&2
|
echo "Failed to set mountpoint to '${mountpoint}' for ${config._name}." >&2
|
||||||
fi
|
echo "You may need to run when the pool is not mounted i.e. in a recovery system:" >&2
|
||||||
|
echo " zfs set mountpoint=${mountpoint} ${config._name}" >&2
|
||||||
|
fi
|
||||||
|
''}
|
||||||
''}
|
''}
|
||||||
''}
|
fi
|
||||||
fi
|
'';
|
||||||
'';
|
|
||||||
} // { readOnly = false; };
|
} // { readOnly = false; };
|
||||||
|
|
||||||
_mount = diskoLib.mkMountOption {
|
_mount = diskoLib.mkMountOption {
|
||||||
|
|
Loading…
Reference in a new issue