!tDnwWRNkmmYtMXfaZl:nixos.org

Nix Language

1518 Members
Nix programming language267 Servers

Load older messages


SenderMessageTime
11 Aug 2024
@lgmrszd:possum.citylgmrszd joined the room.12:26:04
@interru:chat.interru.io@interru:chat.interru.io left the room.15:48:17
12 Aug 2024
@amiablechief:matrix.org@amiablechief:matrix.org left the room.11:34:29
@qbisi:matrix.orgCrower changed their display name from 江一苇 to Crower.13:14:44
@qbisi:matrix.orgCrower set a profile picture.13:15:41
@kyub:matrix.orgkyub left the room.16:59:10
@kyub:matrix.orgkyub joined the room.17:00:44
13 Aug 2024
@atagen:imagisphe.reatagen

how would I enumerate attrs? for example, if I have:

foo = {
 bar = { baz = false; };
 rab = { zab = true; };
};

how can I process this to get

foo = {
 bar = { n = 0; baz = false; };
 rab = { n = 1; zab = true; };
};
```?
02:18:12
@atagen:imagisphe.reatagen *

how would I enumerate attrs? for example, if I have:

foo = {
 bar = { baz = false; };
 rab = { zab = true; };
};

how can I process this to get

foo = {
 bar = { n = 0; baz = false; };
 rab = { n = 1; zab = true; };
};
```
?
02:18:26
@atagen:imagisphe.reatagen *

how would I enumerate attrs? for example, if I have:

foo = {
 bar = { baz = false; };
 rab = { zab = true; };
};

how can I process this to get

foo = {
 bar = { n = 0; baz = false; };
 rab = { n = 1; zab = true; };
};

?

02:18:42
@atagen:imagisphe.reatagen I don't care about the order of evaluation, only that n is unique for each member 02:19:01
@infinisil:matrix.orginfinisil atagen: There's a PR proposing imapAttrs: https://github.com/NixOS/nixpkgs/pull/270049 02:20:59
@emilazy:matrix.orgemily
nix-repl> :p lib.listToAttrs (lib.imap0 (n: {name, value}: {inherit name; value = value // { inherit n; }; }) (lib.attrsToList {a = {}; b = {};}))
{
  a = { n = 0; };
  b = { n = 1; };
}
02:21:56
@emilazy:matrix.orgemily(why do you want this?)02:21:58
@atagen:imagisphe.reatagen
In reply to @emilazy:matrix.org
(why do you want this?)
I have a home-manager option that generates firefox profiles w userchrome removed, unique .desktop files etc to make pseudo-PWAs - the IDs need to be unique and sequential for firefox to respect all entries in the profile ini
02:24:54
@emilazy:matrix.orgemilyI see02:25:20
@emilazy:matrix.orgemily you might want to skip the listToAttrs part depending on your usecase 02:25:28
@emilazy:matrix.orgemilyalso, since there's no ordering guarantees, if renumbering would matter at all you might just want it to be a list to begin with02:25:54
@atagen:imagisphe.reatagenI appreciate the help, I'll have a poke around at it02:25:55
@atagen:imagisphe.reatagenanything beats setting them manually at each site02:26:32
@atagen:imagisphe.reatagen
In reply to @emilazy:matrix.org
also, since there's no ordering guarantees, if renumbering would matter at all you might just want it to be a list to begin with
though hmm yeah
02:26:36
@adis:blad.is@adis:blad.isAttrsets are sorted02:27:03
@atagen:imagisphe.reatagennow I think about it, if I remove one and the number decrements, firefox will probably start using the data of the old profile from the wrong app02:27:08
@adis:blad.is@adis:blad.isSo you'll get numbering in lexicographical order02:27:20
@atagen:imagisphe.reatagen * now I think about it, if I remove one and the number decrements, firefox will probably start using the data of the old profile from the wrong app.. perhaps I can do some symlink crimes based on app names and some stateful stuff in home dir02:29:21
@emilazy:matrix.orgemily
In reply to @adis:blad.is
Attrsets are sorted
uh, TIL
02:30:38
@emilazy:matrix.orgemily
In reply to @atagen:imagisphe.re
now I think about it, if I remove one and the number decrements, firefox will probably start using the data of the old profile from the wrong app.. perhaps I can do some symlink crimes based on app names and some stateful stuff in home dir
I'm confused, surely the reason Firefox profile directories are named after key mashes is to avoid this?
02:31:15
@emilazy:matrix.orgemilyare you sure the ordering is not just to determine the list some UI presents or something?02:31:37
@atagen:imagisphe.reatagenI honestly have no idea02:31:50
@atagen:imagisphe.reatagen hmm, they do have a Path key in the INI, but I don't know if I have simple access to that part of the hm firefox machinery lol 02:32:51

Show newer messages


Back to Room ListRoom Version: 6