From 1c89e2ab92d5786dfa2ead8ba1c0f822697c5a24 Mon Sep 17 00:00:00 2001 From: Roland Coeurjoly Date: Wed, 8 May 2024 03:52:12 +0200 Subject: [PATCH] Add nix flake and lock file. Add nix build step. Pending nix flake update step --- .github/workflows/nix-github-actions.yml | 13 +++++ flake.lock | 61 ++++++++++++++++++++++++ flake.nix | 44 +++++++++++++++++ 3 files changed, 118 insertions(+) create mode 100644 .github/workflows/nix-github-actions.yml create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.github/workflows/nix-github-actions.yml b/.github/workflows/nix-github-actions.yml new file mode 100644 index 000000000..a11584bc6 --- /dev/null +++ b/.github/workflows/nix-github-actions.yml @@ -0,0 +1,13 @@ +name: "build nix flake" +on: + pull_request: + push: +jobs: + tests: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + submodules: true + - uses: cachix/install-nix-action@v25 + - run: nix build '.?submodules=1' diff --git a/flake.lock b/flake.lock new file mode 100644 index 000000000..2545f4ce0 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1705309234, + "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1708807242, + "narHash": "sha256-sRTRkhMD4delO/hPxxi+XwLqPn8BuUq6nnj4JqLwOu0=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "73de017ef2d18a04ac4bfd0c02650007ccb31c2a", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 000000000..1143d538c --- /dev/null +++ b/flake.nix @@ -0,0 +1,44 @@ +{ + description = "A nix flake for the Yosys synthesis suite"; + + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + flake-utils.url = "github:numtide/flake-utils"; + }; + + outputs = { self, nixpkgs, flake-utils }: + flake-utils.lib.eachDefaultSystem (system: + let + pkgs = import nixpkgs { + inherit system; + }; + customYosys = pkgs.clangStdenv.mkDerivation { + name = "yosys"; + src = ./. ; + buildInputs = with pkgs; [ clang bison flex libffi tcl readline python3 llvmPackages.libcxxClang zlib git ]; + checkInputs = with pkgs; [ gtest ]; + propagatedBuildInputs = with pkgs; [ abc-verifier ]; + preConfigure = "make config-clang"; + checkTarget = "test"; + installPhase = '' + make install PREFIX=$out + ''; + buildPhase = '' + make -j$(nproc) + ''; + meta = with pkgs.lib; { + description = "Yosys Open SYnthesis Suite"; + homepage = "https://yosyshq.net/yosys/"; + license = licenses.isc; + maintainers = with maintainers; [ ]; + }; + }; + in { + packages.default = customYosys; + defaultPackage = customYosys; + devShell = pkgs.mkShell { + buildInputs = with pkgs; [ clang bison flex libffi tcl readline python3 llvmPackages.libcxxClang zlib git gtest abc-verifier ]; + }; + } + ); +}