!9IQChSjwSHXPPWTa:lix.systems

Lix

807 Members
Lix user channel. Feel free to discuss on-topic issues here and give each other help. For matrix.to links to the rest of the Lix channels, see: https://wiki.lix.systems/books/lix-organisation/page/matrix-rooms233 Servers

Load older messages


SenderMessageTime
16 Feb 2025
@charles:computer.surgeryCharles
makeScopedPackagesFromDirectoryRecursive = newScope: directory:
  nixpkgs.lib.customisation.makeScope newScope (scope:
    nixpkgs.lib.filesystem.packagesFromDirectoryRecursive {
      inherit directory;
      callPackage = fn: args:
        scope.callPackage
          fn
          (args // { sprinkle = self; });
    }
  );

not to interrupt but i have to share this extremely long function name i just wrote

03:41:49
@charles:computer.surgeryCharles(oh darn the attribute set merge thingy does not do what i had hoped it would)03:53:37
@antifuchs:asf.computerantifuchsHm, maybe you need to use withCallPackage or whatever it’s called03:54:14
@charles:computer.surgeryCharles i was gonna go for builtins.functionArgs and doing it manually, but that sounds possibly better 03:54:38
@antifuchs:asf.computerantifuchsnixpkgs.lib.callPackageWith, that’s the o e03:55:00
@antifuchs:asf.computerantifuchs* nixpkgs.lib.callPackageWith, that’s the one03:55:04
* @charles:computer.surgeryCharles RsTFM03:55:23
@antifuchs:asf.computerantifuchsI’m not sure it’s documented 😭03:55:44
@charles:computer.surgeryCharleshttps://nixos.org/manual/nixpkgs/unstable/#function-library-lib.customisation.callPackageWith ?03:56:13
@antifuchs:asf.computerantifuchsHah, oops! There we go03:56:23
@raitobezarius:matrix.orgraitobezarius
In reply to @charles:computer.surgery
i was gonna go for builtins.functionArgs and doing it manually, but that sounds possibly better
This man is going to reinvent nixpkgs if left alone
03:56:42
@charles:computer.surgeryCharlesyes03:56:51
@raitobezarius:matrix.orgraitobezarius2muchinthefuture03:57:08
@charles:computer.surgeryCharlesin reality i'm just trying to make my dotfiles good03:57:34
@charles:computer.surgeryCharlesusing my new sprinkles thingy03:58:00
@raitobezarius:matrix.orgraitobezariusExcited for the sprinkles RFC04:00:13
@charles:computer.surgeryCharles i briefly considered trying to write a lix plugin that provided a builtins.newSprinkle function 04:00:48
@charles:computer.surgeryCharles also i'm not sure if callPackageWith fits the bill here because i need to combine it with the scope.callPackage too somehow 04:03:01
@antifuchs:asf.computerantifuchsAh, hmm, yeah that’s an issue04:06:29
@antifuchs:asf.computerantifuchsOh wait, isn’t example 254 exactly that?04:07:53
@charles:computer.surgeryCharleskinda04:08:34
@antifuchs:asf.computerantifuchsETOOFUNCTIONAL for my brain atm04:08:37
@charles:computer.surgeryCharles 254 uses callPackageWith to construct the value for newScope, but i want to use an existing other value for that 04:09:10
@charles:computer.surgeryCharles e.g. nixpkgs.newScope 04:09:15
@charles:computer.surgeryCharles

so... this works:

callPackage = fn: args:
  scope.callPackage
    fn
    (args // (
      let
        loadedFn = if builtins.isFunction fn
          then fn
          else if builtins.isPath fn
            then import fn
          else builtins.throw "???";
        requiresSprinkle = builtins.hasAttr
          "sprinkle"
          (builtins.functionArgs loadedFn);
      in
      if requiresSprinkle
      then { sprinkle = self; }
      else {}
    ));
04:24:48
@charles:computer.surgeryCharles now i'm getting infinite recursion presumably because i have packages like { foo }: (foo.override { bar = true; }) that retain the same name in my newly created scope from their original scope, but what's weird is that this wasn't happening before 04:27:35
@charles:computer.surgeryCharles maybe makeScope is the wrong abstraction and i need to use callPackageWith manually, i dunno 04:28:45
@antifuchs:asf.computerantifuchsYeah, possibly. I’m not sure what the value of the scope is considering you can also do mutually-dependent packages with callPackageWith. Maybe eval speed04:32:05
@charles:computer.surgeryCharles tbh i think the point of makeScope is to avoid this exact infinite recursion issue i'm hitting 04:33:17
@llakala:matrix.orgllakala
In reply to @charles:computer.surgery
makeScopedPackagesFromDirectoryRecursive = newScope: directory:
  nixpkgs.lib.customisation.makeScope newScope (scope:
    nixpkgs.lib.filesystem.packagesFromDirectoryRecursive {
      inherit directory;
      callPackage = fn: args:
        scope.callPackage
          fn
          (args // { sprinkle = self; });
    }
  );

not to interrupt but i have to share this extremely long function name i just wrote

I wrote something similar which may be helpful as a reference
04:33:28

Show newer messages


Back to Room ListRoom Version: 10