flake.nix: expose full scope in legacyPackages

This commit is contained in:
Someone Serge 2023-12-29 16:15:37 +00:00 committed by Philip Taron
parent e39106c055
commit 1e3900ebac
2 changed files with 30 additions and 9 deletions

View File

@ -8,12 +8,13 @@
pkgsCuda, pkgsCuda,
... ...
}: }:
lib.optionalAttrs (system == "aarch64-linux") { {
packages = legacyPackages =
let let
caps.jetson-xavier = "7.2"; caps.llamaPackagesXavier = "7.2";
caps.jetson-orin = "8.7"; caps.llamaPackagesOrin = "8.7";
caps.jetson-nano = "5.3"; caps.llamaPackagesTX2 = "6.2";
caps.llamaPackagesNano = "5.3";
pkgsFor = pkgsFor =
cap: cap:
@ -27,6 +28,12 @@
}; };
}; };
in in
builtins.mapAttrs (name: cap: ((pkgsFor cap).callPackage ./scope.nix { }).llama-cpp) caps; builtins.mapAttrs (name: cap: (pkgsFor cap).callPackage ./scope.nix { }) caps;
packages = lib.optionalAttrs (system == "aarch64-linux") {
jetson-xavier = config.legacyPackages.llamaPackagesXavier.llama-cpp;
jetson-orin = config.legacyPackages.llamaPackagesOrin.llama-cpp;
jetson-nano = config.legacyPackages.llamaPackagesNano.llama-cpp;
};
}; };
} }

View File

@ -80,16 +80,30 @@
... ...
}: }:
{ {
# Unlike `.#packages`, legacyPackages may contain values of
# arbitrary types (including nested attrsets) and may even throw
# exceptions. This attribute isn't recursed into by `nix flake
# show` either.
#
# You can add arbitrary scripts to `.devops/nix/scope.nix` and
# access them as `nix build .#llamaPackages.${scriptName}` using
# the same path you would with an overlay.
legacyPackages = {
llamaPackages = pkgs.callPackage .devops/nix/scope.nix { inherit llamaVersion; };
llamaPackagesCuda = pkgsCuda.callPackage .devops/nix/scope.nix { inherit llamaVersion; };
llamaPackagesRocm = pkgsRocm.callPackage .devops/nix/scope.nix { inherit llamaVersion; };
};
# We don't use the overlay here so as to avoid making too many instances of nixpkgs, # We don't use the overlay here so as to avoid making too many instances of nixpkgs,
# cf. https://zimbatm.com/notes/1000-instances-of-nixpkgs # cf. https://zimbatm.com/notes/1000-instances-of-nixpkgs
packages = packages =
{ {
default = (pkgs.callPackage .devops/nix/scope.nix { inherit llamaVersion; }).llama-cpp; default = config.legacyPackages.llamaPackages.llama-cpp;
} }
// lib.optionalAttrs pkgs.stdenv.isLinux { // lib.optionalAttrs pkgs.stdenv.isLinux {
opencl = config.packages.default.override { useOpenCL = true; }; opencl = config.packages.default.override { useOpenCL = true; };
cuda = (pkgsCuda.callPackage .devops/nix/scope.nix { inherit llamaVersion; }).llama-cpp; cuda = config.legacyPackages.llamaPackagesCuda.llama-cpp;
rocm = (pkgsRocm.callPackage .devops/nix/scope.nix { inherit llamaVersion; }).llama-cpp; rocm = config.legacyPackages.llamaPackagesRocm.llama-cpp;
mpi-cpu = config.packages.default.override { useMpi = true; }; mpi-cpu = config.packages.default.override { useMpi = true; };
mpi-cuda = config.packages.default.override { useMpi = true; }; mpi-cuda = config.packages.default.override { useMpi = true; };