Update pkg setup
This commit is contained in:
60
flake.nix
60
flake.nix
@@ -1,5 +1,5 @@
|
||||
{
|
||||
description = "Ascend CANN Toolkit Nix package";
|
||||
description = "Ascend CANN: ascend-toolkit (CANN env), bisheng-wrapper (Nix bisheng; needs ASCEND_TOOLKIT_HOME), ascend-cann (both)";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
|
||||
@@ -10,6 +10,23 @@
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
lib = pkgs.lib;
|
||||
|
||||
bishengNixCflags =
|
||||
let
|
||||
gccCc = pkgs.gcc13.cc;
|
||||
cxxDev = lib.getDev gccCc;
|
||||
ccVersion = gccCc.version;
|
||||
host = pkgs.stdenv.hostPlatform.config;
|
||||
in
|
||||
builtins.concatStringsSep " " [
|
||||
"-isystem ${cxxDev}/include/c++/${ccVersion}"
|
||||
"-isystem ${cxxDev}/include/c++/${ccVersion}/${host}"
|
||||
"-isystem ${gccCc}/lib/gcc/${host}/${ccVersion}/include"
|
||||
"-isystem ${pkgs.glibc.dev}/include"
|
||||
];
|
||||
|
||||
bishengNixCflagsFile = pkgs.writeText "bisheng-nix-cflags" bishengNixCflags;
|
||||
|
||||
fetchAscendToolkit = pkgs.fetchurl {
|
||||
url = "https://git.amadey.xyz/api/packages/mozart/generic/ascend-toolkit/8.5.0/ascend-toolkit-8.5.0-310p-full.tar.gz";
|
||||
@@ -52,6 +69,8 @@
|
||||
find $out/tools -type f \( -name "*.py" -o -name "*.sh" \) -exec chmod +x {} + 2>/dev/null || true
|
||||
'';
|
||||
|
||||
setupHook = ./nix/ascend-toolkit-setup-hook.sh;
|
||||
|
||||
postFixup = ''
|
||||
echo "Adding RPATH for toolkit-internal libraries..."
|
||||
local rpath="$out/lib64:$out/devlib:$out/tools/aml/lib64"
|
||||
@@ -72,13 +91,11 @@
|
||||
if [ -f "$bisheng_config" ]; then
|
||||
cp ${./nix/bisheng_config_patched.cmake} "$bisheng_config"
|
||||
fi
|
||||
'';
|
||||
|
||||
passthru = {
|
||||
setupHook = pkgs.makeSetupHook
|
||||
{ name = "ascend-toolkit-setup-hook.sh"; }
|
||||
./nix/ascend-toolkit-setup-hook.sh;
|
||||
};
|
||||
if [ -f "$out/nix-support/setup-hook" ]; then
|
||||
substituteInPlace "$out/nix-support/setup-hook" --subst-var-by ASCEND_TOOLKIT "$out"
|
||||
fi
|
||||
'';
|
||||
};
|
||||
|
||||
bisheng-wrapper = pkgs.stdenv.mkDerivation {
|
||||
@@ -107,17 +124,42 @@
|
||||
EOF
|
||||
|
||||
touch $out/nix-support/add-local-cc-cflags-before.sh
|
||||
|
||||
cp ${bishengNixCflagsFile} $out/nix-support/bisheng-nix-cflags
|
||||
cp ${./nix/bisheng-wrapper-setup-hook.sh} $out/nix-support/setup-hook
|
||||
substituteInPlace $out/nix-support/setup-hook \
|
||||
--subst-var-by WRAPPER_OUT "$out"
|
||||
'';
|
||||
|
||||
meta = with pkgs.lib; {
|
||||
description = "Wrapper for Huawei Bisheng compiler that injects Nix compilation flags";
|
||||
description = "Bisheng wrapper with Nix CFLAGS; set ASCEND_TOOLKIT_HOME to your CANN toolkit (use with ascend-toolkit or any upstream install)";
|
||||
license = licenses.mit;
|
||||
};
|
||||
};
|
||||
|
||||
# Single dependency for dev shells: propagates toolkit + bisheng-wrapper (hooks run in list order).
|
||||
ascend-cann = pkgs.stdenvNoCC.mkDerivation {
|
||||
pname = "ascend-cann";
|
||||
version = ascend-toolkit.version;
|
||||
|
||||
dontUnpack = true;
|
||||
|
||||
installPhase = "mkdir -p $out";
|
||||
|
||||
propagatedBuildInputs = [
|
||||
ascend-toolkit
|
||||
bisheng-wrapper
|
||||
];
|
||||
|
||||
meta = with pkgs.lib; {
|
||||
description = "Meta package: CANN toolkit + Bisheng Nix wrapper (add only this, or use ascend-toolkit / bisheng-wrapper separately)";
|
||||
license = licenses.mit;
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
packages = {
|
||||
inherit ascend-toolkit bisheng-wrapper;
|
||||
inherit ascend-toolkit bisheng-wrapper ascend-cann;
|
||||
default = ascend-toolkit;
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user