forked from lowRISC/opentitan
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
146 lines (134 loc) · 5.67 KB
/
Copy pathflake.nix
File metadata and controls
146 lines (134 loc) · 5.67 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
# Copyright lowRISC contributors (OpenTitan project).
# Licensed under the Apache License, Version 2.0, see LICENSE for details.
# SPDX-License-Identifier: Apache-2.0
{
description = "OpenTitan EDA development environment";
inputs = {
# Pinned to nixos-26.05 to match lowrisc-nix and because that channel ships
# Verilator 5.048.
nixpkgs.url = "github:nixos/nixpkgs/nixos-26.05";
flake-utils.url = "github:numtide/flake-utils";
# uv2nix builds the Python environment straight from this repo's
# pyproject.toml + uv.lock
pyproject-nix = {
url = "github:nix-community/pyproject.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
uv2nix = {
url = "github:pyproject-nix/uv2nix";
inputs = {
pyproject-nix.follows = "pyproject-nix";
nixpkgs.follows = "nixpkgs";
};
};
pyproject-build-systems = {
url = "github:pyproject-nix/build-system-pkgs";
inputs = {
pyproject-nix.follows = "pyproject-nix";
uv2nix.follows = "uv2nix";
nixpkgs.follows = "nixpkgs";
};
};
# Provides mkEdaShell (the EDA devshell builder)
lowrisc-nix.url = "github:lowRISC/lowrisc-nix";
};
nixConfig = {
extra-substituters = ["https://nix-cache.lowrisc.org/public/"];
extra-trusted-public-keys = ["nix-cache.lowrisc.org-public-1:O6JLD0yXzaJDPiQW1meVu32JIDViuaPtGDfjlOopU7o="];
};
outputs = {
nixpkgs,
flake-utils,
pyproject-nix,
uv2nix,
pyproject-build-systems,
lowrisc-nix,
...
}:
flake-utils.lib.eachDefaultSystem (system: let
inherit (nixpkgs) lib;
pkgs = nixpkgs.legacyPackages.${system};
python = pkgs.python312;
# OpenTitan's Python environment, built from this repo's own pyproject.toml
# + uv.lock. It bundles fusesoc and dvsim along with every other OpenTitan
# Python dependency these are available on PATH inside the shell.
workspace = uv2nix.lib.workspace.loadWorkspace {workspaceRoot = ./.;};
# Prefer prebuilt wheels: they need no per-package build-system overrides
# and are auto-patchelfed by pyproject.nix, which avoids building native
# deps (rpds-py/libcst's Rust, libclang, ...) from source.
overlay = workspace.mkPyprojectOverlay {sourcePreference = "wheel";};
pythonSet = (pkgs.callPackage pyproject-nix.build.packages {inherit python;})
.overrideScope (
lib.composeManyExtensions [
pyproject-build-systems.overlays.default
overlay
# Declares build systems for the sdist-only stragglers (crcmod, ...).
# Inert for deps that resolve to a prebuilt wheel above.
(lowrisc-nix.lib.pyprojectOverrides {inherit pkgs;})
]
);
pythonEnv = pythonSet.mkVirtualEnv "opentitan-env" workspace.deps.default;
# Commercial EDA tool shell, built on lowrisc-nix's generic mkEdaShell.
# Enter with `nix develop .`. It execs into a hermetic FHS sandbox, so
# it is not direnv-loadable and must be entered explicitly.
#
# Tool install paths and license servers are supplied at *runtime* from the
# JSON file named by $LOWRISC_EDA_CONFIG (the flake only declares which
# vendor tools + versions are wanted); without that config the shell still
# works and just warns. See lowrisc-nix lib/README-eda.md.
eda = lowrisc-nix.lib.mkEdaShell {
inherit pkgs;
name = "opentitan-eda";
tools = builtins.fromJSON (builtins.readFile ./tool_data.json);
# OpenTitan Python env (fusesoc, dvsim, ...) plus the open-source tools
# that ship in nixpkgs.
extraDeps = [pythonEnv];
extraPkgs = [
# Pinned via lowrisc-nix rather than nixpkgs directly, so a future
# nixpkgs bump can't silently drift the devshell's tool versions.
lowrisc-nix.packages.${system}.verilator_5_048
lowrisc-nix.packages.${system}.verible_0_0_4080
# Bazel pinned to match .bazelversion (8.7.0). With this on PATH,
# ./bazelisk.sh uses it directly instead of downloading Bazel over the
# network, so the build is hermetic and reproducible. Keep this version
# in sync with .bazelversion (bazelisk falls back to downloading if
# they ever diverge).
lowrisc-nix.packages.${system}.bazel_8_7_0
# OpenSSL headers + libcrypto for the AES DPI model (hw/ip/aes/model:
# crypto.c includes <openssl/*.h> and links -lcrypto).
pkgs.openssl
# srec_cat, invoked by rules/opentitan/transform.bzl to convert build
# artifacts (e.g. SW images -> SREC/VMEM).
pkgs.srecord
# xxd, invoked by rules/opentitan/cc.bzl (`... | xxd -r -p`) during the
# SW image build.
pkgs.unixtools.xxd
# lcov/genhtml, used by util/coverage to collect and render SW (C/C++)
# coverage.
pkgs.lcov
# Hardware-interaction libs/tools used by opentitantool and
# FPGA/chip bring-up (JTAG, USB, smartcard, serial xmodem/zmodem).
pkgs.libftdi1
pkgs.libusb1
pkgs.pcsclite
pkgs.dfu-util
pkgs.lrzsz
];
};
in {
packages.pythonEnv = pythonEnv;
devShells = {
inherit eda;
default = eda;
};
# `nix run .#eda` drops into the EDA sandbox in your $SHELL; with args,
# `nix run .#eda -- <cmd> <args>` execs them inside the sandbox (argv is
# passed through directly, so use e.g. `-- bash -c '...'` for a shell
# snippet). mkEdaShell exposes the ready-made flake-app payload as `eda.app`.
apps = {
eda = eda.app;
default = eda.app;
};
formatter = pkgs.alejandra;
});
}