!SgYlXivkogarTVcnZO:nixos.org

Nix Flakes

886 Members
179 Servers

Load older messages


SenderMessageTime
28 Jan 2024
@qyriad:matrix.org@qyriad:matrix.orgflake.lock doesn't come into the picture directly21:31:45
@mr-qubo:matrix.orgmr-qubo
In reply to @lxsameer:matrix.org
hey folkss, when running nix store gc, how does nix know what to delete? does it know what flake.lock files do I have?
It doesn't know about flake.lock by default. But it's possible to add it as a root manually. Some projects, e.g. direnv, do that for you.
22:24:36
@lxsameer:matrix.orglxsameerInteresting22:41:29
@lxsameer:matrix.orglxsameerI'm not on nixos and i want to gc the store without removing my flake related packages22:42:09
@qyriad:matrix.org@qyriad:matrix.orgwhat do you mean by "flake related packages"?22:43:34
@lxsameer:matrix.orglxsameer I use flakes to manage the dependencies in my projects. for example i install clang toolchain and few other things in my flake, when I do nix store gc I don't want nix to remove them 22:45:06
@qyriad:matrix.org@qyriad:matrix.org if you have done something like nix build, that creates a result symlink in the flake directory. That symlink will keep those packages from being garbage collected 22:46:17
@lxsameer:matrix.orglxsameerah ok, what about packages that I add to my devshell ?22:47:14
@qyriad:matrix.org@qyriad:matrix.org nix develop doesn't create a gc root (except for processes running in that shell) 22:52:16
@qyriad:matrix.org@qyriad:matrix.org If you want to create a symlink to those you can run something like nix build --impure --expr 'let flake = builtins.getFlake "/full/path/to/flakedir"; in flake.outputs.devShells.x86_64-linux.default' to create that result symlink 22:53:46
@qyriad:matrix.org@qyriad:matrix.org Or you can find the /nix/store path manually and use nix-store --gc --add-root on it 22:54:04
@qyriad:matrix.org@qyriad:matrix.orgI'm not aware of another way22:54:12
@qyriad:matrix.org@qyriad:matrix.org but also if you run nix store gc you can just re-run nix develop to re-download/build those store paths 22:54:49
@charles:computer.surgeryCharles
In reply to @lxsameer:matrix.org
I use flakes to manage the dependencies in my projects. for example i install clang toolchain and few other things in my flake, when I do nix store gc I don't want nix to remove them
if you use direnv and nix-direnv, it will create gc roots for your flakes
22:57:02
@lxsameer:matrix.orglxsameerWould it be possible to make a root in the flake itself via nix?23:00:31
29 Jan 2024
@lehmanator:tchncs.deSam Lehman joined the room.10:58:52
@lehmanator:tchncs.deSam Lehman set a profile picture.11:06:03
@mr-qubo:matrix.orgmr-qubo
In reply to @lxsameer:matrix.org
Would it be possible to make a root in the flake itself via nix?
Just look how direnv does that.
12:07:30
@lxsameer:matrix.orglxsameercheers12:07:45
@lxsameer:matrix.orglxsameeris there any docs on the structure of the store that I can use while I'm working on this?18:14:33
30 Jan 2024
@erremilia:matrix.org@erremilia:matrix.org left the room.19:55:30
31 Jan 2024
@federicodschonborn:matrix.org@federicodschonborn:matrix.org changed their profile picture.03:36:26
@federicodschonborn:matrix.org@federicodschonborn:matrix.org changed their profile picture.06:22:05
@bryan.bennett:matrix.orgBryan lxsameer: This is exactly what nix-direnv does, for the record. We create the root in the direnv layout dir (which is kind of what that directory is for - creating state that we need for direnv-related things) 15:34:40
@lxsameer:matrix.orglxsameer
In reply to @bryan.bennett:matrix.org
lxsameer: This is exactly what nix-direnv does, for the record. We create the root in the direnv layout dir (which is kind of what that directory is for - creating state that we need for direnv-related things)
what do you mean by "We create the root in the direnv layout dir"?
16:20:03
@bryan.bennett:matrix.orgBryan

There are multiple things that might require explaining there, so I'll talk about them individually:

  • the direnv layout directory is just a directory that state lives in for direnv and its plugins to use. The python layout populates it (in part) with a virtual environment, for instance.
  • The root is just a symlink that points to a derivation in the store (more or less). We create those in the layout directory.
16:25:44
@bryan.bennett:matrix.orgBryan lxsameer: ^ 16:25:50
@lxsameer:matrix.orglxsameerthank you, I had a look at nix-direnv and direnv the other day, I'll try to write somthing and try it out16:27:29
@lxsameer:matrix.orglxsameerbut it would be cool to have a reference for how the store works16:27:46
@bryan.bennett:matrix.orgBryan I think what I am trying to say is that you don't need to write anything. 16:27:55

Show newer messages


Back to Room ListRoom Version: 6