diff --git a/flake.nix b/flake.nix index f5cf582..534f900 100644 --- a/flake.nix +++ b/flake.nix @@ -33,6 +33,7 @@ sfpi = callPackages ./pkgs/sfpi { }; luwen = callPackage ./pkgs/luwen { }; tools-common = callPackage ./pkgs/tools-common { }; + system-tools = callPackage ./pkgs/system-tools { }; flash = callPackage ./pkgs/flash { pyluwen = self.luwen.pyluwen_0_1; }; @@ -56,6 +57,7 @@ luwen = scope.luwen.luwen; pyluwen = scope.luwen.pyluwen; tools-common = scope.tools-common; + system-tools = scope.system-tools; flash = scope.flash; umd = scope.umd; metal = scope.metal; diff --git a/pkgs/system-tools/default.nix b/pkgs/system-tools/default.nix new file mode 100644 index 0000000..fa2cb62 --- /dev/null +++ b/pkgs/system-tools/default.nix @@ -0,0 +1,57 @@ +{ + lib, + stdenv, + fetchFromGitHub, + makeWrapper, + bash, + pciutils, +}: + +# NOTE: We might not use these files if we end up doing the things it does in nix instead if possible. + +stdenv.mkDerivation rec { + pname = "tt-system-tools"; + version = "unstable-2024-10-11"; + + src = fetchFromGitHub { + owner = "tenstorrent"; + repo = "tt-system-tools"; + rev = "29ba4dc6049eef3cee4314c53720417823ffc667"; + hash = "sha256-1Z6I5LAfOdNrTSBm49LyBGkmlhgfXKsAxA867rvDiIE="; + }; + + strictDeps = true; + nativeBuildInputs = [ makeWrapper ]; + buildInputs = [ bash ]; + + dontBuild = true; + dontConfigure = true; + + installPhase = '' + runHook preInstall + + install -Dm444 -t $out/lib/systemd/system/ "tenstorrent-hugepages.service" + install -Dm444 -t $out/lib/systemd/system/ 'dev-hugepages\x2d1G.mount' + install -Dm555 -t $out/libexec/ "hugepages-setup.sh" + + runHook postInstall + ''; + + postFixup = '' + substituteInPlace "$out/lib/systemd/system/tenstorrent-hugepages.service" \ + --replace-fail "/opt/tenstorrent/bin/hugepages-setup.sh" "$out/libexec/hugepages-setup.sh" + + wrapProgram "$out/libexec/hugepages-setup.sh" \ + --prefix PATH : ${ + lib.makeBinPath [ + pciutils # for lspci + ] + } + ''; + + meta = { + homepage = "https://github.com/tenstorrent/tt-system-tools"; + license = lib.licenses.asl20; + platforms = lib.platforms.all; + }; +}