summaryrefslogtreecommitdiffstats
path: root/types.nix
diff options
context:
space:
mode:
authorLassulus <github@lassul.us>2022-11-15 20:27:44 +0100
committerGitHub <noreply@github.com>2022-11-15 20:27:44 +0100
commitc60f20ceffd9cd662aad8482dd1bdeed472d75c2 (patch)
tree2288702b7b12a533f4733fa82ef2f5fbe28c565d /types.nix
parentf22e2fa83464131a7a5f2efe9766befb3c8a9ddf (diff)
parenta3bef46beb9c497582ae44efb06671c9df6c74c0 (diff)
Merge pull request #56 from nix-community/cleanup
Diffstat (limited to 'types.nix')
-rw-r--r--types.nix23
1 files changed, 8 insertions, 15 deletions
diff --git a/types.nix b/types.nix
index 228052f..fe04e9c 100644
--- a/types.nix
+++ b/types.nix
@@ -51,21 +51,14 @@ rec {
=> "/dev/disk/by-id/xxx-part2"
*/
deviceNumbering = dev: index:
- let
- schemas = {
- dev__da = dev + toString index; # /dev/{s,v}da style
- dev_disk = "${dev}-part${toString index}"; # /dev/disk/by-id/xxx style
- dev_nvme = "${dev}p${toString index}"; # /dev/nvme0n1p1 style
- dev_md = "${dev}p${toString index}"; # /dev/nvme0n1p1 style
- };
- detectSchema =
- 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};
+ if match "/dev/[vs]d.+" dev != null then
+ dev + toString index # /dev/{s,v}da style
+ else if match "/dev/disk/.+" dev != null then
+ "${dev}-part${toString index}" # /dev/disk/by-id/xxx style
+ else if match "/dev/(nvme|md/|mmcblk).+" dev != null then
+ "${dev}p${toString index}" # /dev/nvme0n1p1 style
+ else
+ abort "${dev} seems not to be a supported disk format";
/* A nix option type representing a json datastructure, vendored from nixpkgs to avoid dependency on pkgs */
jsonType = let