When is keep-outputs, keep-derivations garbage collected?

I have flake environment for a python development project. Integrating direnv, the website recommends to set

{ pkgs, ... }: {
  nix.extraOptions = ''
    keep-outputs = true
    keep-derivations = true

to protect the shell against garbage collection.

Using these options, what is kept and how long? Do I have to manually trigger a garbage collection, or will nix store every nix build I make forever?

1 Like

Those are related to build time dependencies which by default could get garbage collected. When those options are set they are only garbage collected when the package itself is garbage collected.