-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnu-libs-and-plugins.nix
80 lines (69 loc) · 2.54 KB
/
nu-libs-and-plugins.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
# This flake exposes some existing nushell libraries (packaged with their dependencies)
#
# When adding a library/plugin here, don't forget to add its inputs to the main flake.nix
{ self, pkgs, ... }@inputs:
let
nu-libraries =
let # Shortcut to build a nu library without too much fuss:
simpleNuLib = name: extraArgs:
self.lib.makeNuLibrary ({
inherit pkgs name;
src = inputs."${name}-src";
} // extraArgs);
in
{
nu-batteries = simpleNuLib "nu-batteries" { };
webserver-nu = simpleNuLib "webserver-nu" {
path = with pkgs; [ "${netcat}/bin" "${coreutils}/bin" ];
};
};
nu-plugins =
let
craneLib = inputs.crane.mkLib pkgs;
cratesIoJsonIndex = self.lib.runNuScript pkgs "plugins-in-crates.io-index"
../nu-src/list-plugins-in-index.nu [ inputs.crates-io-index ];
cratesIoIndex =
builtins.fromJSON (builtins.readFile "${cratesIoJsonIndex}/plugins.json");
pluginsBaseBuildInputs = with pkgs;
[ pkg-config ] ++ lib.optionals (stdenv.hostPlatform.isDarwin) [
iconv
darwin.apple_sdk.frameworks.IOKit
darwin.apple_sdk.frameworks.Security
];
# Non-rust dependencies for plugins from crates.io
#
# Deps are to be added here on a case-by-case fashion
buildInputsForPluginsFromCratesIo = with pkgs; {
binaryview = [ xorg.libX11 ];
cloud = [ openssl ];
dbus = [ dbus ];
fetch = [ openssl ];
from_dhall = [ openssl ];
gstat = [ openssl ];
plotters = [ fontconfig ];
polars = [ openssl ];
post = [ openssl ];
prometheus = [ openssl ];
query = [ openssl ];
s3 = [ openssl ];
};
buildPluginFromCratesIo = { name, ... }@nameVerCksum:
let
src = craneLib.downloadCargoPackage (nameVerCksum // {
source = "registry+https://github.com/rust-lang/crates.io-index";
});
shortName = builtins.replaceStrings [ "nu_plugin_" ] [ "" ] name;
buildInputs = pluginsBaseBuildInputs
++ (buildInputsForPluginsFromCratesIo.${shortName} or [ ]);
cargoArtifacts = craneLib.buildDepsOnly { inherit src buildInputs; };
in
craneLib.buildPackage {
inherit src buildInputs cargoArtifacts;
doCheck = false;
};
in
# All the plugins from crates.io:
# (Each attr is of the form "nu_plugin_<name>")
builtins.mapAttrs (_: buildPluginFromCratesIo) cratesIoIndex;
in
nu-libraries // nu-plugins