| 28 Jan 2024 |
@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 | Or you can find the /nix/store path manually and use nix-store --gc --add-root on it | 22:54:04 |
@qyriad:matrix.org | I'm not aware of another way | 22:54:12 |
@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 | 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 | Would it be possible to make a root in the flake itself via nix? | 23:00:31 |
| 29 Jan 2024 |
| Sam Lehman joined the room. | 10:58:52 |
| Sam Lehman set a profile picture. | 11:06:03 |
mr-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 | cheers | 12:07:45 |
lxsameer | is 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 left the room. | 19:55:30 |
| 31 Jan 2024 |
| @federicodschonborn:matrix.org changed their profile picture. | 03:36:26 |
| @federicodschonborn:matrix.org changed their profile picture. | 06:22:05 |
Bryan | 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 | 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 | 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 | lxsameer: ^ | 16:25:50 |
lxsameer | thank you, I had a look at nix-direnv and direnv the other day, I'll try to write somthing and try it out | 16:27:29 |
lxsameer | but it would be cool to have a reference for how the store works | 16:27:46 |
Bryan | I think what I am trying to say is that you don't need to write anything. | 16:27:55 |
Bryan | lxsameer: If you're looking for something that prevents your devShell installed software from getting garbage-collected, nix-direnv just does it already | 16:29:06 |
Bryan | * lxsameer: If you're looking for something that prevents your devShell installed software from getting garbage-collected, nix-direnv just does it already (it should be noted that - by default - the layout dir is <project_directory>/.direnv, which is "inside the flake") | 16:29:57 |
Bryan | Far be it from me to say "don't write a competitor" (I am one of the maintainers for nix-direnv and I wrote one...), but if you just want to skip to the solution - you can | 16:30:48 |
lxsameer | can it handle more than one shells? | 16:30:56 |
Bryan | What does that mean? | 16:31:08 |
Bryan | "Can you do this pattern for an arbitrary number of shells"? Yes - of course. When you cd into the project directory, you'll activate the appropriate one (and you'll hit the cache if you've activated this before, assuming you have direnv and nix-direnv set up properly) | 16:32:14 |
lxsameer | for example, I have a clang based shell and a gcc based shell, would it be able to cache both and prevent all the packages to be excluded from gc? | 16:33:29 |
Bryan | Yes. | 16:33:59 |
Bryan | (Presuming you have two projects with devShell defined) | 16:34:15 |