l hilum.r: introduce tryFile
This commit is contained in:
parent
34360eb931
commit
d0b3d234e5
@ -6,9 +6,16 @@
|
|||||||
<nixpkgs/nixos/modules/installer/scan/not-detected.nix>
|
<nixpkgs/nixos/modules/installer/scan/not-detected.nix>
|
||||||
{
|
{
|
||||||
# nice hack to carry around state passed impurely at the beginning
|
# 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;
|
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;
|
config.environment.etc.hilum-disk.text = config.mainDisk;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user