!djTaTBQyWEPRQxrPTb:nixos.org

Nixpkgs Architecture Team

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

Load older messages


SenderMessageTime
10 Jul 2022
@infinisil:matrix.orginfinisil Maybe even a builtins.prefixedAutocall 15:51:32
@kevincox:matrix.orgkevincox I think some sort of ProxyAttrs that allowed overriding lookup and iteration would be the generic option. But we could also just hardcode the lookup scheme that we pick. 15:52:26
@infinisil:matrix.orginfinisilOh I see, so you mean to allow people to specify some file outside of nixpkgs for a specific attribute for development?15:53:27
@infinisil:matrix.orginfinisilI think that's very unproblematic, an overlay can already be used for that15:54:31
@kevincox:matrix.orgkevincox

I'm thinking something like this. (For a flat solution)

all-packages = builtin.proxyAttrs {
  lookup = name: pkgs.callPackage (import "pkgs/${name}.nix");
  list-keys = # List all packages and return a list or something here.
};

Then for the common case of nix-build -A foo it just calls lookup "foo" and only that package is loaded.

15:56:13
@infinisil:matrix.orginfinisilAh! Yes that's an interesting idea and could have many other useful applications15:57:24
@kevincox:matrix.orgkevincoxTo all other Nix code it would behave like a regular attrs of all packages except as long as you never do something that requires listing attributes it doesn't have to build the full set.15:57:29
@kevincox:matrix.orgkevincox(IDK if we need other primitive operations but they can be added easily. We can also do caching to ensure that it is pure)15:58:11
@kevincox:matrix.orgkevincoxYeah, for nixpkgs we can make as complicated of a lookup as we like, include 1 or 2 level and whatnot. We can also fall back to the current all-packages.nix attr for transition.15:59:05
@kevincox:matrix.orgkevincoxThis could also be polyfilled for older NIxes by eagerly computing the real attrs.16:07:43
@kevincox:matrix.orgkevincox * This could also be polyfilled for older NIxes by eagerly computing the a attrset.16:09:26
@kevincox:matrix.orgkevincox* This could also be polyfilled for older NIxes by eagerly computing the resulting attrset.16:17:37
11 Jul 2022
@j-k:matrix.orgj-k

Slightly related: I just noticed /nix/var/log/nix/drvs/ has a 2 letter prefix sub dir pattern

λ ls /nix/var/log/nix/drvs/
 00   0s   1l   2f   38   42   4w   5n   6h   7a # ... etc ...
11:01:01
@whentze:matrix.orgWanja Hentze joined the room.12:39:14
@hexa:lossy.networkhexa joined the room.12:45:26
@profpatsch:augsburg.oneprofpatsch joined the room.12:45:49
@andreas.schraegle:helsinki-systems.deAndreas Schrägle joined the room.12:49:24
@toonn:matrix.orgtoonn joined the room.13:31:16
@winterqt:nixos.devWinter (she/her) joined the room.15:18:42
@kayla.fire:matrix.orgkayla.fire joined the room.18:48:48
@sandro:supersandro.deSandro 🐧
In reply to @j-k:matrix.org

Slightly related: I just noticed /nix/var/log/nix/drvs/ has a 2 letter prefix sub dir pattern

λ ls /nix/var/log/nix/drvs/
 00   0s   1l   2f   38   42   4w   5n   6h   7a # ... etc ...
Really common for hash based directory structures to keep the amount of things in a directory smaller
23:54:06
@sandro:supersandro.deSandro 🐧Because if you have a lot a lot of files in a directory listing that gets show23:54:32
@sandro:supersandro.deSandro 🐧* Because if you have a lot a lot of files in a directory listing that gets slow23:54:37
12 Jul 2022
@kevincox:matrix.orgkevincox /nix/store laughs. 00:42:06
@kevincox:matrix.orgkevincoxBut honestly it is generally better to let the storage system do something optimal. Especially for this case where the prefix will depend on human-chosen names. However we know at least that GitHub handles this poorly and that Git doesn't do anything clever at the moment. So we do need to meet our tools.00:43:23
@yorik.sar:matrix.orgyorik.sar

/nix/store is stored locally, rarely listed and mostly accessed by the entry name. That's why we get get away with FS choosing optimal representation for it (hash tree usually).
Nixpkgs is stored in Git and often listed in editors and UIs, all of them are not great with huge directories, so we should optimize for smaller ones.

I wonder why such nested structure was chosen for logs though.

05:40:25
@hsngrmpf:matrix.orgDavHau
In reply to @kevincox:matrix.org

I'm thinking something like this. (For a flat solution)

all-packages = builtin.proxyAttrs {
  lookup = name: pkgs.callPackage (import "pkgs/${name}.nix");
  list-keys = # List all packages and return a list or something here.
};

Then for the common case of nix-build -A foo it just calls lookup "foo" and only that package is loaded.

I really like that idea. Especially as it allows to add a package by just dropping a file somewhere. Having to edit some all-packages.nix is really unnecessary overhead.

Assuming overrides are still a thing at the time when this gets implemented, we'd have to find a new solution for the default callPackage overrides that are currently done in all-packages.nix for some packages.
I see the following options for this:

  1. Create one central overrides file for default callPackage overrides (I think this is a bad idea)
  2. Manage the overrides within the .nix of each package, though then it requires a reference to pkgs.
  3. Deprecate in-line overrides all-together and enforce the creation of an actual individual package for each required package variation. This would make every existing package variation referenceable by an actual attribute name, which is great for further overriding by the user.

For example, if we have packages hello and foobar, where hello depends on an overridden foobar, we could have the following files:

/fo/ob/foobar.nix
/he/ll/hello.nix
/he/ll/foobar.nix  -  (the overridden foobar package for hello)

/he/ll/foobar.nix could look like this:

{foobar,}:
foobar.overrideAttrs (old: {
   pname = "foobar-for-hello";
})
08:47:07
@hsngrmpf:matrix.orgDavHau If we have a flat package structure another question to answer would be, how are package name collisions treated.
Where to put the pythonhello package, or the nodejs hello package, and how should those be named?
08:55:56
@k900:0upti.meK900 I'd expect to still have stuff like python3Packages 08:56:29
@k900:0upti.meK900Maybe in a special top-level directory08:56:36

Show newer messages


Back to Room ListRoom Version: 9