summaryrefslogtreecommitdiffstats
path: root/lass/1systems/hilum/physical.nix
diff options
context:
space:
mode:
authorlassulus <git@lassul.us>2023-01-26 23:47:07 +0100
committerlassulus <git@lassul.us>2023-01-26 23:47:07 +0100
commitd0b3d234e57c3960ee278c5e29feef448f958c4a (patch)
treeac4a44842dc1bbab532aad99efce9a748ac859cb /lass/1systems/hilum/physical.nix
parent34360eb931e89b09512091fe819fb59568852441 (diff)
l hilum.r: introduce tryFile
Diffstat (limited to 'lass/1systems/hilum/physical.nix')
-rw-r--r--lass/1systems/hilum/physical.nix11
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;
}