3 ms·
> Things like fzf have bash completion accompanying files. I have not figured out where these reside using nix. Bash completions get installed under Nix profil
by pxc 5y ago
> Things like fzf have bash completion accompanying files. I have not figured out where these reside using nix.
Bash completions get installed under Nix profiles (yours, root's (a.k.a., the ‘default profile’), or the ‘system’ profile, if you're using nix-darwin or NixOS), just like binaries.
On my system, I have some bash completions under my user profile, in
/nix/var/nix/profiles/per-user/$USER/profile/share/bash-completion/completions/
and some in the system profile, in
/nix/var/nix/profiles/system/sw/share/bash-completion/completions
If you use a shell installed from Nixpkgs, it'll automatically pick up on all such completions installed to your profiles (which come bundled with the packages they're for). (To try this with bash, make sure to install `bashInteractive` rather than just `bash`.)
If you use a shell configured by a Nix module system, like NixOS or Nix-Darwin, it will provide an option to enable the installation of such completions to your system profile, which you can enable like this: https://github.com/LnL7/nix-darwin/blob/a7492a8c76dcc702d0a65cd820a5f9baa8702684/modules/examples/lnl.nix#L196 https://github.com/LnL7/nix-darwin/blob/a7492a8c76dcc702d0a6...
> Things like mysql make heave use of directories such as /usr/local/var/mysql or similar. I was unsuccessful in surpassing permission problems with these.
It's clear that you're pointing to a real issue, but there's either a typo or a misunderstanding above. If your `mysql` binary really does spit out messages about /usr/local/, it didn't come from Nixpkgs. But if it comes from Nixpkgs, it might be emitting similar complaints about directories under /nix/store.
The explanation: Nix packages don't know or care anything about /usr/local, but they are compiled so that they think all of their ‘prefixes’ (e.g., what by default on a system are just /usr, /lib, /etc, etc.) live in package-specific directories under /nix/store. It's an important part of Nix's design that everything in the store be immutable, and so everything there is marked read-only.
The solution: to use stateful services like databases that you install from Nixpkgs, point them to writeable directories outside of the Nix store to use for their data storage. You can do this manually for mysql with options like `--datadir=/some/writeable/path/you/own` and similar. These same options are used inside Nix module systems when they enable configuration of services like MySQL, e.g., here: https://github.com/NixOS/nixpkgs/blob/nixos-21.05/nixos/modules/services/databases/mysql.nix#L12 https://github.com/NixOS/nixpkgs/blob/nixos-21.05/nixos/modu...
Hope that helps!