!tDnwWRNkmmYtMXfaZl:nixos.org

Nix Language

1901 Members
Nix programming language355 Servers

Load older messages


SenderMessageTime
20 May 2026
@me:nahsi.devnahsi joined the room.09:48:48
@lumi:the-apothecary.clubNuwa changed their profile picture.21:00:54
@lumi:the-apothecary.clubNuwa changed their display name from Hazel to Aspen.22:37:52
21 May 2026
@libregeekingkid:matrix.orgrajudev joined the room.00:00:20
@moatx:matrix.org@moatx:matrix.org removed their profile picture.15:47:26
@k.sommer:mozilla.org@k.sommer:mozilla.org joined the room.16:29:06
@k.sommer:mozilla.org@k.sommer:mozilla.org changed their display name from k-sommer to k-sommer 🏳️‍⚧️.16:29:51
@k.sommer:mozilla.org@k.sommer:mozilla.org changed their display name from k-sommer 🏳️‍⚧️ to 🏳️‍⚧️❄️ k-sommer (she/her).16:42:18
@bonsal2:matrix.orgjayf99 joined the room.18:45:33
@k.sommer:mozilla.org@k.sommer:mozilla.org left the room.20:48:28
@moatx:matrix.org@moatx:matrix.org left the room.22:01:44
22 May 2026
@lin_0kx:catgirl.cloud凛锋 changed their profile picture.10:24:09
@share-x:matrix.orgshare-x joined the room.15:22:09
23 May 2026
@exodus786:matrix.orgdj joined the room.06:04:20
@inclyc:matrix.orgYingchi Long changed their profile picture.11:24:37
@mtmn:matrix.orgmtmn joined the room.15:20:49
25 May 2026
@llakala:matrix.orgllakala

how does nix handle these differently when it comes to laziness?

let
  inherit (builtins) isInt genList;
  assertMsg = pred: msg: pred || throw msg;
  v1 =
    x:
    assert isInt x || throw "error message";
    x * 2;
  v2 =
    x:
    assert assertMsg (isInt x) "error message";
    x * 2;
  indices = genList (i: i) 100;
in
map v2 indices

i understand that assertMsg and similar functions (throwIf, warnIf, etc) are bad for performance - i can run stats on both versions and tell you that we go from 7 -> 107 thunks, 200 -> 400 function calls, and 4300 -> 7500 envs.bytes when using v2. what i don't get is how we're able to only have 7 thunks in the || case. how do we not need to create a thunk on every call?

01:58:00
@llakala:matrix.orgllakala (posted this in #users:nixos.org and was sent here for esoterica) 01:58:17
@infinisil:matrix.orginfinisilA while ago i wrote https://wiki.nixos.org/wiki/Nix_Evaluation_Performance which should help here :)07:25:51
@llakala:matrix.orgllakalayes I've read that - but that doesn't clarify how || works11:04:19
@llakala:matrix.orgllakala(off-topic but I'd appreciate a response on https://github.com/NixOS/nixpkgs/pull/520174)11:06:16
@lumi:the-apothecary.clubNuwa changed their profile picture.11:25:50
@lumi:the-apothecary.clubNuwa changed their profile picture.11:27:04
@lumi:the-apothecary.clubNuwa changed their display name from Aspen to Orion.11:27:52
@lisa:bylisa.devlisa changed their profile picture.11:37:25
@funzen:matrix.orgfunzen set a profile picture.12:39:32
@piegames:flausch.socialpiegamesCould it be that function applications are not counted as thunks? I'm not sure I would trust the code to accurately track all counters at all times, the stats code is badly designed (slapped on) and thus notoriously badly maintained16:25:18
@piegames:flausch.socialpiegames https://git.lix.systems/lix-project/lix/src/branch/main/lix/libexpr/primops.cc#L2251 It creates a Value::app which kinda sorta is a type of thunk, but also distinct from Value::thunk 16:25:51
@piegames:flausch.socialpiegames * https://git.lix.systems/lix-project/lix/src/branch/main/lix/libexpr/primops.cc#L2378 It creates a Value::app which kinda sorta is a type of thunk, but also distinct from Value::thunk 16:27:12
@mattsturg:matrix.orgMatt Sturgeon

I noticed in the repl that there is a builtins.unsafeDiscardOutputDependency. Is it new?

It seems extremely similar to builtins.unsafeDiscardStringContext, so I'm wondering what the difference is and when I might choose one over the other, or if I'd ever need to apply both?

nix-repl> :doc builtins.unsafeDiscardStringContext
Synopsis: builtins.unsafeDiscardStringContext s

Discard the string context from a value that can be coerced to a string.
nix-repl> :doc builtins.unsafeDiscardOutputDependency
Synopsis: builtins.unsafeDiscardOutputDependency s

Create a copy of the given string where every derivation deep string context
element is turned into a constant string context element.

This is the opposite of builtins.addDrvOutputDependencies.

This is unsafe because it allows us to "forget" store objects we would have
otherwise referred to with the string context, whereas Nix normally tracks all
dependencies consistently. Safe operations "grow" but never "shrink" string
contexts. builtins.addDrvOutputDependencies in contrast is safe because
"derivation deep" string context element always refers to the underlying
derivation (among many more things). Replacing a constant string context
element with a "derivation deep" element is a safe operation that just
enlargens the string context without forgetting anything.

There's also the derivation attr unsafeDiscardReferences, which seems to apply mostly to the serialized structured attrs?

16:52:48

Show newer messages


Back to Room ListRoom Version: 6