!SgYlXivkogarTVcnZO:nixos.org

Nix Flakes

890 Members
179 Servers

Load older messages


SenderMessageTime
26 Dec 2021
@withoutwithin:matrix.orgXebut yeah i was just doing things really wrongly with how i was copying things into my flake.nix18:53:36
@withoutwithin:matrix.orgXeScreenshot from 2021-12-26 13-53-12.png
Download Screenshot from 2021-12-26 13-53-12.png
18:53:50
@withoutwithin:matrix.orgXeit works now πŸ˜€18:53:54
28 Dec 2021
@ilkecan:matrix.orgilkecan
In reply to @andi:kack.it
So, how do I write a flake that doesn't rebuild all the packages that have their source in the same repo (root) whenever I change a whitespace in my flake.nix? Is filterSource compatible/supported with flakes?
You need to use nix-filter or something equivalent.
18:57:38
@andi:kack.itandi-I wrote a filter expression that only accepted a single file. It still copied everything in the store.18:58:26
@ilkecan:matrix.orgilkecan
In reply to @flyx:flyx.org
hi folks! how can I prevent every edit of flake.nix to cause everything depending on self being rebuilt on the next nix build? flake.nix is checked into git so it is part of self, but obviously not part of the sources being built, so an edit should only affect those derivations whose definitions were changed by the edit
please see the message above
18:58:27
@ilkecan:matrix.orgilkecan
In reply to @andi:kack.it
I wrote a filter expression that only accepted a single file. It still copied everything in the store.
The repo is copied to the Nix store before each evaluation but using nix-filter should prevent unnecessary rebuilds.
18:59:57
@andi:kack.itandi-yeah but the former is the issue I am trying to avoid.19:00:14
@andi:kack.itandi-No point in copying everythin ginto the repo for just a few files..19:00:22
@ilkecan:matrix.orgilkecanYou didn't say that in you original message. You asked how to write a flake that doesn't rebuild all packages not how to prevent Nix copying the full repo to the store.19:02:15
29 Dec 2021
@putch4r:matrix.orgputchar joined the room.12:46:08
@v0id:nltrix.netv0|d joined the room.18:19:47
30 Dec 2021
@aditsachde:matrix.orgAdit joined the room.07:44:28
@ereslibre:matrix.orgereslibre joined the room.10:22:12
@flyx:flyx.orgflyxI'm writing another article about Nix Flakes, and I'd like to write it in a way that enables me to automatically test whether the Nix code I show actually works. is there per chance someone else who did that and has a repo for it available where I can draw inspiration from?19:13:22
@flyx:flyx.orgflyx
In reply to @ilkecan:matrix.org
You need to use nix-filter or something equivalent.
when using nix-filter on root = self; it complains that root isn't a path. using self.outPath or builtins.toPath self doesn't work either.
20:50:34
@ilkecan:matrix.orgilkecan
In reply to @flyx:flyx.org
when using nix-filter on root = self; it complains that root isn't a path. using self.outPath or builtins.toPath self doesn't work either.
You can use ./.
20:52:39
@flyx:flyx.orgflyx hmm, why do we have self then? 20:53:37
@ilkecan:matrix.orgilkecan
In reply to @flyx:flyx.org
hmm, why do we have self then?

self is an attribute set that has multiple attributes, one of them being outPath. In my experience, self is generally used to refer to the outputs of the current flake (e.g. self.packages). As for why self has an outPath attribute when we have ./.; I am not sure whether self.outPath is required or better than ./. for some cases but removing a possible edge case (all flake inputs except self has outPath) is enough of a reason for me.

nix-filter expects root to be a Nix path but self.outPath is a string with context. While I don't know why that is necessary, one reason might be there was a bug in Nix that prevented filtering strings with context. But that should be possible now so the assertion in nix-filter might not be needed anymore.

21:59:12
@ilkecan:matrix.orgilkecan
In reply to @flyx:flyx.org
hmm, why do we have self then?
*

self is an attribute set that has multiple attributes, one of them being outPath. In my experience, self is generally used to refer to the outputs of the current flake (e.g. self.packages). As for why self has an outPath attribute when we have ./.; I am not sure whether self.outPath is required or better than ./. for some cases but removing a possible edge case (all flake inputs except self has outPath) is enough of a reason for me.

nix-filter expects root to be a Nix path but self.outPath is a string with context. While I am not sure why that assertion is necessary, one reason might be there was a bug in Nix that prevented filtering strings with context. But that should be possible now so the assertion in nix-filter might not be needed anymore.

22:00:04
@tomberek:matrix.orgtomberekusing self is generally preferred over ./.22:01:17
@tomberek:matrix.orgtomberekand at first it was unknown exactly what parts of storePath, path, filterSource, etc were safe, so we started with most of them not being allowed, and are slowly re-allowing them as we learn what can be done while retaining purity.22:02:19
@ilkecan:matrix.orgilkecan
In reply to @tomberek:matrix.org
using self is generally preferred over ./.
Why is that?
22:03:16
@ilkecan:matrix.orgilkecanIs it because of style or is there a difference between the two?22:04:37
@tomberek:matrix.orgtombereki think it is more resilient when it comes to things like the name of the folder it happens to be in 22:07:15
@ilkecan:matrix.orgilkecan Unless If I misunderstood you I don't think that is the case because both will refer to the same Nix store path in the form of /nix/store/<hash>-source. Since flake evaluation happens in the Nix store, possible impurity from the name of the root directory is avoided altogether. 22:13:31
@ilkecan:matrix.orgilkecan
In reply to @ilkecan:matrix.org

self is an attribute set that has multiple attributes, one of them being outPath. In my experience, self is generally used to refer to the outputs of the current flake (e.g. self.packages). As for why self has an outPath attribute when we have ./.; I am not sure whether self.outPath is required or better than ./. for some cases but removing a possible edge case (all flake inputs except self has outPath) is enough of a reason for me.

nix-filter expects root to be a Nix path but self.outPath is a string with context. While I am not sure why that assertion is necessary, one reason might be there was a bug in Nix that prevented filtering strings with context. But that should be possible now so the assertion in nix-filter might not be needed anymore.

I think lib.pathIsDirectory can be used instead of builtins.isPath in that assertion.
22:41:48
31 Dec 2021
@brendanzab:matrix.orgbrendanzab is there a way to check the flake schema somehow? I was running nix flake check, assuming it was checking the schema, but if seems like it let through a bug with how I'd defined my apps: https://github.com/brendanzab/ocaml-flake-example/pull/5/files 08:48:04
@brendanzab:matrix.orgbrendanzab

it only popped up when I ran nix flake show and got:

git+file:///.../ocaml-flake-example?ref=main&rev=840f7782276b4e1cc17c3baa3fae03247d188c78
β”œβ”€β”€β”€apps
β”‚   β”œβ”€β”€β”€aarch64-darwin
error: not an app definition
08:48:56
@brendanzab:matrix.orgbrendanzab is seems like that produced an non-zero exit code though. should I be running nix flake show in CI? 08:50:00

Show newer messages


Back to Room ListRoom Version: 6