210 lines
6.2 KiB
Nix
210 lines
6.2 KiB
Nix
# FeynmanDB
|
|
#
|
|
# Copyright (c) 2024 Sameer Rahmani <lxsameer@gnu.org>
|
|
#
|
|
# This program is free software; you can redistribute it and/or modify
|
|
# it under the terms of the GNU General Public License as published by
|
|
# the Free Software Foundation, version 2.
|
|
#
|
|
# This program is distributed in the hope that it will be useful,
|
|
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
# GNU General Public License for more details.
|
|
#
|
|
# You should have received a copy of the GNU General Public License
|
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
{
|
|
description = "A single user and local graph database";
|
|
|
|
inputs = {
|
|
#nixpkgs.url = "github:nixos/nixpkgs/442d407992384ed9c0e6d352de75b69079904e4e";
|
|
nixpkgs.url = "github:lxsameer/nixpkgs/e1f7865bce4d52d30dd1d61e79798ee2765cc2b0";
|
|
flake_utils.url = "github:numtide/flake-utils";
|
|
};
|
|
|
|
outputs = { self, nixpkgs, flake-utils, ... } @ inputs:
|
|
flake-utils.lib.eachDefaultSystem (system:
|
|
let
|
|
overlays = [
|
|
(final: prev: {
|
|
p11-kit = prev.p11-kit.overrideAttrs (old: {
|
|
patches = [
|
|
./nix/patches/p11-kit_skip_test.patch
|
|
];
|
|
});
|
|
|
|
cpio = prev.cpio.overrideAttrs (old: {
|
|
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; };
|
|
|
|
# libpam exmaples use glibc. We need to disable them
|
|
linux-pam = prev.linux-pam.overrideAttrs (old: {
|
|
postConfigure = ''
|
|
sed 's/examples//' -i Makefile
|
|
'';
|
|
});
|
|
|
|
#=============================================================
|
|
# Since we're using lld-17, and --no-undefined-version is the
|
|
# default in lld-17. We need to explicitely turn it off for
|
|
# these problematic packages untill they fix it upstream.
|
|
libgcrypt = prev.libgcrypt.overrideAttrs (old: {
|
|
NIX_LDFLAGS = if prev.stdenv.cc.isClang
|
|
then [ "--undefined-version" ]
|
|
else [];
|
|
});
|
|
libxcrypt = prev.libxcrypt.overrideAttrs (old: {
|
|
NIX_LDFLAGS = if prev.stdenv.cc.isClang
|
|
then [ "--undefined-version" ]
|
|
else [];
|
|
});
|
|
ncurses = prev.ncurses.overrideAttrs (old: {
|
|
NIX_LDFLAGS = if prev.stdenv.cc.isClang
|
|
then [ "--undefined-version" ]
|
|
else [];
|
|
});
|
|
|
|
libbsd = prev.libbsd.overrideAttrs (old: { #old.NIX_LDFLAGS ++
|
|
NIX_LDFLAGS = if prev.stdenv.cc.isClang
|
|
then [ "--undefined-version" ]
|
|
else [];
|
|
});
|
|
libidn2 = prev.libidn2.overrideAttrs (old: { #old.NIX_LDFLAGS ++
|
|
NIX_LDFLAGS = if prev.stdenv.cc.isClang
|
|
then [ "--undefined-version" ]
|
|
else [];
|
|
});
|
|
|
|
fmt = prev.fmt.overrideAttrs (old: {
|
|
doCheck = false;
|
|
});
|
|
|
|
# libapparmor = prev.libapparmor.overrideAttrs (old: {
|
|
# NIX_CFLAGS_COMPILE = "--no-"
|
|
# });
|
|
#==============================================================
|
|
|
|
iwyu = (prev.include-what-you-use.overrideAttrs (old:
|
|
let
|
|
version = "0.21";
|
|
in {
|
|
inherit version;
|
|
|
|
src = prev.fetchurl {
|
|
url = "${old.meta.homepage}/downloads/${old.pname}-${version}.src.tar.gz";
|
|
hash = "sha256-ajUZGf+JvafJXIlUcmAYaNs9qrlqlYs44DYokNWHYLY=";
|
|
};
|
|
cmakeFlags = [ "-DCMAKE_PREFIX_PATH=${prev.llvmPackages_17.llvm.dev}" ];
|
|
|
|
})).override {
|
|
llvmPackages = prev.__splicedPackages.llvmPackages_17;
|
|
};
|
|
})
|
|
];
|
|
|
|
get_pkgs = overlays:
|
|
if system == "x86_64-linux"
|
|
then import nixpkgs {
|
|
inherit system overlays;
|
|
linker = "lld";
|
|
crossSystem = nixpkgs.lib.systems.examples.musl64;
|
|
}
|
|
else import nixpkgs {
|
|
inherit system overlays;
|
|
};
|
|
|
|
nativePkgs = import nixpkgs { inherit system; };
|
|
|
|
pkgs = get_pkgs overlays;
|
|
# Just disabling the tests that fails under musl
|
|
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;
|
|
});
|
|
|
|
stdenv = pkgs.overrideCC pkgs.stdenv pkgs.llvmPackages_17.clangUseLLVM;
|
|
|
|
buildToolsDeps = (with pkgs; [
|
|
cmake
|
|
ninja
|
|
clang_17
|
|
lld_17
|
|
clang-tools
|
|
ccache
|
|
iwyu
|
|
git'
|
|
valgrind
|
|
gtest
|
|
bashInteractive
|
|
nativePkgs.fish
|
|
]);
|
|
|
|
deps = (with pkgs.pkgsStatic; [
|
|
fmt
|
|
rocksdb
|
|
gtest
|
|
argparse
|
|
]);
|
|
|
|
utils = pkgs.callPackage ./nix/utils.nix { deps = buildToolsDeps ++ deps; };
|
|
|
|
devCommands = (with utils; [
|
|
build
|
|
run
|
|
compile
|
|
]);
|
|
|
|
|
|
shell = args: (pkgs.mkShell.override { inherit stdenv; }) {
|
|
name = "feynman";
|
|
nativeBuildInputs = buildToolsDeps ++ devCommands ++ deps;
|
|
buildInputs = deps;
|
|
|
|
|
|
CPP_LS = "clangd -j 30 --query-driver=${pkgs.clang_17}/bin/clang-*";
|
|
shellHook = ''
|
|
fish && exit
|
|
'';
|
|
} // args;
|
|
|
|
in {
|
|
|
|
packages.default = stdenv.mkDerivation {
|
|
pname = "feynmanDB";
|
|
version = "0.1.0";
|
|
|
|
src = ./.;
|
|
|
|
cmakeFlags = [];
|
|
|
|
nativeBuildInputs = buildToolsDeps;
|
|
buildInputs = deps;
|
|
};
|
|
|
|
devShells.default = shell {};
|
|
});
|
|
}
|