The `-a` from exec sets the `$0` from the process. So `exec -a "$0"`
would set the name of the new process to `nvidia-offload` (the name of
the script), however this is causing issues with a few programs that try
to interpret `$0` in a special way. For example, see `wine`:
```
$ nvidia-offload /nix/store/zhv91s26gsrl1w8yn9800xd03a31r3wj-wine-osu-7.0/bin/wine .osu/drive_c/osu/osu\!.exe
/nix/store/zhv91s26gsrl1w8yn9800xd03a31r3wj-wine-osu-7.0/bin/nvidia-offload: could not open
```
What I think `wine` is doing here is trying to re-exec `wine` again, but
to do so it tries to figure out the original call of wine by readind `$0`,
and will fail in this case because the `$0` was changed because of the
`nvidia-offload` script using `-a` flag, as explained above.
Instead, let's simplify this. There is no good reason to rename the `$0`
from the script anyway (it just sets a few environment variables), so let's
just remove it. We may lose the ability to know if the command is being
offloaded, but I think having more commands to work is a good trade-off.
`libvdpau-va-gl` is a wrapper around VAAPI to have a VDPAU driver, which
is required for Intel GPU's. `VDPAU_DRIVER` environment variable is set
to "va_gl", since it defaults to "nvidia".
Two reasons for this change:
- `intel` drivers are not updated from quite a long time (since ~2019),
and `modesetting` is the preferred one for Intel iGPUs.
- Technically you may want to disable NVIDIA GPUs on laptops with AMD
processors too.
We don't want to pin `modesetting` here because it is already the default
since PR: https://github.com/NixOS/nixpkgs/pull/111551.
This is already used in XPS 15-9560, but instead of defining it in XPS
15-9560 let's create a separate profile and expose it for those who want
to disable their NVIDIA GPU.
This will run TRIM once a week using a systemd timer. Running TRIM regularly
will improves the performance and increases the SSDs lifespan. Since it is based
on the utillinux no additional package is required.
I've tested this to work on MacBookAir4,1 and I'm going to deploy it
to MacBookAir6,2 today and Lenovo ThinkPad X230 in a week from now.
Also, cleaned up Lenovo ThinkPad X230 profile.