Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

bochs: configure it via module system #342188

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

AndersonTorres
Copy link
Member

Description of changes

Playing a little bit with the module system proposed by @Atemu at #312432.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@ofborg ofborg bot added 11.by: package-maintainer This PR was created by the maintainer of the package it changes 10.rebuild-darwin: 1-10 10.rebuild-darwin: 1 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Sep 16, 2024
{
options = {
interfaces = lib.mkOption {
default = [ "SDL2" "term" "wx" "x11" ];
Copy link
Member

@Atemu Atemu Sep 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Lists compose quite poorly. A better design could be to make these a bunch of individual options or a freeform attrset such that you can set them like this:

{
  sdl2 = true;
  term = true;
  wx = true;
  x11 = true;
  somethinElse = false;
}

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a bunch of individual options

Like the previous commit?
0e3afc4

a freeform attrset

Like this?

options = {
  interfaces = lib.mkOption {
    default = {
      sdl =  true;
      term =  true;
      # . . .
    };
  };
};

Copy link
Member

@Atemu Atemu Sep 16, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Like the previous commit?
0e3afc4

Yes, like that.

Like this?

options = {
  interfaces = lib.mkOption {
    default = {
      sdl =  true;
      term =  true;
      # . . .
    };
  };
};

Not quite. This issues because setting the option overrides the entire default attrset, leaving only the overridden values.

What I meant is an RFC42 settings-like option.

This lends itself to scenarios where there are a bunch of settings where it's unreasonable effort to have individual options for each or where you only want to specify a subset of all settings the program can understand.

For packages, I think that's a rather rare requirement though and I don't think it's necessary here.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like to use Bochs expression as a "test+documentation" example.
I wanna try that settings-like approach just for the docs.

@Atemu
Copy link
Member

Atemu commented Sep 16, 2024

When you have individual options, you could also experiment with having the buildInputs deps declared with each option like I did with ffmpeg.

@AndersonTorres AndersonTorres force-pushed the upload-bochs branch 2 times, most recently from 39a424f to 58261fd Compare September 25, 2024 20:49
@ofborg ofborg bot added 10.rebuild-linux: 1-10 10.rebuild-linux: 1 and removed 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux labels Sep 26, 2024
@AndersonTorres AndersonTorres force-pushed the upload-bochs branch 2 times, most recently from 1f0bb75 to 80f290e Compare September 29, 2024 12:26
@Atemu
Copy link
Member

Atemu commented Oct 9, 2024

Re: availableOn

You can take this one step further if you have the deps declared with the option and automatically apply it to all packages and decide the default on that.

I had considered doing something like this for ffmpeg too but IIRC it was too costly in eval time for questionable benefit.

I had even gone one step further and tryEval'd the toString of the drv in order to catch any sort of eval failure, including transitive ones.

@Atemu
Copy link
Member

Atemu commented Oct 9, 2024

Atemu@9a0d986

@ofborg ofborg bot added 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux and removed 10.rebuild-linux: 1 10.rebuild-linux: 1-10 labels Oct 9, 2024
@AndersonTorres
Copy link
Member Author

I am thinking on how to "extend" this correctly.

Usually, SDL packages need to be put in both buildInputs and nativeBuildInputs, especially with strictDeps set as true.

This way, a config.sdl = true; should come with something filling both *lists at the same time.

However

  • I don't know if splicing will break (no one does)
  • I am unable to remember if buildInputs receive either pkgs.sdl or buildPackages.sdl...

@Atemu
Copy link
Member

Atemu commented Oct 10, 2024

SDL packages need to be put in both buildInputs and nativeBuildInputs, especially with strictDeps set as true.

Would be interesting to know why that is; which executable of SDL gets executed here.

This edge-case can be handled by bespoke logic though while everything else still gets handled generically.

I don't know if splicing will break (no one does)

I don't see how this would break splicing? The pkgs in packages are still spliced; nothing un-spliced them.

I am unable to remember if buildInputs receive either pkgs.sdl or buildPackages.sdl...

buildInputs are depsHostTarget but we don't call them that for historical reasons.

buildPackages are pkgsBuildHost but we don't call them that for ??? reasons.

Therefore, buildPackages don't go into buildInputs. (pkgs == pkgsHostTarget)

@AndersonTorres
Copy link
Member Author

Would be interesting to know why that is; which executable of SDL gets executed here.

My guess:

SDL has a sdl-config, its own pkg-config-like utility. This utility goes into its own bin output.
Because of this, packages linking to SDL usually needs SDL in buildInputs (libraries) and nativeBuildInputs too (the config utility).
Otherwise, errors like sdl-config not found happen.

On the other hand, Bochs uses pkg-config directly, so no problem here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
10.rebuild-darwin: 1-10 10.rebuild-darwin: 1 10.rebuild-linux: 0 This PR does not cause any packages to rebuild on Linux 11.by: package-maintainer This PR was created by the maintainer of the package it changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants