]> git.immae.eu Git - perso/Immae/Config/Nixies.git/blobdiff - stdenv_prefix/example.nix
Add stdenv_prefix
[perso/Immae/Config/Nixies.git] / stdenv_prefix / example.nix
diff --git a/stdenv_prefix/example.nix b/stdenv_prefix/example.nix
new file mode 100644 (file)
index 0000000..0d4aa65
--- /dev/null
@@ -0,0 +1,51 @@
+{ storepath_length ? 30, storepath_chunks ? 4, pkgs ? import <nixpkgs> {
+  stdenvStages = { config, overlays, localSystem, ... }@args: (import <nixpkgs/pkgs/stdenv> args) ++ [
+    (previousStage: {
+      inherit config overlays;
+      stdenv = let
+        toPreHook = withAppendOut: ''
+              storepath_length=${toString storepath_length}
+              storepath_chunks=${toString storepath_chunks}
+          '' + builtins.readFile ./prehook.sh + (pkgs.lib.optionalString withAppendOut ''
+              appendOut
+          '');
+        newlibunistring = previousStage.libunistring.overrideAttrs (attrs: {
+          preHook = attrs.preHook or "" + (toPreHook true);
+          am_cv_func_iconv_works = "yes";
+        });
+        newlibidn2 = (previousStage.libidn2.override { libunistring = newlibunistring; }).overrideAttrs (attrs: {
+          preHook = attrs.preHook or "" + (toPreHook true);
+          postFixup = ''
+            ${previousStage.nukeReferences}/bin/nuke-refs -e $(cat ${newlibunistring}/nix-support/new-out)/lib \
+              "$out"/lib/lib*.so.*.*
+          '';
+        });
+        overridenCallPackage = p: a: previousStage.callPackage p (a // { libidn2 = newlibidn2;});
+
+        newlibc = (previousStage."${localSystem.libc}".override { callPackage = overridenCallPackage; }).overrideAttrs(old: {
+          preHook = old.preHook or "" + (toPreHook true);
+        });
+        newbintools = (previousStage.binutils.override { libc = newlibc; }).overrideAttrs(old: {
+          postFixup = old.postFixup + ''
+            newlibcout=$(cat ${newlibc}/nix-support/new-out)
+            sed -i -e "s@${newlibc}@$newlibcout@g" $out/nix-support/*
+          '';
+        });
+        newStdenv = previousStage.stdenv.override {
+          allowedRequisites = null;
+          extraAttrs.bintools = newbintools;
+          cc = previousStage.gcc.override({ bintools = newbintools; libc = newlibc; });
+          overrides = self: super: rewriteMap (previousStage.stdenv.overrides self super) // {
+            ${localSystem.libc} = newlibc;
+          };
+          preHook = previousStage.stdenv.preHook + ''
+              libc_path=${newlibc}
+            '' + (toPreHook false);
+        };
+        rewriteMap = builtins.mapAttrs (n: v: v.override { stdenv = newStdenv; });
+      in
+        newStdenv;
+      })
+    ];
+} }:
+  pkgs.xar