Skip to content

Commit d2586e2

Browse files
Merge pull request #4238 from RCoeurjoly/nix
Begin supporting nix flakes build system
2 parents e940d24 + 13a6920 commit d2586e2

File tree

5 files changed

+146
-0
lines changed

5 files changed

+146
-0
lines changed
+15
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
name: "build nix flake"
2+
on:
3+
pull_request:
4+
push:
5+
jobs:
6+
tests:
7+
runs-on: ubuntu-latest
8+
steps:
9+
- uses: actions/checkout@v4
10+
with:
11+
submodules: true
12+
- uses: cachix/install-nix-action@v26
13+
with:
14+
install_url: https://releases.nixos.org/nix/nix-2.18.1/install
15+
- run: nix build .?submodules=1
+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: update-flake-lock
2+
on:
3+
workflow_dispatch: # allows manual triggering
4+
schedule:
5+
- cron: '0 0 * * 0' # runs weekly on Sunday at 00:00
6+
7+
jobs:
8+
lockfile:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout repository
12+
uses: actions/checkout@v4
13+
- name: Install Nix
14+
uses: DeterminateSystems/nix-installer-action@main
15+
- name: Update flake.lock
16+
uses: DeterminateSystems/update-flake-lock@main
17+
with:
18+
pr-title: "Update flake.lock" # Title of PR to be created
19+
pr-labels: | # Labels to be set on the PR
20+
dependencies
21+
automated

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,4 @@ __pycache__
4545
/tests/unit/bintest/
4646
/tests/unit/objtest/
4747
/tests/ystests
48+
/result

flake.lock

+61
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

flake.nix

+48
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
{
2+
description = "A nix flake for the Yosys synthesis suite";
3+
4+
inputs = {
5+
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
6+
flake-utils.url = "github:numtide/flake-utils";
7+
};
8+
9+
outputs = { self, nixpkgs, flake-utils }:
10+
flake-utils.lib.eachDefaultSystem (system:
11+
let
12+
pkgs = import nixpkgs {
13+
inherit system;
14+
};
15+
# TODO: don't override src when ./abc is empty
16+
# which happens when the command used is `nix build` and not `nix build ?submodules=1`
17+
abc-verifier = pkgs.abc-verifier.overrideAttrs(x: y: {src = ./abc;});
18+
yosys = pkgs.clangStdenv.mkDerivation {
19+
name = "yosys";
20+
src = ./. ;
21+
buildInputs = with pkgs; [ clang bison flex libffi tcl readline python3 llvmPackages.libcxxClang zlib git pkg-configUpstream ];
22+
checkInputs = with pkgs; [ gtest ];
23+
propagatedBuildInputs = [ abc-verifier ];
24+
preConfigure = "make config-clang";
25+
checkTarget = "test";
26+
installPhase = ''
27+
make install PREFIX=$out ABCEXTERNAL=yosys-abc
28+
ln -s ${abc-verifier}/bin/abc $out/bin/yosys-abc
29+
'';
30+
buildPhase = ''
31+
make -j$(nproc) ABCEXTERNAL=yosys-abc
32+
'';
33+
meta = with pkgs.lib; {
34+
description = "Yosys Open SYnthesis Suite";
35+
homepage = "https://yosyshq.net/yosys/";
36+
license = licenses.isc;
37+
maintainers = with maintainers; [ ];
38+
};
39+
};
40+
in {
41+
packages.default = yosys;
42+
defaultPackage = yosys;
43+
devShell = pkgs.mkShell {
44+
buildInputs = with pkgs; [ clang bison flex libffi tcl readline python3 llvmPackages.libcxxClang zlib git gtest abc-verifier ];
45+
};
46+
}
47+
);
48+
}

0 commit comments

Comments
 (0)