apparently a mkIf can't contain a nonexistent option even if it's never gonna be evaluated?
38 lines
990 B
Nix
38 lines
990 B
Nix
{ pkgs, config, lib, options, ... }:
|
|
let
|
|
|
|
configForSystem = (system:
|
|
let
|
|
riscv = [ "riscv32-linux" "riscv64-linux" ];
|
|
arm = [ "armv6l-linux" "armv7l-linux" "aarch64-linux" ];
|
|
x86 = [ "i686-linux" "x86_64-linux" ];
|
|
windows = [ "x86_64-windows" "i686-windows" ];
|
|
systems = {
|
|
x86_64-linux = riscv ++ arm;
|
|
aarch64-linux = riscv;
|
|
};
|
|
in
|
|
if (systems ? "${system}") then systems."${system}" else []
|
|
);
|
|
emulatedSystems = configForSystem "${pkgs.system}";
|
|
cfg = config.nixfiles.binfmt;
|
|
in
|
|
{
|
|
options.nixfiles.binfmt = {
|
|
enable = lib.mkOption {
|
|
description = "Whether to configure default binfmt emulated systems for the current architecture";
|
|
type = lib.types.bool;
|
|
default = false;
|
|
example = true;
|
|
};
|
|
};
|
|
|
|
config = let
|
|
enable = cfg.enable && (builtins.length emulatedSystems) > 0;
|
|
in lib.mkMerge [
|
|
(lib.mkIf enable {
|
|
boot.binfmt = {inherit emulatedSystems;};
|
|
})
|
|
];
|
|
}
|