Add a default.nix and a flake file to replace the conan stuff

This commit is contained in:
Sameer Rahmani 2023-09-02 19:12:06 +01:00
parent 17728ee4ae
commit 03794fde6a
Signed by: lxsameer
GPG Key ID: B0A4AF28AB9FD90B
8 changed files with 68 additions and 25 deletions

32
default.nix Normal file
View File

@ -0,0 +1,32 @@
{
nixPkgsVersion ? "3e52e76b70d5508f3cec70b882a29199f4d1ee85"
}:
let
getNixPkgs = args: import (builtins.fetchGit {
name = "nixpkg-serene-${nixPkgsVersion}";
url = "https://github.com/nixos/nixpkgs/";
# Commit hash for nixos-unstable as of 2018-09-12
# `git ls-remote https://github.com/nixos/nixpkgs nixos-unstable`
ref = "refs/heads/nixos-unstable";
rev = nixPkgsVersion;
}) args;
nixpkgs = getNixPkgs {};
system = import ./system.nix { pkgs = nixpkgs; };
staticMuslPkgs = getNixPkgs system;
llvm = staticMuslPkgs.llvmPackages_16.override { stdenv = staticMuslPkgs.llvmPackages_16.libcxxClang; };
SereneOverlay = final: prev:
{
sereneToolchain = llvm.libcxxClang;
};
createPkgSet = _: # It has to be the nixpkgs instance
getNixPkgs (system // { overlays = [ SereneOverlay ]; });
#pkgs = getNixPkgs nixVersion (system // { overlays = [ libcxxClangOverlay ]; });
in {
inherit SereneOverlay createPkgSet;
# setupToolchain = nixpkgs:
#pkgs.stdenv.override { stdenv = llvm.libcxxClang; };
}

13
flake.nix Normal file
View File

@ -0,0 +1,13 @@
{
description = "Serene Toolchain";
outputs = inputs:
let
toolchain = import ./.;
in
{
inherit toolchain;
};
}

View File

@ -52,7 +52,8 @@ class Cmake(ConanFile):
cmake = CMake(self)
flags = with_static_flags(
{
"CMAKE_USE_OPENSSL": "OFF",
"CMAKE_USE_OPENSSL": "ON",
"OPENSSL_USE_STATIC_LIBS": "ON",
"BUILD_TESTING": "OFF",
}
)

21
system.nix Normal file
View File

@ -0,0 +1,21 @@
{ pkgs }:
let
parsedSystem = builtins.split "-" builtins.currentSystem;
arch = builtins.head (parsedSystem);
os = builtins.elemAt (parsedSystem) 2;
system = pkgs.lib.systems.elaborate {
system = builtins.currentSystem;
config = "${arch}-unknown-linux-musl";
isStatic = true;
useLLVM = true;
linker = "lld";
};
args = if os != "linux" then {}
else {
localSystem = system;
crossSystem = system;
};
in args

Binary file not shown.

View File

@ -1,3 +0,0 @@
# ninja log v5
0 0 1683492538462869278 main 6157dd645b7b0062
0 0 1683492538462869278 main-static 92a52c8bbfaceaad

View File

@ -1,10 +0,0 @@
cxxflags = -Wall -fuse-ld=lld --sysroot /sysroot
rule cc
command = clang++ $cxxflags -c $in -o $out
rule static-cc
command = clang++ $cxxflags -c $in -o $out
build main: cc main.cpp
build main-static: static-cc main.cpp

View File

@ -1,11 +0,0 @@
#include <stdio.h>
#include <string>
#include <memory>
#include <iostream>
int main() {
auto a = std::make_unique<std::string>("boooo");
printf("test_1\n");
std::cout << *a << "\n";
return 0;
}