switch to alejandra for nix formatting

This commit is contained in:
Robin Appelman 2024-12-23 22:55:24 +01:00
commit 576d0418c8
8 changed files with 500 additions and 386 deletions

View file

@ -1,51 +1,55 @@
{ lib, src, config }:
let
{
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
if pathExists (src + /Cargo.lock)
then let
cargoLock = fromTOML (readFile (src + /Cargo.lock));
in
map (package: package.name) cargoLock.package
else [ ];
else [];
availableAutoDeps = import ./deps.nix;
detectedDeps = intersectLists cargoLockDeps (attrNames availableAutoDeps);
mergedDetectedDeps =
if config.autodeps then
if config.autodeps
then
foldl
(merged: dep: {
build = merged.build ++ (availableAutoDeps.${dep}.build or [ ]);
native = merged.native ++ (availableAutoDeps.${dep}.native or [ ]);
runtime = merged.runtime ++ (availableAutoDeps.${dep}.runtime or [ ]);
env =
if (hasAttr "env" availableAutoDeps.${dep}) then
pkgs: (merged.env pkgs) // (availableAutoDeps.${dep}.env pkgs)
else merged.env;
})
{
build = [ ];
native = [ ];
runtime = [ ];
env = pkgs: { };
}
detectedDeps else {
build = [ ];
native = [ ];
runtime = [ ];
env = pkgs: { };
(merged: dep: {
build = merged.build ++ (availableAutoDeps.${dep}.build or []);
native = merged.native ++ (availableAutoDeps.${dep}.native or []);
runtime = merged.runtime ++ (availableAutoDeps.${dep}.runtime or []);
env =
if (hasAttr "env" availableAutoDeps.${dep})
then pkgs: (merged.env pkgs) // (availableAutoDeps.${dep}.env pkgs)
else merged.env;
})
{
build = [];
native = [];
runtime = [];
env = pkgs: {};
}
detectedDeps
else {
build = [];
native = [];
runtime = [];
env = pkgs: {};
};
getPkgs = pkgs: deps:
let
depPaths = map (splitString ".") deps;
in
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);
nativeBuildInputs = with pkgs; [pkg-config] ++ (getPkgs pkgs mergedDetectedDeps.native);
runtimeInputs = getPkgs pkgs mergedDetectedDeps.runtime;
env = mergedDetectedDeps.env pkgs;
};
in
autoDeps
autoDeps

View file

@ -1,12 +1,12 @@
{
"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" = { runtime = [ "libGL" "libGLU" ]; };
"wayland-egl" = { build = [ "egl-wayland" ]; };
"wayland-sys" = { runtime = [ "wayland" "libxkbcommon" ]; };
"libsodium-sys" = { build = [ "libsodium" ]; };
"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" = {runtime = ["libGL" "libGLU"];};
"wayland-egl" = {build = ["egl-wayland"];};
"wayland-sys" = {runtime = ["wayland" "libxkbcommon"];};
"libsodium-sys" = {build = ["libsodium"];};
}