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

Command-line overrides for installables #5766

Open
max-privatevoid opened this issue Dec 12, 2021 · 3 comments
Open

Command-line overrides for installables #5766

max-privatevoid opened this issue Dec 12, 2021 · 3 comments

Comments

@max-privatevoid
Copy link
Contributor

(This should probably be turned into an RFC at some point)

Is your feature request related to a problem? Please describe.

nixpkgs provides the override and overrideAttrs patterns to easily customize preexisting derivations. These have never been particularly usable over the command line, usually requiring patterns like

$ nix build --impure --expr '(import <nixpkgs> {}).package.override { ... }'

With flakes standardizing the concept of installables, maybe we can have a go at this?

Describe the solution you'd like

Similar to nix eval's --expr, there should be a way to apply overrides to derivations supporting them.

Some examples of how this could look like:

$ nix build nixpkgs#package --override-arg withSomething true --override-arg withSomethingElse false

$ nix build nixpkgs#package --override-argstr channel dev

$ nix build nixpkgs/nixos-21.11#package --override-pkg libabstract nixpkgs/nixos-unstable#libabstract-impl

# old is magically pulled into scope
$ nix build nixpkgs#package --overrideattr patches 'old.patches ++ [ ./myfeature.patch ]'

# if we're really stretching it
$ nix build nixpkgs#package --overrideattr-append patches ./myfeature.patch

$ nix build /nix/store/xxxxxxxx-package --override-argstr foo bar
error: argument '...' cannot be evaluated

https://github.com/max-privatevoid/nix/tree/cli-overrides currently implements a rudimentary base for this concept. It allows you to do this:

$ nix build nixpkgs#ffmpeg --apply-to-installable 'x: x.override { libmfxSupport = true; }'

Things to figure out:

  • The override pattern is from nixpkgs and not "official". Should the pattern be specified as part of Nix itself? ([RFC 0067] Common override interface derivations rfcs#67)
  • Can installable in --override-pkg installable be a non-value (e.g. --override-pkg /nix/store/xxxxxxx-newpackage)?
  • Come up with better argument names (maybe reuse --arg, --argstr?)
  • How to apply functions to apps
  • No way to differentiate between configuration arguments (withSomething) and dependency arguments. This is a nixpkgs issue.
  • Nested overrides i.e. equivalent of pkg1.override { dep1 = pkg2.override { dep2 = newPkg3; }; }
  • Use URL parameters instead? (see Support flake references to patches #3920)

Describe alternatives you've considered

Wait for https://gist.github.com/edolstra/29ce9d8ea399b703a7023073b0dbc00d#user-interface

@stale
Copy link

stale bot commented Jun 20, 2022

I marked this as stale due to inactivity. → More info

@stale stale bot added the stale label Jun 20, 2022
@Kranzes
Copy link
Member

Kranzes commented Jun 20, 2022

Why are feature request issues being made stale???

@stale stale bot removed the stale label Jun 20, 2022
@hraban
Copy link
Member

hraban commented Oct 16, 2023

Why are feature request issues being made stale???

Because they've gone without activity for a long time, in other words "stale"? I hate auto-closing bots as much as the next guy, but just labelling someting "stale" when in fact it is stale, without closing the issue, seems only fair to me.

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

No branches or pull requests

4 participants