Unverified Commit ead097db authored by Tristan Ross's avatar Tristan Ross
Browse files

glibcLocales: format

parent e9211c21
Loading
Loading
Loading
Loading
+84 −73
Original line number Diff line number Diff line
/* This function builds just the `lib/locale/locale-archive' file from
/*
  This function builds just the `lib/locale/locale-archive' file from
  Glibc and nothing else.  If `allLocales' is true, all supported
  locales are included; otherwise, just the locales listed in
  `locales'.  See localedata/SUPPORTED in the Glibc source tree for
@@ -6,30 +7,41 @@
  https://sourceware.org/git/?p=glibc.git;a=blob;f=localedata/SUPPORTED
*/

{ lib, stdenv, buildPackages, callPackage, writeText, glibc
, allLocales ? true, locales ? [ "en_US.UTF-8/UTF-8" ]
, linuxHeaders, withLinuxHeaders ? !stdenv.cc.isGNU
{
  lib,
  stdenv,
  buildPackages,
  callPackage,
  writeText,
  glibc,
  allLocales ? true,
  locales ? [ "en_US.UTF-8/UTF-8" ],
  linuxHeaders,
  withLinuxHeaders ? !stdenv.cc.isGNU,
}:

(callPackage ./common.nix ({ inherit stdenv; } // lib.optionalAttrs withLinuxHeaders {
  inherit linuxHeaders;
}) {
(callPackage ./common.nix
  ({ inherit stdenv; } // lib.optionalAttrs withLinuxHeaders { inherit linuxHeaders; })
  {
    pname = "glibc-locales";
    extraNativeBuildInputs = [ glibc ];
    inherit withLinuxHeaders;
}).overrideAttrs(finalAttrs: previousAttrs: {
  }
).overrideAttrs
  (
    finalAttrs: previousAttrs: {

      builder = ./locales-builder.sh;

      outputs = [ "out" ];

      LOCALEDEF_FLAGS = [
    (if stdenv.hostPlatform.isLittleEndian
    then "--little-endian"
    else "--big-endian")
        (if stdenv.hostPlatform.isLittleEndian then "--little-endian" else "--big-endian")
      ];

  preBuild = (previousAttrs.preBuild or "") + ''
      preBuild =
        (previousAttrs.preBuild or "")
        + ''
          # Awful hack: `localedef' doesn't allow the path to `locale-archive'
          # to be overriden, but you *can* specify a prefix, i.e. it will use
          # <prefix>/<path-to-glibc>/lib/locale/locale-archive.  So we use
@@ -74,17 +86,16 @@
        "localedir=${builtins.placeholder "out"}/lib/locale"
      ];

  installPhase =
    ''
      installPhase = ''
        mkdir -p "$out/lib/locale" "$out/share/i18n"
        cp -v "$TMPDIR/$NIX_STORE/"*"/lib/locale/locale-archive" "$out/lib/locale"
        cp -v ../glibc-2*/localedata/SUPPORTED "$out/share/i18n/SUPPORTED"
      '';

  setupHook = writeText "locales-setup-hook.sh"
    ''
      setupHook = writeText "locales-setup-hook.sh" ''
        export LOCALE_ARCHIVE=@out@/lib/locale/locale-archive
      '';

      meta.description = "Locale information for the GNU C Library";
})
    }
  )