nix: Move the overlayes to a module and lock nixpkgs
This commit is contained in:
parent
b59e4ab315
commit
f377e0d4d5
|
@ -32,4 +32,5 @@ docs/spec.pdf
|
|||
.pdf
|
||||
docs/overall_picture.png
|
||||
.direnv/
|
||||
.pre-commit-config.yaml
|
||||
.pre-commit-config.yaml
|
||||
.envrc
|
18
flake.lock
18
flake.lock
|
@ -129,16 +129,18 @@
|
|||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"dirtyRev": "1681ff1c67b9e337c204178d4cd85c9327e35eff-dirty",
|
||||
"dirtyShortRev": "1681ff1c67b9-dirty",
|
||||
"lastModified": 1712254141,
|
||||
"narHash": "sha256-r283uWBsHhcmTMIcAlGbM8c9wnc8b9AFweeNXnggbD8=",
|
||||
"type": "git",
|
||||
"url": "file:///home/lxsameer/src/nixpkgs"
|
||||
"lastModified": 1712525377,
|
||||
"narHash": "sha256-TbfZDd8NN6gx7eU5XQWgF/ojnnkTvn7cPXWdY4PVTMU=",
|
||||
"owner": "lxsameer",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "c738ee8ad1c35383037c20fa13eaac17c8ae98c5",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"type": "git",
|
||||
"url": "file:///home/lxsameer/src/nixpkgs"
|
||||
"owner": "lxsameer",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "c738ee8ad1c35383037c20fa13eaac17c8ae98c5",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
|
|
123
flake.nix
123
flake.nix
|
@ -16,124 +16,18 @@
|
|||
{
|
||||
description = "Serene programming language";
|
||||
|
||||
#inputs.nixpkgs.url = "github:NixOS/nixpkgs/bcb1a9c7e1d8568c5e58316fe3254eb8f4455439";
|
||||
#inputs.nixpkgs.url = "github:lxsameer/nixpkgs/e1f7865bce4d52d30dd1d61e79798ee2765cc2b0";
|
||||
inputs.nixpkgs.url = "/home/lxsameer/src/nixpkgs/";
|
||||
inputs.nixpkgs.url =
|
||||
"github:lxsameer/nixpkgs/c738ee8ad1c35383037c20fa13eaac17c8ae98c5";
|
||||
#inputs.nixpkgs.url = "/home/lxsameer/src/nixpkgs/";
|
||||
inputs.git-hooks.url = "github:cachix/git-hooks.nix";
|
||||
inputs.flake-utils.url = "github:numtide/flake-utils";
|
||||
|
||||
outputs = { self, nixpkgs, flake-utils, git-hooks, ... }:
|
||||
outputs = { self, nixpkgs, git-hooks, flake-utils, ... }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
version = "1.0.0";
|
||||
# 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 contribuete
|
||||
# them upstream little by little.
|
||||
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-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.
|
||||
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: {
|
||||
NIX_LDFLAGS = if prev.stdenv.cc.isClang then
|
||||
[ "--undefined-version" ]
|
||||
else
|
||||
[ ];
|
||||
});
|
||||
|
||||
binutils = prev.binutils.overrideAttrs (old: {
|
||||
NIX_LDFLAGS = [
|
||||
"-Wl,--undefined-version"
|
||||
] # if prev.stdenv.cc.isClang
|
||||
# then
|
||||
# else []
|
||||
;
|
||||
});
|
||||
|
||||
libidn2 = prev.libidn2.overrideAttrs (old: {
|
||||
# old.NIX_LDFLAGS ++
|
||||
NIX_LDFLAGS = if prev.stdenv.cc.isClang then
|
||||
[ "--undefined-version" ]
|
||||
else
|
||||
[ ];
|
||||
});
|
||||
|
||||
nghttp2 = prev.nghttp2.overrideAttrs
|
||||
(old: { buildInputs = old.buildInputs ++ [ final.zlib ]; });
|
||||
|
||||
#==============================================================
|
||||
|
||||
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;
|
||||
};
|
||||
})
|
||||
];
|
||||
overlays = [ (import ./nix/overlays.nix { }).muslComp ];
|
||||
|
||||
utils = import ./nix/utils.nix { inherit nixpkgs; };
|
||||
|
||||
|
@ -163,10 +57,12 @@
|
|||
# is not static), We can't statically link to it. So, we just replace
|
||||
# that zlib with our override of zlib-ng
|
||||
clang' = stdenv.cc.overrideAttrs (old: {
|
||||
propagatedBuildInputs = [ stdenv.cc.bintools ] ++ [ zlib' ];
|
||||
propagatedBuildInputs = [ stdenv.cc.bintools ]
|
||||
++ [ pkgs.zlib.static ];
|
||||
});
|
||||
|
||||
llvm = pkgs.llvmPackages_18.llvm.overrideAttrs
|
||||
(old: { propagatedBuildInputs = [ zlib' ]; });
|
||||
(old: { propagatedBuildInputs = [ pkgs.zlib.static ]; });
|
||||
|
||||
# This is the actual stdenv that we need to use anywhere else
|
||||
stdenv' = pkgs.stdenvAdapters.overrideCC pkgs.stdenv clang';
|
||||
|
@ -222,6 +118,5 @@
|
|||
};
|
||||
};
|
||||
};
|
||||
|
||||
});
|
||||
}
|
||||
|
|
|
@ -0,0 +1,100 @@
|
|||
# Serene Programming Language
|
||||
#
|
||||
# Copyright (c) 2019-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/>.
|
||||
{ ... }: {
|
||||
# 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.
|
||||
muslComp = (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-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: {
|
||||
NIX_LDFLAGS = [ ] ++ final.lib.optional (prev.stdenv.cc.isClang)
|
||||
[ "--undefined-version" ];
|
||||
});
|
||||
|
||||
ncurses = prev.ncurses.overrideAttrs (old: {
|
||||
NIX_LDFLAGS = [ ] ++ final.lib.optional (prev.stdenv.cc.isClang)
|
||||
[ "--undefined-version" ];
|
||||
});
|
||||
|
||||
libbsd = prev.libbsd.overrideAttrs (old: {
|
||||
NIX_LDFLAGS = [ ] ++ final.lib.optional (prev.stdenv.cc.isClang)
|
||||
[ "--undefined-version" ];
|
||||
});
|
||||
|
||||
libxml2 = prev.libxml2.overrideAttrs (old: {
|
||||
propagatedBuildInputs = old.propagatedBuildInputs ++ [ prev.zlib.static ];
|
||||
NIX_LDFLAGS = [ ] ++ final.lib.optional (prev.stdenv.cc.isClang)
|
||||
[ "--undefined-version" ];
|
||||
});
|
||||
|
||||
binutils = prev.binutils.overrideAttrs (old: {
|
||||
buildInputs = [ prev.zlib prev.gettext prev.zlib.static ];
|
||||
NIX_LDFLAGS = [ "--undefined-version" ];
|
||||
});
|
||||
|
||||
#==============================================================
|
||||
|
||||
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; };
|
||||
});
|
||||
}
|
|
@ -13,22 +13,18 @@
|
|||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
{ nixpkgs }:
|
||||
{
|
||||
get_pkgs = system: overlays:
|
||||
{
|
||||
host = import nixpkgs { inherit system; };
|
||||
target =
|
||||
if system == "x86_64-linux"
|
||||
then import nixpkgs {
|
||||
inherit system overlays;
|
||||
linker = "lld";
|
||||
crossSystem = nixpkgs.lib.systems.examples.musl64 // { useLLVM = true; };
|
||||
# config.replaceCrossStdenv = { buildPackages, baseStdenv }:
|
||||
# buildPackages.stdenvAdapters.overrideCC baseStdenv buildPackages.llvmPackages_17.clangUseLLVM;
|
||||
}
|
||||
else import nixpkgs {
|
||||
inherit system overlays;
|
||||
{ nixpkgs }: {
|
||||
get_pkgs = system: overlays: {
|
||||
host = import nixpkgs { inherit system; };
|
||||
target = if system == "x86_64-linux" then
|
||||
import nixpkgs {
|
||||
inherit system overlays;
|
||||
linker = "lld";
|
||||
crossSystem = nixpkgs.lib.systems.examples.musl64 // {
|
||||
useLLVM = true;
|
||||
};
|
||||
};
|
||||
}
|
||||
else
|
||||
import nixpkgs { inherit system overlays; };
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue