-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
87 lines (79 loc) · 2.54 KB
/
flake.nix
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
# SPDX-FileCopyrightText: lowRISC contributors
# SPDX-License-Identifier: Apache-2.0
# SPDX-FileContributor: Hugo McNally
{
description = "FuseSoC Prim Lib Examples";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
poetry2nix = {
url = "github:nix-community/poetry2nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
};
outputs = {
self,
nixpkgs,
flake-utils,
poetry2nix,
} @ inputs: let
system_outputs = system: let
pkgs = import nixpkgs {inherit system;};
inherit (pkgs.lib) getExe;
pythonEnv = let
poetry2nix = inputs.poetry2nix.lib.mkPoetry2Nix {inherit pkgs;};
in
poetry2nix.mkPoetryEnv {
projectDir = ./.;
python = pkgs.python311;
overrides = [poetry2nix.defaultPoetryOverrides];
};
buildInputs = with pkgs; [libelf zlib];
nativeBuildInputs = with pkgs; [lychee reuse graphviz verilator pythonEnv];
lints = pkgs.stdenv.mkDerivation {
name = "fusesoc-examples-lints";
src = ./.;
inherit buildInputs nativeBuildInputs;
dontBuild = true;
doCheck = true;
PYTHONPATH=./python_plugins;
checkPhase = ''
HOME=$TMPDIR
echo Checking license headers...
reuse lint
echo Checking documentation links...
lychee --offline --no-progress --include-fragments .
echo Checking python quality...
ruff format --check
ruff check
echo Checking examples build and run...
prims_checks() {
fusesoc run --setup hugom:example:top
fusesoc run --flag not_prims_generic --flag prims_specific --setup hugom:example:top
fusesoc run --flag not_prims_generic --flag prims_secret hugom:example:top
}
pushd prims_lib/virtual_cores
prims_checks
popd
pushd prims_lib/filters
prims_checks
popd
'';
installPhase = "mkdir $out";
};
in {
formatter = pkgs.alejandra;
devShells.default = pkgs.mkShell {
name = "prim-lib-examples";
inherit buildInputs nativeBuildInputs;
shellHook = ''
export REPO_ROOT="$(${getExe pkgs.git} rev-parse --show-toplevel)"
export PYTHONPATH="$REPO_ROOT/python_plugins";
'';
};
checks = {inherit lints;};
};
in
flake-utils.lib.eachDefaultSystem system_outputs;
}