Skip to content

Standard gentoo-like "use" flags across nixpkgs #12877

@copumpkin

Description

@copumpkin

Before telling me nix already supports this, hear me out 😄

Take a "headless" Nix (NixOS or otherwise) system. A whole load of packages have slightly different options to disable GUI components, but none of them are standardized, and thus we can end up with a completely headless server bundling a ton of graphics stuff because it depends for example on pinentry which optionally supports a GUI prompt and thus pulls in a ton of graphical crap.

What if we instituted a set of standard flags that would be available through stdenv that would help us determine those options? For example:

{ stdenv, fetchurl, mesa, gnome }:

stdenv.mkDerivation {
  buildInputs = stdenv.lib.optional (!stdenv.flags.headless) [ mesa gnome ];
}

And then our closures get small again. Individual packages could still keep ad-hoc flags in their parameter set, but this would help us standardize on a set of common flags of this sort.

Off the top of my head, I'd start with these common flags:

  • headless: disable any GUI components
  • hardened: use any additional package-specific hardening measures available (the stdenv would also apply some default hardening steps, but certain packages might need additional knowledge of this) [this is already on by default, now]
  • monolingual: get rid of language translations (and default to whatever you specify if not english)

There are probably others, but I think we could get a lot of value out of just these two.

cc:

Metadata

Metadata

Assignees

No one assigned

    Labels

    1.severity: significantNovel ideas, large API changes, notable refactorings, issues with RFC potential, etc.2.status: stalehttps://github.com/NixOS/nixpkgs/blob/master/.github/STALE-BOT.md6.topic: policy discussionDiscuss policies to work in and around Nixpkgs9.needs: community feedbackThis needs feedback from more community members.
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions