Skip to content

Commit 6ff89a2

Browse files
committed
flake: added package
1 parent 479625b commit 6ff89a2

File tree

3 files changed

+101
-7
lines changed

3 files changed

+101
-7
lines changed

flake.nix

Lines changed: 95 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,19 @@
66
flake-utils.url = "github:numtide/flake-utils";
77
};
88

9-
outputs = { self, nixpkgs, flake-utils }:
9+
outputs = { self, nixpkgs, flake-utils } @inputs:
1010
flake-utils.lib.eachDefaultSystem (system:
1111
let
1212
pkgs = import nixpkgs {
1313
inherit system;
1414
};
15+
common = with pkgs; {
16+
bazel = bazel_7;
17+
jdk = jdk;
18+
};
1519
in {
1620
devShells.default =
1721
let
18-
bazel = pkgs.bazel_7;
19-
2022
# There is too much volatility between even micro-versions of
2123
# newer clang-format. Use slightly older version for now.
2224
clang_for_formatting = pkgs.llvmPackages_17.clang-tools;
@@ -26,8 +28,8 @@
2628
in with pkgs; pkgs.mkShell{
2729
packages = with pkgs; [
2830
git
29-
bazel
30-
jdk
31+
common.bazel
32+
common.jdk
3133
bash
3234
gdb
3335

@@ -51,7 +53,95 @@
5153

5254
CLANG_TIDY="${clang_for_tidy}/bin/clang-tidy";
5355
CLANG_FORMAT="${clang_for_formatting}/bin/clang-format";
56+
57+
shellHook = ''
58+
exec bash
59+
'';
5460
};
61+
62+
# Package fpga-assembler.
63+
packages.default = (pkgs.callPackage (
64+
{
65+
buildBazelPackage,
66+
stdenv,
67+
fetchFromGitHub,
68+
lib,
69+
nix-gitignore,
70+
}:
71+
let
72+
system = stdenv.hostPlatform.system;
73+
registry = fetchFromGitHub {
74+
owner = "bazelbuild";
75+
repo = "bazel-central-registry";
76+
rev = "63f3af762b2fdd7acaa7987856cd3ac314eaea09";
77+
hash = "sha256-ugNzoP0gdrhl9vH1TRdwoevuTsSqjitXnAoMSSTlCgI=";
78+
};
79+
in
80+
buildBazelPackage {
81+
pname = "fpga-as";
82+
83+
version = "0.0.1";
84+
85+
src = nix-gitignore.gitignoreSourcePure [] ./.;
86+
87+
bazelFlags = [
88+
"--registry"
89+
"file://${registry}"
90+
];
91+
92+
postPatch = ''
93+
patchShebangs scripts/create-workspace-status.sh
94+
'';
95+
96+
fetchAttrs = {
97+
hash =
98+
{
99+
aarch64-linux = "sha256-E4VHjDa0qkHmKUNpTBfJi7dhMLcd1z5he+p31/XvUl8=";
100+
x86_64-linux = "sha256-hVBJB0Hsd9sXuEoNcjhTkbPl89vlZT1w39JppCD+n8Y=";
101+
}
102+
.${system} or (throw "No hash for system: ${system}");
103+
};
104+
105+
removeRulesCC = false;
106+
removeLocalConfigCc = false;
107+
removeLocalConfigSh = false;
108+
109+
nativeBuildInputs = [
110+
common.jdk
111+
pkgs.git
112+
pkgs.bash
113+
# Convenient tool to enter into the sandbox and start debugging.
114+
pkgs.breakpointHook
115+
];
116+
117+
bazel = common.bazel;
118+
119+
bazelBuildFlags = [ "-c opt" ];
120+
bazelTestTargets = [ "//..." ];
121+
bazelTargets = [ "//fpga:fpga-as" ];
122+
123+
buildAttrs = {
124+
installPhase = ''
125+
install -D --strip bazel-bin/fpga/fpga-as "$out/bin/fpga-as"
126+
'';
127+
};
128+
129+
meta = {
130+
description = "Tool to convert FASM to FPGA bitstream.";
131+
homepage = "https://github.com/lromor/fpga-assembler";
132+
license = lib.licenses.asl20;
133+
platforms = lib.platforms.linux;
134+
};
135+
}
136+
) {}).overrideAttrs (final: prev: {
137+
# Fixup the deps so they always contain correrct
138+
# shebangs paths pointing to the store.
139+
deps = prev.deps.overrideAttrs (final: prev: {
140+
installPhase = ''
141+
patchShebangs $bazelOut/external
142+
'' + prev.installPhase;
143+
});
144+
});
55145
}
56146
);
57147
}

fpga/BUILD

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ package(
99
license(
1010
name = "license",
1111
package_name = "fpga",
12-
license_kind = "@rules_license//licenses/spdx:Apache-2.0",
12+
license_kinds = [
13+
"@rules_license//licenses/spdx:Apache-2.0",
14+
],
1315
)
1416

1517
cc_library(

fpga/xilinx/BUILD

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,9 @@ package(
99
license(
1010
name = "license",
1111
package_name = "xilinx",
12-
license_kind = "@rules_license//licenses/spdx:ISC",
12+
license_kinds = [
13+
"@rules_license//licenses/spdx:ISC"
14+
],
1315
)
1416

1517
cc_library(

0 commit comments

Comments
 (0)