Skip to content

Commit

Permalink
Create Nix Flake
Browse files Browse the repository at this point in the history
Replacing `etc/shell.nix`, this is a [flake](https://nixos.wiki/wiki/Flakes) based on the OpenROAD Nix derivation used for OpenLane 2. With Nix installed with flakes enabled, getting an OpenROAD environment is as simple as typing `nix develop`.

Also fixes issue with versions of OpenROAD built in the dev environments failing to launch the GUI.

Signed-off-by: Mohamed Gaber <[email protected]>
  • Loading branch information
donn committed Aug 26, 2024
1 parent 1d99a9c commit 8afe983
Show file tree
Hide file tree
Showing 4 changed files with 201 additions and 51 deletions.
142 changes: 142 additions & 0 deletions default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,142 @@
###############################################################################
##
## BSD 3-Clause License
##
## Copyright (c) 2023-2024, Efabless Corporation
## All rights reserved.
##
## Redistribution and use in source and binary forms, with or without
## modification, are permitted provided that the following conditions are met:
##
## * Redistributions of source code must retain the above copyright notice, this
## list of conditions and the following disclaimer.
##
## * Redistributions in binary form must reproduce the above copyright notice,
## this list of conditions and the following disclaimer in the documentation
## and#or other materials provided with the distribution.
##
## * Neither the name of the copyright holder nor the names of its
## contributors may be used to endorse or promote products derived from
## this software without specific prior written permission.
##
## THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
## AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
## IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
## ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
## LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
## CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
## SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
## INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
## CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
## ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
## POSSIBILITY OF SUCH DAMAGE.
##
###############################################################################
{
lib,
clangStdenv,
fetchFromGitHub,
libsForQt5,
boost183,
eigen,
cudd,
ninja,
tcl,
python3,
readline,
tclreadline,
spdlog,
libffi,
llvmPackages,
lemon-graph,
or-tools,
glpk,
zlib,
clp,
cbc,
re2,
swig4,
pkg-config,
cmake,
gnumake,
flex,
bison,
clang-tools_14,
# or-tools
stdenv,
overrideSDK,
}: let
or-tools' =
(or-tools.override {
## Alligned alloc not available on the default SDK for x86_64-darwin (10.12!!)
stdenv =
if stdenv.isDarwin
then (overrideSDK stdenv "11.0")
else stdenv;
})
.overrideAttrs (finalAttrs: previousAttrs: {
# Based on https://github.com/google/or-tools/commit/af44f98dbeb905656b5a9fc664b5fdcffcbe1f60
# Stops CMake going haywire on reconfigures
postPatch =
previousAttrs.postPatch
+ ''
sed -Ei.bak 's/(NOT\s+\w+_FOUND\s+AND\s+)+//' cmake/ortoolsConfig.cmake.in
sed -Ei.bak 's/NOT absl_FOUND/NOT TARGET absl::base/' cmake/ortoolsConfig.cmake.in
'';
});
self = clangStdenv.mkDerivation (finalAttrs: {
name = "openroad";

src = ./.;

cmakeFlags = [
"-DTCL_LIBRARY=${tcl}/lib/libtcl${clangStdenv.hostPlatform.extensions.sharedLibrary}"
"-DTCL_HEADER=${tcl}/include/tcl.h"
"-DUSE_SYSTEM_BOOST:BOOL=ON"
"-DVERBOSE=1"
];

qt5Libs = [
libsForQt5.qt5.qtbase
libsForQt5.qt5.qtcharts
libsForQt5.qt5.qtsvg
libsForQt5.qt5.qtdeclarative
];

QT_PLUGIN_PATH = lib.makeSearchPathOutput "bin" "lib/qt-${libsForQt5.qt5.qtbase.version}/plugins" self.qt5Libs;

buildInputs = self.qt5Libs ++ [
boost183
eigen
cudd
tcl
python3
readline
tclreadline
spdlog
libffi
llvmPackages.openmp

lemon-graph
or-tools'
glpk
zlib
clp
cbc
re2
];

nativeBuildInputs = [
swig4
pkg-config
cmake
ninja
gnumake
flex
bison
libsForQt5.wrapQtAppsHook
clang-tools_14
];
});
in
self
51 changes: 0 additions & 51 deletions etc/shell.nix

This file was deleted.

27 changes: 27 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 32 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
# To get dependencies and build in a Nix environment:
# 1. Install Nix: https://github.com/DeterminateSystems/nix-installer
# 2. Invoke `nix develop` in your shell. First invocation will
# take around 5 minutes depending on your internet connection and
# CPU speed.
# 3. `cd build`
# 4. `cmake -G Ninja $cmakeFlags ..`
# 5. `ninja`
# 6. `wrapQtApp ./src/openroad`
{
inputs = {
nixpkgs.url = github:nixos/nixpkgs/nixos-24.05;
};

outputs = {nixpkgs, ...}: {
packages = nixpkgs.lib.genAttrs [
"x86_64-linux"
"aarch64-linux"
"x86_64-darwin"
"aarch64-darwin"
] (
system: let
pkgs = import nixpkgs {inherit system;};
self = {
openroad = (nixpkgs.lib.callPackageWith pkgs) ./default.nix {};
default = self.openroad;
};
in
self
);
};
}

0 comments on commit 8afe983

Please sign in to comment.