From 1842dc2d8015223dde4792a4e9ccb70e8a218b26 Mon Sep 17 00:00:00 2001 From: Anderson Torres Date: Wed, 25 Sep 2024 17:49:19 -0300 Subject: [PATCH] bochs: configure via module system Inspired by Atemu --- pkgs/by-name/bo/bochs/options.nix | 40 +++++++++++++++++++++++++++++++ pkgs/by-name/bo/bochs/package.nix | 26 ++++++++++++++++---- 2 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 pkgs/by-name/bo/bochs/options.nix diff --git a/pkgs/by-name/bo/bochs/options.nix b/pkgs/by-name/bo/bochs/options.nix new file mode 100644 index 0000000000000..e0bed56ebf0d7 --- /dev/null +++ b/pkgs/by-name/bo/bochs/options.nix @@ -0,0 +1,40 @@ +{ + lib, + config, + stdenv, + _pkgs, + ... +}: + +{ + options = { + SDL2 = lib.mkOption { + type = lib.types.bool; + default = lib.meta.availableOn stdenv.hostPlatform _pkgs.SDL2; + description = '' + Enable SDL2 interface. + ''; + }; + X11 = lib.mkOption { + type = lib.types.bool; + default = lib.meta.availableOn stdenv.hostPlatform _pkgs.libX11; + description = '' + Enable X11 interface. + ''; + }; + term = lib.mkOption { + type = lib.types.bool; + default = lib.meta.availableOn stdenv.hostPlatform _pkgs.ncurses; + description = '' + Enable ncurses terminal interface. + ''; + }; + wx = lib.mkOption { + type = lib.types.bool; + default = lib.meta.availableOn stdenv.hostPlatform _pkgs.wxGTK32; + description = '' + Enable wxWidgets interface. + ''; + }; + }; +} diff --git a/pkgs/by-name/bo/bochs/package.nix b/pkgs/by-name/bo/bochs/package.nix index 2bb8d36f3edb9..5ddc305799372 100644 --- a/pkgs/by-name/bo/bochs/package.nix +++ b/pkgs/by-name/bo/bochs/package.nix @@ -18,13 +18,29 @@ stdenv, wget, wxGTK32, - # Boolean flags - enableSDL2 ? true, - enableTerm ? true, - enableWx ? !stdenv.hostPlatform.isDarwin, - enableX11 ? !stdenv.hostPlatform.isDarwin, + _configuration ? {}, }: +let + eval = lib.evalModules { + modules = [ + ./options.nix + _configuration + { + _module.args = { + inherit stdenv; + _pkgs = { + inherit SDL2 ncurses wxGTK32 libX11; + }; + }; + } + ]; + }; + enableSDL2 = eval.config.SDL2; + enableTerm = eval.config.term; + enableWx = eval.config.wx; + enableX11 = eval.config.X11; +in stdenv.mkDerivation (finalAttrs: { pname = "bochs"; version = "2.8";