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

Naming convention for optional feature flags #148730

Open
KAction opened this issue Dec 5, 2021 · 9 comments
Open

Naming convention for optional feature flags #148730

KAction opened this issue Dec 5, 2021 · 9 comments

Comments

@KAction
Copy link
Contributor

KAction commented Dec 5, 2021

Generally, Nixpkgs exports flexibility of upstream build system with boolean
flags to corresponding Nix expression, so, for example, Nix expression for
doas(8) starts with following:

{ lib, stdenv, fetchFromGitHub, bison, pam
, withPAM ? true, withTimestamp ? true }:

There are least two ways to represent the fact that particular input is
optional:

  1. Add boolean flag like withPAM in example above, and use include dependency
    with something like buildInputs = lib.optional withPAM pam;
  2. Write code to handle input beeing null instead of derivation, with code like
    configureFlags = lib.enableFeature (pam != null) "pam".

In cases when upstream build system provides option to enable or disable
functionality that is not tied to external dependency, only boolean flags
approach is possibly; probably this is why it is more popular.

Furthermore, we don't have convention for naming of this flags. Across the
tree, we have "withPAM", "withPAMSupport", "enablePAM" and "usePAM". The same
mess happens for every other flag. You can get idea with something as simple as

$ git grep -i PAM | grep -iE 'with|support|enable|disable'

Substitute PAM with systemd, nls, ssl or alsa.

This inconsistency, among other things, makes writing overlays harder. On
Gentoo, if you wan't whole system without, e.g NLS, you just set global USE
flag and rebuild the world.

On Nix, you can do the same -- you create overlay, but you need to setup 3 or 4
flags, each of them controlling some irregular subset of all packages. This is
not nice user interface, even (especially?) when user is a developer. I
propose that we make things uniform.

Currently, "supportFoo" seems to be the most common convention, used both for
external dependencies and optional internal features, so the simplest solution
would be to convert all enable/with/disable to this convention. Regular
expression can do it with reasonable accuracy.

Alternatively, and what I would prefer instead, is to follow autoconf
convention: --with for external dependencies, --enable for internal. It
involves more work, more changes, and, unlike previous approach, can't be done
tree-wide.

No matter which of these paths we agree on, I am willing to provide patches for
Nix expressions, nixpkgs manual and probably to nixpkgs-hammering.

@stale stale bot added the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jun 19, 2022
@fricklerhandwerk
Copy link
Contributor

@infinisil Something for the nixpkgs architecture team?

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/2024-01-09-nixpkgs-architecture-team-meeting-47/38037/1

@stale stale bot removed the 2.status: stale https://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md label Jan 9, 2024
@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/pre-rfc-standardization-of-feature-parameters/38104/1

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/pre-rfc-standardization-of-feature-parameters/38104/47

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/pre-rfc-standardization-of-feature-parameters/38104/59

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/pre-rfc-standardization-of-feature-parameters/38104/69

@infinisil
Copy link
Member

This is now a proper RFC: NixOS/rfcs#169

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/need-for-coorinated-enforced-boolean-switch-arguments-in-nixpkgs/48948/4

@nixos-discourse
Copy link

This issue has been mentioned on NixOS Discourse. There might be relevant details there:

https://discourse.nixos.org/t/best-practices-for-config-flags-to-packages/4064/8

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants