diff options
author | lassulus <git@lassul.us> | 2023-01-26 23:47:07 +0100 |
---|---|---|
committer | lassulus <git@lassul.us> | 2023-01-26 23:47:07 +0100 |
commit | d0b3d234e57c3960ee278c5e29feef448f958c4a (patch) | |
tree | ac4a44842dc1bbab532aad99efce9a748ac859cb /lass/1systems | |
parent | 34360eb931e89b09512091fe819fb59568852441 (diff) |
l hilum.r: introduce tryFile
Diffstat (limited to 'lass/1systems')
-rw-r--r-- | lass/1systems/hilum/physical.nix | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/lass/1systems/hilum/physical.nix b/lass/1systems/hilum/physical.nix index f97873aa9..6f160062d 100644 --- a/lass/1systems/hilum/physical.nix +++ b/lass/1systems/hilum/physical.nix @@ -6,9 +6,16 @@ <nixpkgs/nixos/modules/installer/scan/not-detected.nix> { # nice hack to carry around state passed impurely at the beginning - options.mainDisk = lib.mkOption { + options.mainDisk = let + tryFile = path: default: + if lib.elem (builtins.baseNameOf path) (lib.attrNames (builtins.readDir (builtins.dirOf path))) then + builtins.readFile path + else + default + ; + in lib.mkOption { type = lib.types.str; - default = builtins.readFile "/etc/hilum-disk"; + default = tryFile "/etc/hilum-disk" "/dev/sdz"; }; config.environment.etc.hilum-disk.text = config.mainDisk; } |