-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathflake.nix
139 lines (122 loc) · 4.63 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
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
{
description = "A collection of scripts for AMD/Xilinx Vitis/Vivado";
inputs = {
flake-utils.url = "github:numtide/flake-utils";
devshell.url = "github:numtide/devshell";
devshell.inputs.nixpkgs.follows = "nixpkgs";
devshell.inputs.flake-utils.follows = "flake-utils";
treefmt-nix.url = "github:numtide/treefmt-nix";
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = { self, nixpkgs, flake-utils, treefmt-nix, ... } @ inputs:
flake-utils.lib.eachSystem [ "x86_64-linux" ]
(system:
let
# checkout of the nixpkgs
pkgs = import nixpkgs {
inherit system;
config.allowUnfree = true;
overlays = [
# https://github.com/NixOS/nixpkgs/pull/42637
(final: prev: {
requireFile = args: (prev.requireFile args).overrideAttrs (_: { allowSubstitutes = true; });
})
self.overlays.default
inputs.devshell.overlays.default
];
};
treefmtEval = treefmt-nix.lib.evalModule pkgs ./treefmt.nix;
in
rec {
packages = {
xilinx-unified-unwraped = pkgs.xilinx-unified-unwrapped;
xilinx-unified = pkgs.xilinx-unified;
xilinx-unified-2023-1-unwraped = pkgs.xilinx-unified-unwrapped;
xilinx-unified-2023-1 = pkgs.xilinx-unified;
xilinx-vivado-2019-2-unwraped = pkgs.xilinx-vivado-2019-2-unwrapped;
xilinx-vivado-2019-2 = pkgs.xilinx-vivado-2019-2;
xilinx-fhs = pkgs.genXilinxFhs { runScript = ""; };
};
devShells.default = pkgs.devshell.mkShell {
imports = [ "${inputs.devshell}/extra/git/hooks.nix" ];
name = "xilinx-dev-shell";
packages = [
pkgs.coreutils
pkgs.glow
pkgs.python3
pkgs.unzip
pkgs.xilinx-vivado-2019-2
];
git.hooks = {
enable = true;
pre-commit.text = ''
nix flake check
'';
};
commands =
let
commandTemplate = command: ''
set +u
exec ${./.}/commands/${command} "''${@}"
'';
commands = {
create-project = "creates a new project based on a template";
store = "create a restore script for a given project";
restore = "restore a project using a generated restore script";
build-hw-config = "generate a hw config for given platform";
build-bootloader = "build the bootloader for a script";
jtag-boot = "deploy a firmware via jtag";
launch-picocom = "launch the picocom serial monitor";
};
in
[
{
name = "show-readme";
command = ''glow "$PRJ_ROOT/README.md"'';
help = "";
}
] ++ (pkgs.lib.mapAttrsToList
(name: help: {
inherit name help;
command = commandTemplate name;
})
commands);
};
# for `nix fmt`
formatter = treefmtEval.config.build.wrapper;
# for `nix flake check`
checks = {
formatting = treefmtEval.config.build.check self;
shellcheck = pkgs.runCommand "shellcheck" { nativeBuildInputs = [ pkgs.shellcheck ]; }
"cd ${./.} && shellcheck commands/*; touch $out";
};
# just add every package as a hydra job
hydraJobs = checks // packages // (
let
cc = pkgs.checkCommands;
in
{
# TODO all checks are defunct, as no .xsa is created
# check-commands-2019-2-coraz7 = cc {
# toolchain = pkgs.xilinx-vivado-2019-2;
# platform = "coraz7";
# };
# check-commands-2019-2-ultrascale = cc {
# toolchain = pkgs.xilinx-vivado-2019-2;
# platform = "ultrascale";
# };
# check-commands-2019-2-zerdboard = cc {
# toolchain = pkgs.xilinx-vivado-2019-2;
# platform = "zerdboard";
# };
# check-commands-2019-2-zynq7000 = cc {
# toolchain = pkgs.xilinx-vivado-2019-2;
# platform = "zynq7000";
# };
}
);
}
) // {
overlays.default = import ./overlay.nix;
};
}