Add a flake.nix to replace our current dev environment
This commit is contained in:
parent
3e2aaea218
commit
9622dc8382
|
@ -129,19 +129,11 @@ if(CMAKE_PROJECT_NAME STREQUAL PROJECT_NAME)
|
|||
endif()
|
||||
endif()
|
||||
|
||||
Include(FetchContent)
|
||||
|
||||
if(SERENE_BUILD_TESTING)
|
||||
message(STATUS "Fetching google test...")
|
||||
FetchContent_Declare(
|
||||
googletest
|
||||
URL https://github.com/google/googletest/archive/refs/tags/v1.14.0.tar.gz
|
||||
DOWNLOAD_EXTRACT_TIMESTAMP ON
|
||||
)
|
||||
|
||||
enable_testing()
|
||||
find_package(GTest REQUIRED)
|
||||
# For Windows: Prevent overriding the parent project's compiler/linker settings
|
||||
set(gtest_force_shared_crt ON CACHE BOOL "" FORCE)
|
||||
FetchContent_MakeAvailable(googletest)
|
||||
endif()
|
||||
|
||||
# LLVM setup ==================================================================
|
||||
|
|
4
builder
4
builder
|
@ -151,10 +151,8 @@ function popd_build() {
|
|||
|
||||
function build-gen() {
|
||||
local args
|
||||
setup_toolchain
|
||||
#setup_toolchain
|
||||
args=(
|
||||
"-DSERENE_TOOLCHAIN_PATH=$SERENE_TOOLCHAIN_PATH"
|
||||
"-DCMAKE_TOOLCHAIN_FILE=$ME/cmake/toolchains/x86_64-linux-musl.cmake"
|
||||
"-C"
|
||||
"$ME/cmake/caches/$1.cmake"
|
||||
)
|
||||
|
|
|
@ -0,0 +1,59 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1694529238,
|
||||
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"dirtyRev": "aa8d093e3bede559e5681ca69aa05e6e1ad4ee9a-dirty",
|
||||
"dirtyShortRev": "aa8d093e3bed-dirty",
|
||||
"lastModified": 1700918627,
|
||||
"narHash": "sha256-gcbm/2a4Hp4k2dpOl33hGARAiHMHH5HKyCSkzRGhpLQ=",
|
||||
"type": "git",
|
||||
"url": "file:///home/lxsameer/src/nixpkgs"
|
||||
},
|
||||
"original": {
|
||||
"type": "git",
|
||||
"url": "file:///home/lxsameer/src/nixpkgs"
|
||||
}
|
||||
},
|
||||
"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
|
||||
}
|
|
@ -0,0 +1,136 @@
|
|||
{
|
||||
description = "Serene programming language";
|
||||
|
||||
inputs.nixpkgs.url = "/home/lxsameer/src/nixpkgs/";
|
||||
inputs.flake-utils.url = "github:numtide/flake-utils";
|
||||
|
||||
outputs = inputs@{ self, nixpkgs, flake-utils, ... }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
llvm = {
|
||||
url = "https://devheroes.codes/Serene/llvm-project.git";
|
||||
major = "16";
|
||||
version = "16.0.6";
|
||||
rev = "b2c0361bcc08afdf466a605a23924bcd64fa2b86";
|
||||
hash = "sha256-wUKHwWYYlKa0v5zEJXxndleYtK7wzJKi0vqr3lNkGMI=";
|
||||
rev-version = "17-disable-shared-1";
|
||||
};
|
||||
|
||||
overlays = [
|
||||
(self: super:
|
||||
{
|
||||
serene_toolchain = (super.callPackage (super.path + "/pkgs/development/compilers/llvm/${llvm.major}") ({
|
||||
inherit (super.stdenvAdapters) overrideCC;
|
||||
buildLlvmTools = super.buildPackages.serene_toolchain.tools;
|
||||
targetLlvmLibraries = self.targetPackages.serene_toolchain.libraries or self.serene_toolchain.libraries;
|
||||
targetLlvm = self.targetPackages.serene_toolchain.llvm or self.serene_toolchain.llvm;
|
||||
monorepoSrc = super.fetchgit {
|
||||
url = llvm.url;
|
||||
rev = llvm.rev;
|
||||
hash = llvm.hash;
|
||||
};
|
||||
officialRelease = null;
|
||||
gitRelease = {
|
||||
version = llvm.version;
|
||||
rev = llvm.rev;
|
||||
rev-version = llvm.rev-version;
|
||||
};
|
||||
}));
|
||||
})
|
||||
(final: prev: {
|
||||
cpio = prev.cpio.overrideAttrs (old: {
|
||||
patches = [
|
||||
./patches/0001-configure-Include-needed-header-for-major-minor-macr.patch
|
||||
];
|
||||
nativeBuildInputs = [ prev.autoreconfHook ];
|
||||
NIX_CFLAGS_COMPILE = "-Wno-implicit-function-declaration";
|
||||
});
|
||||
|
||||
libedit = prev.libedit.overrideAttrs (old: {
|
||||
# Musl is ISO 10646 compliant but doesn't define __STDC_ISO_10646__ we need to do it ourselves
|
||||
NIX_CFLAGS_COMPILE = "-D__STDC_ISO_10646__=201103L";
|
||||
});
|
||||
|
||||
elfutils = prev.elfutils.overrideAttrs (old: {
|
||||
# libcxx does not have __cxa_demangle
|
||||
configureFlags = old.configureFlags ++ [ "--disable-demangler" ];
|
||||
});
|
||||
|
||||
ccache = prev.ccache.overrideAttrs (old: {
|
||||
nativeBuildInputs = old.nativeBuildInputs ++ [ final.elfutils ];
|
||||
});
|
||||
|
||||
# We don't need systemd at all
|
||||
util-linux = prev.util-linux.override { systemdSupport = false; };
|
||||
})
|
||||
];
|
||||
|
||||
get_pkgs = system:
|
||||
if system == "x86_64-linux"
|
||||
then import nixpkgs {
|
||||
inherit system overlays;
|
||||
crossSystem = nixpkgs.lib.systems.examples.musl64 // { useLLVM = true; };
|
||||
config.replaceCrossStdenv = { buildPackages, baseStdenv }:
|
||||
buildPackages.stdenvAdapters.overrideCC baseStdenv buildPackages.llvmPackages_16.clangUseLLVM;
|
||||
}
|
||||
else import nixpkgs {
|
||||
inherit system overlays;
|
||||
};
|
||||
|
||||
|
||||
pkgs = get_pkgs system;
|
||||
|
||||
#with pkgs;
|
||||
native_build_inputs =
|
||||
let
|
||||
git' = pkgs.git.overrideAttrs (old: {
|
||||
preInstallCheck =
|
||||
pkgs.lib.replaceStrings [ ''disable_test t0201-gettext-fallbacks'' ]
|
||||
[ ''
|
||||
disable_test t0201-gettext-fallbacks
|
||||
disable_test t2082-parallel-checkout-attributes
|
||||
'' ]
|
||||
old.preInstallCheck;
|
||||
});
|
||||
in with pkgs; [
|
||||
cmake
|
||||
ninja
|
||||
ccache
|
||||
# serene_toolchain.lldb
|
||||
# serene_toolchain.lld
|
||||
# serene_toolchain.libcxx
|
||||
# serene_toolchain.libcxxabi
|
||||
# serene_toolchain.compiler-rt
|
||||
git'
|
||||
zsh
|
||||
python3
|
||||
];
|
||||
|
||||
build_inputs = with pkgs; [
|
||||
boehmgc
|
||||
# llvm_16
|
||||
gtest
|
||||
gmock
|
||||
# zlib-ng
|
||||
# zstd
|
||||
include-what-you-use
|
||||
];
|
||||
|
||||
in {
|
||||
inherit pkgs;
|
||||
devShells.default = pkgs.mkShell {
|
||||
nativeBuildInputs = native_build_inputs;
|
||||
buildInputs = build_inputs;
|
||||
shellHook = ''zsh --norcs && exit'';
|
||||
};
|
||||
|
||||
packages.cmake = pkgs.cmake;
|
||||
packages.blah = pkgs.stdenv.mkDerivation {
|
||||
pname = "blah";
|
||||
version = "0.1";
|
||||
nativeBuildInputs = native_build_inputs;
|
||||
buildInputs = build_inputs;
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
Loading…
Reference in New Issue