Created
June 20, 2015 10:54
-
-
Save qknight/61787f63c77e08c93431 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
=================================================================================================== | |
originally i was passing languages as a list of | |
=================================================================================================== | |
de_DE_language = pkgs.stdenv.mkDerivation rec { | |
version = "4.2"; | |
name = "wp_de_DE-${version}"; | |
src = pkgs.fetchurl { | |
url = "https://downloads.wordpress.org/translation/core/${version}/${language}.zip"; | |
sha256 = "...2342342340fs9d02390fsfsf..."; | |
}; | |
buildInputs = [ pkgs.unzip ]; | |
unpackPhase = '' | |
unzip $src | |
export sourceRoot=. | |
''; | |
installPhase = "mkdir -p $out; cp -R * $out/"; | |
}; | |
and this mkOption was passed to the service expression: | |
languages = [ de_DE_language ]; | |
and during the installation for each given language-path i created symlinks: | |
${concatMapStrings (language: "ln -s ${language}/*.mo ${language}/*.po $out/wp-content/languages/\n") (languages) } | |
languages = mkOption { | |
default = []; | |
type = types.listOf types.path; | |
}; | |
=================================================================================================== | |
now i want to generalize this pattern | |
=================================================================================================== | |
supportedLanguages = { | |
en_GB = "1yf1sb6ji3l4lg8nkkjhckbwl81jly8z93jf06pvk6a1p6bsr6l6"; | |
de_DE = "3881221f337799b88f9562df8b3f1560f2c49a8f662297561a5b25ce77f22e17"; | |
}; | |
downloadLanguagePack = language: sha256: | |
${language}_language = pkgs.stdenv.mkDerivation rec { | |
version = "4.2"; | |
name = "wp_${language}-${version}"; | |
src = pkgs.fetchurl { | |
url = "https://downloads.wordpress.org/translation/core/${version}/${language}.zip"; | |
sha256 = "${sha256}"; | |
}; | |
buildInputs = [ pkgs.unzip ]; | |
unpackPhase = '' | |
unzip $src | |
export sourceRoot=. | |
''; | |
installPhase = "mkdir -p $out; cp -R * $out/"; | |
}; | |
to in theory languages will be populated with procedurally generated attributes: | |
languages = map (lang: downloadLanguagePack ${lang} supportedLanguages.${lang}) (selectedLanguages); | |
and the config.language would then look something like this: | |
languages = [ "de_DE" "en_EN" ]; | |
however, this does not work because i don't know how to create the downloadLanguagePack function correctly. how to solve this? | |
later use it like this: | |
# install language files | |
mkdir -p $out/wp-content/languages | |
${concatMapStrings (language: "ln -s ${language}/*.mo ${language}/*.po $out/wp-content/languages/\n") (languages) } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment