# Serene Programming Language # # Copyright (c) 2019-2024 Sameer Rahmani # # 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 . { ... }: with builtins; let getEnv = p: (p.env or { }).NIX_LDFLAGS or p.NIX_LDFLAGS or ""; in { # Most of these overlays are do to bugs and problems # in upstream nixpkgs. But thanks to their design # We can fix them using these overlays and contribute # them upstream little by little. sereneDev = (final: prev: if !prev.stdenv.hostPlatform.isLinux then prev else { p11-kit = prev.p11-kit.overrideAttrs (old: { patches = [ ./nix/patches/p11-kit_skip_test.patch ]; }); cpio = prev.cpio.overrideAttrs (old: { nativeBuildInputs = [ final.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-18, and --no-undefined-version is the # default in lld-18. We need to explicitly turn it off for # these problematic packages untill they fix it upstream. libxcrypt = prev.libxcrypt.overrideAttrs (old: { env.NIX_LDFLAGS = "${getEnv old} --undefined-version"; #old.NIX_FLAGS ++ final.lib.optional (prev.stdenv.cc.isClang) }); ncurses = prev.ncurses.overrideAttrs (old: { env.NIX_LDFLAGS = "${getEnv old} --undefined-version"; }); libbsd = prev.libbsd.overrideAttrs (old: { env.NIX_LDFLAGS = "${getEnv old} --undefined-version"; # NIX_LDFLAGS = [ ] ++ final.lib.optional (prev.stdenv.cc.isClang) # [ "--undefined-version" ]; }); libxml2 = prev.libxml2.overrideAttrs (old: { env.NIX_LDFLAGS = "${getEnv old} --undefined-version"; propagatedBuildInputs = old.propagatedBuildInputs ++ [ final.zlib.static ]; # NIX_LDFLAGS = [ ] ++ final.lib.optional (prev.stdenv.cc.isClang) # [ "--undefined-version" ]; }); # binutils = prev.binutils.overrideAttrs (old: { # env.NIX_LDFLAGS = (getEnv old NIX_LDFLAGS " ") ++ "--undefined-version"; # buildInputs = [ final.zlib final.gettext final.zlib.static ]; # }); }); iwyu = (final: prev: { iwyu = (prev.include-what-you-use.overrideAttrs (old: let version = "0.22"; in { inherit version; src = prev.fetchurl { url = "${old.meta.homepage}/downloads/${old.pname}-${version}.src.tar.gz"; hash = "sha256-hZB0tGHqS4MlpzQYwgfKM7XmVmsI5rWH65FkQWVppt0="; }; cmakeFlags = [ "-DCMAKE_PREFIX_PATH=${prev.llvmPackages_18.llvm.dev}" ]; })).override { llvmPackages = prev.__splicedPackages.llvmPackages_18; }; }); }