!djTaTBQyWEPRQxrPTb:nixos.org

Nixpkgs Architecture Team

229 Members
https://github.com/nixpkgs-architecture, weekly public meetings on Wednesday 15:00-16:00 UTC at https://meet.jit.si/nixpkgs-architecture53 Servers

Load older messages


SenderMessageTime
10 Jul 2023
@k900:conduit.0upti.meK900 (deprecated)So I'd rather just do that14:44:20
@adis:blad.isadisbladis
In reply to @k900:conduit.0upti.me
That's getting dangerously close to packages-as-modules already tbh
Modules in what sense?
14:44:53
@k900:conduit.0upti.meK900 (deprecated)Similar to how the current module system for NixOS options works14:45:14
@k900:conduit.0upti.meK900 (deprecated)But on a per-package basis14:45:22
@piegames:matrix.org@piegames:matrix.orgAlso, that's a lot of magic code and boilerplate, even for Nix' standards14:45:41
@adis:blad.isadisbladis
In reply to @piegames:matrix.org
Also, that's a lot of magic code and boilerplate, even for Nix' standards
I'm showcasing an idea, it's possible to make it less code.
14:46:12
@k900:conduit.0upti.meK900 (deprecated)Ot14:46:21
@k900:conduit.0upti.meK900 (deprecated) * It's a thing that has been discussed a lot14:46:33
@k900:conduit.0upti.meK900 (deprecated)And probably the next big change after RFC140 lands14:46:40
@k900:conduit.0upti.meK900 (deprecated)See https://github.com/nixpkgs-architecture/pkgs-modules14:46:59
@infinisil:matrix.orginfinisil
In reply to @piegames:matrix.org
infinisil: I'd like to see the first RFC 140 implementation PR ready for being merged soon, if possible
Yup that's high on my priority list right now
15:04:38
@profpatsch:augsburg.oneprofpatschk900: you can’t have packages as modules, it would kill performance even more16:15:15
@profpatsch:augsburg.oneprofpatschat least you cannot use the nixos module sysetm16:15:29
@infinisil:matrix.orginfinisilhttps://github.com/NixOS/rfcs/pull/146 needs shepherds17:20:30
@infinisil:matrix.orginfinisilAnd that's in scope for the team, relates closely to RFC 14017:20:50
11 Jul 2023
@roberthensing:matrix.orgRobert Hensing (roberth)
In reply to @profpatsch:augsburg.one
k900: you can’t have packages as modules, it would kill performance even more
I think that's the key question the wg is trying to answer
09:20:12
@roberthensing:matrix.orgRobert Hensing (roberth)
In reply to @adis:blad.is

Have anyone else thought of restructuring how we use stdenv.mkDerivation like this before?

let
  # Boilerplate import, not interesting.
  pkgs = import <nixpkgs> { };
  inherit (pkgs) stdenv lib;
  src = pkgs.hello.src;  # Just some random sources to showcase the idea

  # An example of how to possibly structure derivations such as they can be fully overrideable through overrideAttrs
  example = stdenv.mkDerivation (finalAttrs: {
    # Arguments are no longer arguments to to the function that returns the derivation
    # they are instead in passthru so they compose.
    #
    # You could also add a type system on top of this (yants/NixOS module system types)
    # so derivation arguments are introspectable in a standardised way.
    passthru.args = {
      pname = "example";
      version = "0.1.0";
      withCrypto = false;
    };

    # Inputs might be overridable in the same way.
    passthru.inputs = {
      inherit src;
      inherit (pkgs) openssl;
    };

    # This is a bit awkward for now..
    inherit (finalAttrs.passthru.args) pname version;
    inherit (finalAttrs.passthru.inputs) src;
    buildInputs = lib.optional finalAttrs.passthru.args.withCrypto finalAttrs.passthru.inputs.openssl;
  });

in

example.overrideAttrs (oldAttrs: {
  passthru = oldAttrs.passthru // {
    args = oldAttrs.passthru.args // {
      withCrypto = true;
    };
  };
})

This strikes me as a more concise way and would leave us with one blessed way to override regardless of context.
It would also be more introspectable than function args which are currently mixed between build configuration and build inputs.

I haven't thought too much about this yet and it might be a bad idea.

That's more or less the direction I was thinking of when adding the self / finalAttrs argument to the mkDerivation args. At some point I tried to add mkPackage, which would be an overlay-based attrset whose "root" attributes were not exposed in the mkPackage return value. It would allow your example to be expressed without having passthru everywhere, and it would also allow the package to define how the derivation is exposed in the package attrset, which is important for RFC 92 dynamic derivations.
09:25:55
@roberthensing:matrix.orgRobert Hensing (roberth)It would have solved a couple of warts, except for the lack of automatic merging. That could be a good thing or a bad thing, but this uncertainty is one of the reasons I didn't pursue it further09:27:42
@roberthensing:matrix.orgRobert Hensing (roberth)Another was the pushback I got because people didn't understand where this was going09:28:11
@roberthensing:matrix.orgRobert Hensing (roberth)Maybe pushback isn't the right word. I could have made a better attempt at convincing them, but tbh that would have been a week long project that I couldn't spend09:30:54
@nbp:mozilla.orgnbp

adisbladis: I had not thought of using the final as the source for the input, but S.O.S. is kind of layed out this way. With the same disadvantage that the update operator is becoming overwhelmingly present. I think this is part of the solution, except that as mkDerivation is still present. Thus you still need overrideAttrs to modify its argument.

To which the solution is simply to let people override whatever they want before applying mkDerivation at the very last moment.

09:38:13
@nbp:mozilla.orgnbp The idea of S.O.S. is that derivations are available only through final / self, and prev / super provides the recipes. 09:38:54
@nbp:mozilla.orgnbp You want to override anything, use prev. You want to use a program, then use final.
I warned people that I would be happy to break their code if they do not follow the rule.
09:40:15
@piegames:matrix.org@piegames:matrix.org Speaking of mkPackage, a lot of the problems that package modules attempt to solve are actually mkDerivation problems, and I'd like to see them solved first separately 09:56:35
@piegames:matrix.org@piegames:matrix.org Passing random shit as attribute set down through a chain of function calls should be an anti pattern. builtins.removeAttrs should not exist 09:57:32
@k900:conduit.0upti.meK900 (deprecated)removeAttrs is useful in other contexts10:00:19
@k900:conduit.0upti.meK900 (deprecated)But I agree with the core of the argument10:00:29
@piegames:matrix.org@piegames:matrix.org
In reply to @k900:conduit.0upti.me
removeAttrs is useful in other contexts
Agreed
10:05:34
@profpatsch:augsburg.oneprofpatschroberthensing: I don’t think it’s any question10:32:28
@profpatsch:augsburg.oneprofpatschnixos as-is is way to slow already10:32:35

Show newer messages


Back to Room ListRoom Version: 9