mirror of
https://github.com/nix-community/disko.git
synced 2024-11-04 05:44:29 +03:00
simplify deviceNumbering function
This commit is contained in:
parent
f22e2fa834
commit
5cbe8fbb48
23
types.nix
23
types.nix
@ -51,21 +51,14 @@ rec {
|
|||||||
=> "/dev/disk/by-id/xxx-part2"
|
=> "/dev/disk/by-id/xxx-part2"
|
||||||
*/
|
*/
|
||||||
deviceNumbering = dev: index:
|
deviceNumbering = dev: index:
|
||||||
let
|
if match "/dev/[vs]d.*" dev != null then
|
||||||
schemas = {
|
dev + toString index # /dev/{s,v}da style
|
||||||
dev__da = dev + toString index; # /dev/{s,v}da style
|
else if match "/dev/disk/.*" dev != null then
|
||||||
dev_disk = "${dev}-part${toString index}"; # /dev/disk/by-id/xxx style
|
"${dev}-part${toString index}" # /dev/disk/by-id/xxx style
|
||||||
dev_nvme = "${dev}p${toString index}"; # /dev/nvme0n1p1 style
|
else if match "/dev/(nvme|md/|mmcblk).*" dev != null then
|
||||||
dev_md = "${dev}p${toString index}"; # /dev/nvme0n1p1 style
|
"${dev}p${toString index}" # /dev/nvme0n1p1 style
|
||||||
};
|
else
|
||||||
detectSchema =
|
abort "${dev} seems not to be a supported disk format";
|
||||||
if match "/dev/[vs]d.*" dev != null then "dev__da" else
|
|
||||||
if match "/dev/disk/.*" dev != null then "dev_disk" else
|
|
||||||
if match "/dev/nvme.*" dev != null then "dev_nvme" else
|
|
||||||
if match "/dev/md/.*" dev != null then "dev_md" else
|
|
||||||
if match "/dev/mmcblk.*" dev != null then "dev_nvme" else
|
|
||||||
abort "${dev} seems not to be a supported disk format";
|
|
||||||
in schemas.${detectSchema};
|
|
||||||
|
|
||||||
/* A nix option type representing a json datastructure, vendored from nixpkgs to avoid dependency on pkgs */
|
/* A nix option type representing a json datastructure, vendored from nixpkgs to avoid dependency on pkgs */
|
||||||
jsonType = let
|
jsonType = let
|
||||||
|
Loading…
Reference in New Issue
Block a user