Add the basic derivations to debug the nixpkgs

This commit is contained in:
Sameer Rahmani 2023-09-10 20:52:10 +01:00
parent 03794fde6a
commit 7577fcba1f
Signed by: lxsameer
GPG Key ID: B0A4AF28AB9FD90B
4 changed files with 59 additions and 26 deletions

View File

@ -1,32 +1,34 @@
{ {
nixPkgsVersion ? "3e52e76b70d5508f3cec70b882a29199f4d1ee85" nixPkgsVersion ? "f606c027310f06df398875960e04038db1f0129f", # release 23.0 # "3e52e76b70d5508f3cec70b882a29199f4d1ee85", # unstable
currentSystem
}: }:
let let
getNixPkgs = args: import (builtins.fetchGit { getNixPkgs = args: import (builtins.fetchGit {
name = "nixpkg-serene-${nixPkgsVersion}"; name = "nixpkg-serene-${nixPkgsVersion}";
url = "https://github.com/nixos/nixpkgs/"; 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` # `git ls-remote https://github.com/nixos/nixpkgs nixos-unstable`
ref = "refs/heads/nixos-unstable"; ref = "refs/heads/release-23.05"; # refs/heads/nixos-unstable
rev = nixPkgsVersion; rev = nixPkgsVersion;
}) args; }) args;
nixpkgs = getNixPkgs {}; nixpkgs = getNixPkgs { system = currentSystem; };
system = import ./system.nix { pkgs = nixpkgs; }; system = import ./system.nix {
staticMuslPkgs = getNixPkgs system; pkgs = nixpkgs;
llvm = staticMuslPkgs.llvmPackages_16.override { stdenv = staticMuslPkgs.llvmPackages_16.libcxxClang; }; inherit currentSystem;
SereneOverlay = final: prev: };
{ # staticMuslPkgs = getNixPkgs system;
sereneToolchain = llvm.libcxxClang; # llvm = staticMuslPkgs.llvmPackages_16.override { stdenv = staticMuslPkgs.llvmPackages_16.libcxxStdenv; };
};
replaceStdenv = { pkgs }:
let
llvm = pkgs.llvmPackages_16.override { stdenv = pkgs.llvmPackages_16.libcxxStdenv; };
in
llvm.libcxxStdenv;
createPkgSet = _:
getNixPkgs (system // { config = { inherit replaceStdenv; }; });
createPkgSet = _: # It has to be the nixpkgs instance
getNixPkgs (system // { overlays = [ SereneOverlay ]; });
#pkgs = getNixPkgs nixVersion (system // { overlays = [ libcxxClangOverlay ]; });
in { in {
inherit SereneOverlay createPkgSet; inherit createPkgSet;
# setupToolchain = nixpkgs:
#pkgs.stdenv.override { stdenv = llvm.libcxxClang; };
} }

View File

@ -4,10 +4,19 @@
outputs = inputs: outputs = inputs:
let let
toolchain = import ./.; toolchain = import /home/lxsameer/src/toolchain/test-stdenv.nix {};
nixpkgs = import /home/lxsameer/src/nixpkgs {};
myenv = toolchain.createPkgSet;
in in
{ {
inherit toolchain; testClang = myenv.stdenv.mkDerivation {
}; name = "testClang";
unpackPhase = "echo AA $CC; echo '--'; env; NIX_DEBUG=1 $CC -v; echo '--'; exit 1";
};
testGcc = nixpkgs.stdenv.mkDerivation {
name = "testGcc";
unpackPhase = "NIX_DEBUG=1 $CC --version; echo $CC; $CC -v; exit 1";
};
inherit myenv;
};
} }

View File

@ -1,11 +1,11 @@
{ pkgs }: { pkgs, currentSystem }:
let let
parsedSystem = builtins.split "-" builtins.currentSystem; parsedSystem = builtins.split "-" currentSystem;
arch = builtins.head (parsedSystem); arch = builtins.head (parsedSystem);
os = builtins.elemAt (parsedSystem) 2; os = builtins.elemAt (parsedSystem) 2;
system = pkgs.lib.systems.elaborate { system = pkgs.lib.systems.elaborate {
system = builtins.currentSystem; system = currentSystem;
config = "${arch}-unknown-linux-musl"; config = "${arch}-unknown-linux-musl";
isStatic = true; isStatic = true;
useLLVM = true; useLLVM = true;

22
test-stdenv.nix Normal file
View File

@ -0,0 +1,22 @@
{}:
let
currentSystem = "x86_64-linux";
getNixPkgs = args: import ../nixpkgs args;
nixpkgs = getNixPkgs { system = currentSystem; };
system = import ./system.nix {
pkgs = nixpkgs;
inherit currentSystem;
};
# replaceStdenv = { pkgs }:
# let
# llvm = pkgs.llvmPackages_16.override { stdenv = pkgs.llvmPackages_16.libcxxStdenv; };
# in
# llvm.libcxxStdenv;
createPkgSet = getNixPkgs system;
in {
inherit createPkgSet;
}