| 10 Jul 2023 |
K900 (deprecated) | Similar to how the current module system for NixOS options works | 14:45:14 |
K900 (deprecated) | But on a per-package basis | 14:45:22 |
@piegames:matrix.org | Also, that's a lot of magic code and boilerplate, even for Nix' standards | 14:45:41 |
@adis:blad.is | 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 (deprecated) | Ot | 14:46:21 |
K900 (deprecated) | * It's a thing that has been discussed a lot | 14:46:33 |
K900 (deprecated) | And probably the next big change after RFC140 lands | 14:46:40 |
K900 (deprecated) | See https://github.com/nixpkgs-architecture/pkgs-modules | 14:46:59 |
infinisil | 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.one | k900: you can’t have packages as modules, it would kill performance even more | 16:15:15 |
@profpatsch:augsburg.one | at least you cannot use the nixos module sysetm | 16:15:29 |
infinisil | https://github.com/NixOS/rfcs/pull/146 needs shepherds | 17:20:30 |
infinisil | And that's in scope for the team, relates closely to RFC 140 | 17:20:50 |
| 11 Jul 2023 |
Robert 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 |
Robert 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 |
Robert 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 further | 09:27:42 |
Robert Hensing (roberth) | Another was the pushback I got because people didn't understand where this was going | 09:28:11 |
Robert 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 spend | 09:30:54 |
nbp | 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 | 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 | 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 | 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 | 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 (deprecated) | removeAttrs is useful in other contexts | 10:00:19 |
K900 (deprecated) | But I agree with the core of the argument | 10:00:29 |
@piegames:matrix.org | In reply to @k900:conduit.0upti.me removeAttrs is useful in other contexts Agreed | 10:05:34 |
@profpatsch:augsburg.one | roberthensing: I don’t think it’s any question | 10:32:28 |
@profpatsch:augsburg.one | nixos as-is is way to slow already | 10:32:35 |
@profpatsch:augsburg.one | and that’s only a couple hundred modules | 10:32:45 |
@piegames:matrix.org | Wait, would be the goal to have one shared global module system for packages? o.O | 10:38:44 |