diff options
author | Jörg Thalheim <joerg@thalheim.io> | 2022-08-23 16:22:36 +0200 |
---|---|---|
committer | Jörg Thalheim <joerg@thalheim.io> | 2022-08-23 20:37:00 +0200 |
commit | e9d1f151a2582d5a3084311414eceb768edcbd2d (patch) | |
tree | 81ea45c8a1e100d5d4ac3492b881d60b6d29c2c5 /lib | |
parent | af2946358849ac01ee3a40b79f74c3cc989d6640 (diff) |
use nix at eval time rather grep at runtime
Diffstat (limited to 'lib')
-rw-r--r-- | lib/default.nix | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/lib/default.nix b/lib/default.nix index 62aed38..9f62428 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -11,11 +11,11 @@ let { helper.find-device = device: let environment = helper.device-id device; - in '' - if echo '${device}' | grep -q '^/dev/disk'; then - # DEVICE points already to /dev/disk, so we don't handle it via /dev/disk/by-path - ${environment}='${device}' - else + in + # DEVICE points already to /dev/disk, so we don't handle it via /dev/disk/by-path + if hasPrefix "/dev/disk" device then + "${environment}='${device}'" + else '' ${environment}=$(for x in /dev/disk/by-path/*; do dev=$x if [ "$(readlink -f $x)" = '${device}' ]; then @@ -29,8 +29,7 @@ let { else echo $target fi) - fi - ''; + ''; helper.device-id = device: "DEVICE${builtins.substring 0 5 (builtins.hashString "sha1" device)}"; |