]> git.immae.eu Git - perso/Immae/Config/Nixies.git/blob - stdenv_prefix/example.nix
0d4aa65c73f8db7f316276fc2a2d2118ddbf8e79
[perso/Immae/Config/Nixies.git] / stdenv_prefix / example.nix
1 { storepath_length ? 30, storepath_chunks ? 4, pkgs ? import <nixpkgs> {
2 stdenvStages = { config, overlays, localSystem, ... }@args: (import <nixpkgs/pkgs/stdenv> args) ++ [
3 (previousStage: {
4 inherit config overlays;
5 stdenv = let
6 toPreHook = withAppendOut: ''
7 storepath_length=${toString storepath_length}
8 storepath_chunks=${toString storepath_chunks}
9 '' + builtins.readFile ./prehook.sh + (pkgs.lib.optionalString withAppendOut ''
10 appendOut
11 '');
12 newlibunistring = previousStage.libunistring.overrideAttrs (attrs: {
13 preHook = attrs.preHook or "" + (toPreHook true);
14 am_cv_func_iconv_works = "yes";
15 });
16 newlibidn2 = (previousStage.libidn2.override { libunistring = newlibunistring; }).overrideAttrs (attrs: {
17 preHook = attrs.preHook or "" + (toPreHook true);
18 postFixup = ''
19 ${previousStage.nukeReferences}/bin/nuke-refs -e $(cat ${newlibunistring}/nix-support/new-out)/lib \
20 "$out"/lib/lib*.so.*.*
21 '';
22 });
23 overridenCallPackage = p: a: previousStage.callPackage p (a // { libidn2 = newlibidn2;});
24
25 newlibc = (previousStage."${localSystem.libc}".override { callPackage = overridenCallPackage; }).overrideAttrs(old: {
26 preHook = old.preHook or "" + (toPreHook true);
27 });
28 newbintools = (previousStage.binutils.override { libc = newlibc; }).overrideAttrs(old: {
29 postFixup = old.postFixup + ''
30 newlibcout=$(cat ${newlibc}/nix-support/new-out)
31 sed -i -e "s@${newlibc}@$newlibcout@g" $out/nix-support/*
32 '';
33 });
34 newStdenv = previousStage.stdenv.override {
35 allowedRequisites = null;
36 extraAttrs.bintools = newbintools;
37 cc = previousStage.gcc.override({ bintools = newbintools; libc = newlibc; });
38 overrides = self: super: rewriteMap (previousStage.stdenv.overrides self super) // {
39 ${localSystem.libc} = newlibc;
40 };
41 preHook = previousStage.stdenv.preHook + ''
42 libc_path=${newlibc}
43 '' + (toPreHook false);
44 };
45 rewriteMap = builtins.mapAttrs (n: v: v.override { stdenv = newStdenv; });
46 in
47 newStdenv;
48 })
49 ];
50 } }:
51 pkgs.xar