Way to install in environment
numkem opened this issue · comments
Is there a way to install the doc plugin using environment.systemPackages
? It seems like the shared object isn't copied into the system wide one.
I currently don't have any packages inside my nix-env
and I'd like to keep it that way.
I've installed the nix-doc
package using an overlay with niv
being used to provide the sources.nix
:
self: super:
let
sources = import ./nix/sources.nix;
in {
nix-doc = import sources.nix-doc { };
}
Thanks!
🤷♀️
The reason I provided instructions doing it this way is that there's a persistent symbolic link to the used version of nix-doc if you put it in the user environment so the config situation is easier. I don't use NixOS so I don't think I can be of that much assistance.
Basically what you want is to figure out how to provide that library shared object somewhere you can point to effectively in the config file, and we don't really depend on anything about how you do it.
@lf- Just discovered this application, nice!
@numkem If you are on NixOS and use configuration.nix
- create a derivation using rustPlatform
.
{ stdenv, rustPlatform, fetchgit, pkgs, ... }:
rustPlatform.buildRustPackage rec {
pname = "nix-doc";
version = "v0.3.1";
src = fetchgit {
rev = version;
url = "https://github.com/lf-/nix-doc.git";
sha256 = "1hiz0fsbsl74m585llg2n359gs8i2m6jh8zdikkwxd8xq7qmw032";
};
buildInputs = with pkgs; [ boost nix ];
nativeBuildInputs = with pkgs; [ pkg-config ];
cargoSha256 = "1d1gvx14yai4dyz44pp2ffx2swfxnm0fwvldy96dw9gqmar69cpv";
meta = with stdenv.lib; {
homepage = url;
license = licenses.lgpl3;
description = "A Nix documentation lookup tool that quickly dumps the docs of the library function";
};
}
Then expose the package using the normal configuration.nix
options, where ../program/nixdoc/default.nix
is the path to the above derivation named default.nix
. Link the plugin file using nix.extraOptions
.
{ pkgs, ... }:
{
nix.extraOptions = ''
plugin-files = ${pkgs.callPackage ../program/nixdoc/default.nix {}}/lib/libnix_doc_plugin.so
'';
environment.systemPackages = with pkgs; [
(callPackage ../program/nixdoc/default.nix {})
];
}
@tdro that would be a fantastic addition to our documentation, either in the README or in another file. I'd love if you made a PR with it.
While the solution @tdro posted works I wanted to use the package that is already defined in default.nix
rather than having to duplicate the package.
What I ended up doing was to add this repo using niv by doing niv add lf-/nix-doc
than add the package inside an overlay as:
self: super:
let
sources = import ./nix/sources.nix;
in {
nix-doc = import sources.nix-doc { };
}
than somewhere inside my configuration.nix
I added this (thanks @tdro for the pointer):
{ pkgs, ... }:
{
environment.systemPackages = with pkgs; [ nix-doc ];
nix.extraOptions = ''
plugin-files = ${pkgs.nix-doc}/lib/libnix_doc_plugin.so
'';
}
Doing this works and I don't have to maintain/duplicate the package definiton.
Maybe it would be better to show this in the README instead? Or document them inside the Wiki section?
@numkem this may all become moot as a traditional cargo based packaging is going to be put in nixpkgs where it's easy to use.
That would be even better! Official package makes everything easier.
I think we can close this. If anything this issues could be seen as documentation.
Thank you for your time!
for reference: NixOS/nixpkgs#95161 is the PR for nixpkgs