mirror of
https://codeberg.org/icewind/mill-scale.git
synced 2026-06-03 09:54:19 +02:00
autodep env variables
This commit is contained in:
parent
c8bab3321a
commit
6055ccecb6
4 changed files with 75 additions and 37 deletions
47
autodeps/default.nix
Normal file
47
autodeps/default.nix
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
{ lib, src, config }:
|
||||
let
|
||||
inherit (builtins) readFile pathExists attrNames hasAttr;
|
||||
inherit (lib) map intersectLists foldl splitString getAttrFromPath;
|
||||
|
||||
cargoLockDeps =
|
||||
if pathExists (src + /Cargo.lock) then
|
||||
let
|
||||
cargoLock = fromTOML (readFile (src + /Cargo.lock));
|
||||
in
|
||||
map (package: package.name) cargoLock.package
|
||||
else [ ];
|
||||
availableAutoDeps = import ./deps.nix;
|
||||
detectedDeps = intersectLists cargoLockDeps (attrNames availableAutoDeps);
|
||||
mergedDetectedDeps =
|
||||
if config.autodeps then
|
||||
foldl
|
||||
(merged: dep: {
|
||||
build = merged.build ++ (availableAutoDeps.${dep}.build or [ ]);
|
||||
native = merged.native ++ (availableAutoDeps.${dep}.native or [ ]);
|
||||
env =
|
||||
if (hasAttr "env" availableAutoDeps.${dep}) then
|
||||
pkgs: (merged.env pkgs) // (availableAutoDeps.${dep}.env pkgs)
|
||||
else merged.env;
|
||||
})
|
||||
{
|
||||
build = [ ];
|
||||
native = [ ];
|
||||
env = pkgs: { };
|
||||
}
|
||||
detectedDeps else {
|
||||
build = [ ];
|
||||
native = [ ];
|
||||
env = pkgs: { };
|
||||
};
|
||||
getPkgs = pkgs: deps:
|
||||
let
|
||||
depPaths = map (splitString ".") deps;
|
||||
in
|
||||
map (path: getAttrFromPath path pkgs) depPaths;
|
||||
autoDeps = pkgs: {
|
||||
buildInputs = getPkgs pkgs mergedDetectedDeps.build;
|
||||
nativeBuildInputs = with pkgs; [ pkg-config ] ++ (getPkgs pkgs mergedDetectedDeps.native);
|
||||
env = mergedDetectedDeps.env pkgs;
|
||||
};
|
||||
in
|
||||
autoDeps
|
||||
15
autodeps/deps.nix
Normal file
15
autodeps/deps.nix
Normal file
|
|
@ -0,0 +1,15 @@
|
|||
{
|
||||
"openssl-sys" = { build = [ "openssl" ]; };
|
||||
"libudev-sys" = { build = [ "eudev" ]; };
|
||||
"libdbus-sys" = { build = [ "dbus" ]; };
|
||||
"expat-sys" = { native = [ "cmake" ]; };
|
||||
"servo-fontconfig-sys" = { build = [ "fontconfig" ]; };
|
||||
"x11-dl" = { build = [ "xorg.libX11" "xorg.libXcursor" "xorg.libXrandr" "xorg.libXi" ]; };
|
||||
"glutin_glx_sys" = {
|
||||
build = [ "libGL" ];
|
||||
env = pkgs: {
|
||||
LD_LIBRARY_PATH = with pkgs; "/run/opengl-driver/lib/:${lib.makeLibraryPath ([libGL libGLU])}";
|
||||
};
|
||||
};
|
||||
"wayland-egl" = { build = [ "egl-wayland" ]; };
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue