diff --git a/flake.lock b/flake.lock index bdf9be8..7361f31 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "systems": "systems" }, "locked": { - "lastModified": 1701680307, - "narHash": "sha256-kAuep2h5ajznlPMD9rnQyffWG8EM/C73lejGofXvdM8=", + "lastModified": 1710146030, + "narHash": "sha256-SZ5L6eA7HJ/nmkzGG7/ISclqe6oZdOZTNoesiInkXPQ=", "owner": "numtide", "repo": "flake-utils", - "rev": "4022d587cbbfd70fe950c1e2083a02621806a725", + "rev": "b1d9ab70662946ef0850d488da1c9019f3a9752a", "type": "github" }, "original": { @@ -20,18 +20,16 @@ }, "nixpkgs": { "locked": { - "lastModified": 1705092417, - "narHash": "sha256-01pTqprf3NvQijvxkQjwx2c6uevB4MZKooIcf+RTYHA=", - "owner": "lxsameer", - "repo": "nixpkgs", - "rev": "e1f7865bce4d52d30dd1d61e79798ee2765cc2b0", - "type": "github" + "dirtyRev": "1681ff1c67b9e337c204178d4cd85c9327e35eff-dirty", + "dirtyShortRev": "1681ff1c67b9-dirty", + "lastModified": 1712254141, + "narHash": "sha256-r283uWBsHhcmTMIcAlGbM8c9wnc8b9AFweeNXnggbD8=", + "type": "git", + "url": "file:///home/lxsameer/src/nixpkgs" }, "original": { - "owner": "lxsameer", - "repo": "nixpkgs", - "rev": "e1f7865bce4d52d30dd1d61e79798ee2765cc2b0", - "type": "github" + "type": "git", + "url": "file:///home/lxsameer/src/nixpkgs" } }, "root": { diff --git a/flake.nix b/flake.nix index 135f70e..a32b846 100644 --- a/flake.nix +++ b/flake.nix @@ -17,17 +17,14 @@ 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/e1f7865bce4d52d30dd1d61e79798ee2765cc2b0"; + 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 - # Out zsh configuration directory. mkShell will pick up the .zshrc - # from this directory. - zshDir = ./scripts; - + 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 @@ -70,8 +67,8 @@ }); #============================================================= - # Since we're using lld-17, and --no-undefined-version is the - # default in lld-17. We need to explicitely turn it off for + # 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 @@ -89,32 +86,45 @@ else []; }); - libbsd = prev.libbsd.overrideAttrs (old: { #old.NIX_LDFLAGS ++ + 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.21"; + version = "0.22"; in { inherit version; src = prev.fetchurl { url = "${old.meta.homepage}/downloads/${old.pname}-${version}.src.tar.gz"; - hash = "sha256-ajUZGf+JvafJXIlUcmAYaNs9qrlqlYs44DYokNWHYLY="; + hash = "sha256-hZB0tGHqS4MlpzQYwgfKM7XmVmsI5rWH65FkQWVppt0="; }; - cmakeFlags = [ "-DCMAKE_PREFIX_PATH=${prev.llvmPackages_17.llvm.dev}" ]; + cmakeFlags = [ "-DCMAKE_PREFIX_PATH=${prev.llvmPackages_18.llvm.dev}" ]; })).override { - llvmPackages = prev.__splicedPackages.llvmPackages_17; + llvmPackages = prev.__splicedPackages.llvmPackages_18; }; }) ]; @@ -123,12 +133,14 @@ utils = import ./nix/utils.nix { inherit nixpkgs; }; # Create a package set based on the build system - pkgs = utils.get_pkgs system overlays; + pkgs_set = utils.get_pkgs system overlays; + hostPkgs = pkgs_set.host; + pkgs = pkgs_set.target; nativePkgs = import nixpkgs { inherit system overlays; }; - # Create a stdenv based on LLVM 17 - stdenv = pkgs.stdenvAdapters.overrideCC pkgs.stdenv pkgs.llvmPackages_17.clangUseLLVM; + # Create a stdenv based on LLVM + stdenv = pkgs.stdenvAdapters.overrideCC pkgs.stdenv pkgs.llvmPackages_18.clangUseLLVM; gc = pkgs.callPackage ./nix/boehmgc.nix { inherit stdenv; }; @@ -149,7 +161,7 @@ clang' = stdenv.cc.overrideAttrs (old: { propagatedBuildInputs = [ stdenv.cc.bintools ] ++ [ zlib' ]; }); - llvm = pkgs.llvmPackages_17.llvm.overrideAttrs (old: { + llvm = pkgs.llvmPackages_18.llvm.overrideAttrs (old: { propagatedBuildInputs = [ zlib' ]; }); @@ -167,12 +179,18 @@ old.preInstallCheck; }); + nativeBuildToolsDeps = (with hostPkgs; [ + cmake + ninja + ccache + git + python3 + ]); + buildToolsDeps = (with pkgs; [ - cmake - ninja llvm - llvmPackages_17.mlir - llvmPackages_17.clang + llvmPackages_18.mlir + llvmPackages_18.clang iwyu ]); @@ -183,28 +201,20 @@ zsh-syntax-highlighting ]); - buildDevToolsDeps = (with pkgs; [ - ccache - git' - python3 - ]); - buildDeps = (with pkgs; [ gc zlib' llvm - llvmPackages_17.mlir - llvmPackages_17.clang + llvmPackages_18.mlir + llvmPackages_18.clang ]); - testDeps = (with pkgs; [ + testDeps = (with hostPkgs; [ gtest gmock gbenchmark ]); - - tex = nativePkgs.texlive.combine { inherit (nativePkgs.texlive) scheme-minimal @@ -242,12 +252,9 @@ in { inherit pkgs; devShells.default = (pkgs.mkShell.override { stdenv = stdenv';}) { - nativeBuildInputs = buildDevToolsDeps ++ buildToolsDeps ++ shellTools; + nativeBuildInputs = nativeBuildToolsDeps ++ buildToolsDeps ++ shellTools; buildInputs = buildDeps ++ testDeps; - shellHook = - '' - BUILDER= ZDOTDIR=${zshDir} zsh -d && exit - ''; + CPP_LS = "serene-clangd"; }; # This shell is gcc based and we use it only @@ -255,13 +262,17 @@ devShells.math = nativePkgs.mkShell { #nativeBuildInputs = mathDeps; buildInputs = mathDeps; - shellHook = - '' - BUILDER=Math ZDOTDIR=${zshDir} zsh -d && exit - ''; }; - #packages.llvm = llvm; + packages.devshell = stdenv'.mkDerivation { + inherit version; + name = "devshell"; + + doUnpack = false; + doCheck = false; + nativeBuildInputs = nativeBuildToolsDeps ++ buildToolsDeps ++ shellTools; + buildInputs = buildDeps ++ testDeps; + } ; } ); } diff --git a/nix/utils.nix b/nix/utils.nix index da72f57..16646fd 100644 --- a/nix/utils.nix +++ b/nix/utils.nix @@ -16,15 +16,19 @@ { nixpkgs }: { get_pkgs = system: overlays: - 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; + { + 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; + }; }; }