2024-01-31 05:20:40 +00:00
|
|
|
{
|
|
|
|
description = "Tenstorrent software stack.";
|
|
|
|
|
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
|
2024-10-01 18:45:13 +00:00
|
|
|
utils.url = "github:numtide/flake-utils";
|
2024-10-01 20:56:48 +00:00
|
|
|
flake-compat = {
|
|
|
|
url = "github:edolstra/flake-compat";
|
|
|
|
flake = false;
|
|
|
|
};
|
2024-01-31 05:20:40 +00:00
|
|
|
};
|
|
|
|
|
2024-10-01 18:41:35 +00:00
|
|
|
outputs =
|
2024-10-01 18:45:13 +00:00
|
|
|
inputs:
|
2024-10-01 18:41:35 +00:00
|
|
|
let
|
2024-10-01 18:45:13 +00:00
|
|
|
inherit (inputs) self;
|
|
|
|
inherit (inputs.nixpkgs) lib;
|
2024-10-01 18:41:35 +00:00
|
|
|
in
|
2024-10-01 18:45:13 +00:00
|
|
|
inputs.utils.lib.eachDefaultSystem (
|
|
|
|
system:
|
|
|
|
let
|
|
|
|
pkgs = inputs.nixpkgs.legacyPackages.${system};
|
2024-10-01 21:06:25 +00:00
|
|
|
scope = lib.makeScope pkgs.newScope (
|
|
|
|
self:
|
|
|
|
let
|
|
|
|
inherit (self) callPackage;
|
2024-10-03 23:52:00 +00:00
|
|
|
# so `kmd.kmd` gets its own `.override`
|
|
|
|
callPackages = lib.callPackagesWith (pkgs // self);
|
2024-10-14 00:17:41 +00:00
|
|
|
kernel = pkgs.linux_latest;
|
2024-10-01 21:06:25 +00:00
|
|
|
in
|
|
|
|
{
|
2024-10-14 00:17:41 +00:00
|
|
|
kmd = callPackages ./pkgs/kmd { inherit kernel; };
|
2024-10-07 14:51:52 +00:00
|
|
|
sfpi = callPackages ./pkgs/sfpi { };
|
2025-01-29 17:03:14 +00:00
|
|
|
luwen = (callPackage ./pkgs/luwen { }).luwen;
|
|
|
|
pyluwen = (callPackage ./pkgs/luwen { }).pyluwen;
|
2024-10-01 21:13:25 +00:00
|
|
|
tools-common = callPackage ./pkgs/tools-common { };
|
2024-10-14 00:08:50 +00:00
|
|
|
system-tools = callPackage ./pkgs/system-tools { };
|
2025-01-29 17:03:14 +00:00
|
|
|
flash = callPackage ./pkgs/flash { };
|
|
|
|
smi = callPackage ./pkgs/smi { };
|
2024-10-01 21:06:25 +00:00
|
|
|
umd = callPackage ./pkgs/umd { };
|
2024-10-07 14:51:52 +00:00
|
|
|
metal = callPackage ./pkgs/metal { };
|
2024-10-01 21:06:25 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
);
|
2024-10-01 18:45:13 +00:00
|
|
|
in
|
|
|
|
{
|
|
|
|
packages = {
|
2024-10-01 21:06:25 +00:00
|
|
|
kmd = scope.kmd.kmd;
|
|
|
|
udev-rules = scope.kmd.udev-rules;
|
|
|
|
kmd-test = scope.kmd.test;
|
|
|
|
sfpi = scope.sfpi.sfpi;
|
2024-12-17 19:39:41 +00:00
|
|
|
sfpi-prebuilt = scope.sfpi.prebuilt;
|
2024-10-01 21:06:25 +00:00
|
|
|
tt-gcc = scope.sfpi.tt-gcc;
|
|
|
|
smi = scope.smi;
|
2025-01-29 17:03:14 +00:00
|
|
|
luwen = scope.luwen;
|
|
|
|
pyluwen = scope.pyluwen;
|
2024-10-01 21:13:25 +00:00
|
|
|
tools-common = scope.tools-common;
|
2024-10-14 00:08:50 +00:00
|
|
|
system-tools = scope.system-tools;
|
2024-10-01 21:06:25 +00:00
|
|
|
flash = scope.flash;
|
|
|
|
umd = scope.umd;
|
2024-10-07 14:51:52 +00:00
|
|
|
metal = scope.metal;
|
2024-10-01 18:45:13 +00:00
|
|
|
default = self.packages.${system}.smi;
|
|
|
|
};
|
2024-01-31 05:20:40 +00:00
|
|
|
|
2024-10-01 19:46:35 +00:00
|
|
|
checks = {
|
|
|
|
simple =
|
|
|
|
pkgs.runCommand "test"
|
|
|
|
{
|
|
|
|
# Goes up to 7
|
|
|
|
NIX_DEBUG = 0;
|
|
|
|
}
|
|
|
|
''
|
|
|
|
mkdir -p $out
|
|
|
|
${self.packages.${system}.tt-gcc}/bin/riscv32-unknown-elf-gcc ${./tests/test.c} -o $out/test
|
|
|
|
${self.packages.${system}.tt-gcc}/bin/riscv32-unknown-elf-gcc -mblackhole ${./tests/test.c} -o $out/test-wormhole
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2024-10-01 18:45:13 +00:00
|
|
|
formatter = pkgs.nixfmt-rfc-style;
|
|
|
|
}
|
2024-10-14 00:31:44 +00:00
|
|
|
)
|
|
|
|
// {
|
|
|
|
# TODO: Add overlay
|
|
|
|
nixosModules = {
|
|
|
|
tt-module =
|
|
|
|
{ config, pkgs, ... }:
|
|
|
|
{
|
|
|
|
boot = {
|
|
|
|
extraModulePackages = [
|
|
|
|
((pkgs.tt-kmd or self.packages.${pkgs.hostPlatform.system}.kmd).override {
|
|
|
|
kernel = config.boot.kernelPackages.kernel;
|
|
|
|
})
|
|
|
|
];
|
|
|
|
kernelParams = [
|
|
|
|
"iommu=pt"
|
|
|
|
];
|
|
|
|
kernelModules = [ "tenstorrent" ];
|
|
|
|
};
|
2024-11-20 21:39:52 +00:00
|
|
|
systemd = {
|
|
|
|
# https://github.com/NixOS/nixpkgs/issues/81138
|
|
|
|
services.tenstorrent-hugepages.wantedBy = [ "sysinit.target" ];
|
2024-11-20 23:06:03 +00:00
|
|
|
# Define https://github.com/tenstorrent/tt-system-tools/blob/29ba4dc6049eef3cee4314c53720417823ffc667/dev-hugepages%5Cx2d1G.mount
|
|
|
|
# because it has bad start ordering relations with tenstorrent-hugepages.service
|
|
|
|
# or it may be that the `wantedBy` does not work correctly in mounts like it does't work in serices.
|
|
|
|
mounts = [
|
|
|
|
{
|
|
|
|
description = "Mount hugepages at /dev/hugepages-1G for Tenstorrent ASICs";
|
|
|
|
what = "hugetlbfs";
|
|
|
|
where = "/dev/hugepages-1G";
|
|
|
|
type = "hugetlbfs";
|
|
|
|
options = "pagesize=1G,mode=0777,nosuid,nodev";
|
|
|
|
wantedBy = [ "sysinit.target" ];
|
|
|
|
after = [ "tenstorrent-hugepages.service" ];
|
|
|
|
unitConfig = {
|
|
|
|
DefaultDependencies = false;
|
|
|
|
ConditionPathExists = "/sys/kernel/mm/hugepages/hugepages-1048576kB";
|
|
|
|
ConditionCapability = "CAP_SYS_ADMIN";
|
|
|
|
};
|
|
|
|
}
|
|
|
|
];
|
2024-11-20 21:39:52 +00:00
|
|
|
packages = [
|
|
|
|
(pkgs.tt-system-tools or self.packages.${pkgs.hostPlatform.system}.system-tools)
|
|
|
|
];
|
|
|
|
};
|
2024-11-20 22:23:56 +00:00
|
|
|
services.udev = {
|
2024-11-20 22:52:35 +00:00
|
|
|
packages = [ (pkgs.tt-udev-rules or self.packages.${pkgs.hostPlatform.system}.udev-rules) ];
|
|
|
|
# NOTE: passing just the group does not work currently for docker so unneeded for now so use the udev-rules package for now
|
|
|
|
# TT_METAL_HOME=$PWD docker run -v $PWD:/host --workdir /host -v /dev/hugepages-1G:/dev/hugepages-1G -v /dev/tenstorrent:/dev/tenstorrent -u :994 -v /etc/group:/etc/group:ro -it tt-metal bash
|
|
|
|
# extraRules = ''
|
|
|
|
# KERNEL=="tenstorrent*", MODE="0666", OWNER="root", GROUP="tenstorrent"
|
|
|
|
# '';
|
2024-11-20 22:23:56 +00:00
|
|
|
};
|
2024-11-20 22:52:35 +00:00
|
|
|
# users.groups.tenstorrent = { };
|
2024-10-14 00:31:44 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
};
|
2024-01-31 05:20:40 +00:00
|
|
|
}
|