diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..9e5410c --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/mdn diff --git a/coverage.nix b/coverage.nix new file mode 100644 index 0000000..9e5e0f0 --- /dev/null +++ b/coverage.nix @@ -0,0 +1,13 @@ +{stdenv, python26Packages, libmemcached}: python26Packages.buildPythonPackage rec { + pname = "coverage"; + version = "3.2b4"; + format = "setuptools"; + + src = python26Packages.fetchPypi { + inherit pname version; + extension = "tar.gz"; + hash = "sha256-NNSeUns9hu7orVGyhwg5uPRC+HrHS2kuXNEIEN3wADM="; + }; + + propagatedBuildInputs = [python26Packages.setuptools]; +} diff --git a/django-pylibmc.nix b/django-pylibmc.nix new file mode 100644 index 0000000..ecc6d59 --- /dev/null +++ b/django-pylibmc.nix @@ -0,0 +1,16 @@ +{stdenv, python26Packages, libmemcached}: python26Packages.buildPythonPackage rec { + pname = "django-pylibmc"; + version = "0.5.0"; + format = "setuptools"; + + src = python26Packages.fetchPypi { + inherit pname version; + extension = "tar.gz"; + hash = "sha256-p48pdbe1y2HMFfckHaUUsoL9pFQ8Y0ZgKi/CdUmd8fI="; + }; + + propagatedBuildInputs = [python26Packages.setuptools]; + pipInstallFlags = [ "--no-deps" ]; + + #pythonImportsCheck = ["pylibmc"]; +} diff --git a/gitModulesFixer.nix b/gitModulesFixer.nix new file mode 100644 index 0000000..0ab067f --- /dev/null +++ b/gitModulesFixer.nix @@ -0,0 +1,54 @@ +{stdenv, writeShellApplication, git}: writeShellApplication rec { + name = "gitModulesFixer"; + + + #propagatedBuildInputs = [python26Packages.setuptools]; + #nativeBuildInputs = [ libxml2 libxslt ]; + #buildInputs = [ zlib ]; + runtimeInputs = [ git ]; + + #env = { + # NIX_CFLAGS_COMPILE="-Wno-incompatible-pointer-types"; + #}; + + text = '' + root_dir=$(pwd) + processed_files=() + + echo ">>> Starting recursive submodule fix & init" + + while :; do + found_new=false + + while IFS= read -r gitmodules_file; do + # Skip already processed + echo "''${processed_files[@]}" + if printf '%s\n' "''${processed_files[@]}" | grep -qx "$gitmodules_file"; then + continue + fi + + echo ">>> Patching $gitmodules_file" + processed_files+=("$gitmodules_file") + found_new=true + + sed -i 's#git://#https://#g' "$gitmodules_file" + + # Init only first-level submodules for this directory + + mod_dir=$(dirname "$gitmodules_file") + ( + cd "$mod_dir" + echo "$mod_dir" + git status + git submodule status + git submodule update --init + ) + done < <(find "$root_dir" -name .gitmodules) + + if ! $found_new; then + echo ">>> No new submodules found. Done." + break + fi + done + ''; +} diff --git a/jinja2.nix b/jinja2.nix index 49cfe15..6fe1cc3 100644 --- a/jinja2.nix +++ b/jinja2.nix @@ -1,16 +1,13 @@ -{stdenv, fetchPypi, buildPythonPackage, setuptools, argparse }: buildPythonPackage rec { +{stdenv, python26Packages }: python26Packages.buildPythonPackage rec { pname = "Jinja2"; version = "2.5.2"; format = "setuptools"; - #pyproject = true; - src = fetchPypi { + src = python26Packages.fetchPypi { inherit pname version; extension = "tar.gz"; hash = "sha256-GQQPAbOp2MY+TVeTb3hxCQgZm2k3CrRKD3QH3YkfAZs="; }; - propagatedBuildInputs = [setuptools argparse]; - - #dependencies = [importlib]; + propagatedBuildInputs = [python26Packages.setuptools python26Packages.argparse]; } diff --git a/libmemcached.nix b/libmemcached.nix new file mode 100644 index 0000000..9e81dc4 --- /dev/null +++ b/libmemcached.nix @@ -0,0 +1,11 @@ +{stdenv, fetchzip, autoreconfHook, perl, memcached}: stdenv.mkDerivation rec { + pname = "libmemcached"; + version = "0.34"; + + src = fetchzip { + url = "https://launchpad.net/" + pname + "/1.0/" + version + "/+download/" + pname + "-" + version + ".tar.gz"; + hash = "sha256-n0eLdK3y6k34tOBTCNY1aPnkOOPgcP63ypNBYJjkfQk="; + }; + + buildInputs = [ autoreconfHook memcached perl]; +} diff --git a/libxml2.nix b/libxml2.nix index 3d972c9..e75ec79 100644 --- a/libxml2.nix +++ b/libxml2.nix @@ -10,15 +10,11 @@ hash = "sha256-5+IWJMbqqcCPJKfDOHdRGv62XbUPOTjp9ZhsqbbHTeg="; }; - #buildInputs = [autoconf269 automake]; buildInputs = [autoreconfHook]; patchPhase = '' export ACLOCAL_PATH=${libtool}/share/aclocal:$ACLOCAL_PATH - export CFLAGS="-Wno-incompatible-pointer-types" ''; - - /*configurePhase = '' - autoreconf - ./configure - '';*/ + env = { + NIX_CFLAGS_COMPILE="-Wno-incompatible-pointer-types"; + }; } diff --git a/libxslt.nix b/libxslt.nix index 0293138..a7f8ad9 100644 --- a/libxslt.nix +++ b/libxslt.nix @@ -1,4 +1,4 @@ -{stdenv, fetchFromGitLab, autoreconfHook, libtool, libxml2, breakpointHook}: stdenv.mkDerivation rec { +{stdenv, fetchFromGitLab, autoreconfHook, libtool, libxml2}: stdenv.mkDerivation rec { pname = "libxslt"; version = "1.1.26"; @@ -11,7 +11,7 @@ }; #buildInputs = [autoconf269 automake]; - buildInputs = [autoreconfHook libxml2 breakpointHook]; + buildInputs = [autoreconfHook libxml2]; patchPhase = '' export ACLOCAL_PATH=${libtool}/share/aclocal:$ACLOCAL_PATH ''; diff --git a/lxml.nix b/lxml.nix index a8bebfe..895ee5b 100644 --- a/lxml.nix +++ b/lxml.nix @@ -1,17 +1,21 @@ -{stdenv, fetchPypi, buildPythonPackage, setuptools, libxml2 }: buildPythonPackage rec { +{stdenv, python26Packages, libxml2, libxslt, zlib}: python26Packages.buildPythonPackage rec { pname = "lxml"; version = "2.2.6"; format = "setuptools"; - #pyproject = true; - src = fetchPypi { + src = python26Packages.fetchPypi { inherit pname version; extension = "tar.gz"; hash = "sha256-f9NuSlY2DNXXMZ41ewSpDixrg26iIMiPlFHDAK4zzF4="; }; - propagatedBuildInputs = [setuptools]; - buildInputs = [libxml2]; + propagatedBuildInputs = [python26Packages.setuptools]; + nativeBuildInputs = [ libxml2 libxslt ]; + buildInputs = [ zlib ]; - #dependencies = [importlib]; + env = { + NIX_CFLAGS_COMPILE="-Wno-incompatible-pointer-types"; + }; + + pythonImportsCheck = [ "lxml" "lxml.etree" ]; } diff --git a/mysql-python.nix b/mysql-python.nix new file mode 100644 index 0000000..d2f066c --- /dev/null +++ b/mysql-python.nix @@ -0,0 +1,17 @@ +{stdenv, python26Packages, mysql}: python26Packages.buildPythonPackage rec { + pname = "MySQL-python"; + version = "1.2.3c1"; + format = "setuptools"; + + src = python26Packages.fetchPypi { + inherit pname version; + extension = "tar.gz"; + hash = "sha256-H6pJd+mFBzHot/ih1YuGJzk6N0RUN4jsQ3+0XgbP5AE="; + }; + + propagatedBuildInputs = [python26Packages.setuptools]; + nativeBuildInputs = [ mysql ]; + buildInputs = [ mysql ]; + + pythonImportsCheck = ["MySQLdb"]; +} diff --git a/mysql.nix b/mysql.nix new file mode 100644 index 0000000..da6be01 --- /dev/null +++ b/mysql.nix @@ -0,0 +1,24 @@ +{stdenv, fetchzip, autoreconfHook, libtool, ncurses, ps, breakpointHook}: stdenv.mkDerivation rec { + pname = "mysql"; + version = "5.1.73"; + + src = fetchzip { + url = "https://downloads.mysql.com/archives/get/p/23/file/" + pname + "-" + version + ".tar.gz"; + hash = "sha256-LBQst5LfINNE65Q9fht7EX5W0NKATqfqabS9EjPwkWQ="; + }; + + patches = [./mysql.patch]; + + nativeBuildInputs = [ps]; + buildInputs = [autoreconfHook ncurses breakpointHook]; + env = { + ACLOCAL_PATH="${libtool}/share/aclocal"; + NIX_CFLAGS_COMPILE="-fpermissive"; + }; + + configureFlags = ["--with-plugins=innobase"]; + + postInstall = '' + ln -s $out/libexec/mysqld $out/bin/mysqld + ''; +} diff --git a/mysql.patch b/mysql.patch new file mode 100644 index 0000000..882028e --- /dev/null +++ b/mysql.patch @@ -0,0 +1,12 @@ +diff --git a/vio/viosocket.c b/vio/viosocket.c +index c969a14..c3d9266 100644 +--- a/vio/viosocket.c ++++ b/vio/viosocket.c +@@ -29,6 +29,7 @@ + #pragma comment(lib, "ws2_32.lib") + #endif + #include "vio_priv.h" ++#include + + + diff --git a/openssl/default.nix b/openssl/default.nix new file mode 100644 index 0000000..82f44c5 --- /dev/null +++ b/openssl/default.nix @@ -0,0 +1,167 @@ +{ lib, stdenv, fetchurl, buildPackages, perl, coreutils +, withCryptodev ? false, cryptodev +, enableSSL2 ? false +, enableSSL3 ? false +, static ? stdenv.hostPlatform.isStatic +# Used to avoid cross compiling perl, for example, in darwin bootstrap tools. +# This will cause c_rehash to refer to perl via the environment, but otherwise +# will produce a perfectly functional openssl binary and library. +, withPerl ? stdenv.hostPlatform == stdenv.buildPlatform +}: + +# Note: this package is used for bootstrapping fetchurl, and thus +# cannot use fetchpatch! All mutable patches (generated by GitHub or +# cgit) that are needed here should be included directly in Nixpkgs as +# files. + +let + common = { version, sha256, patches ? [], withDocs ? false, extraMeta ? {} }: + stdenv.mkDerivation rec { + pname = "openssl"; + inherit version; + + src = fetchurl { + url = "https://www.openssl.org/source/${pname}-${version}.tar.gz"; + inherit sha256; + }; + + inherit patches; + + postPatch = '' + patchShebangs Configure + patchShebangs test/* + for a in test/t* ; do + substituteInPlace "$a" \ + --replace /bin/rm rm + done + ''; + + outputs = [ "bin" "dev" "out" "man" ] ++ lib.optional withDocs "doc"; + setOutputFlags = false; + separateDebugInfo = + !stdenv.hostPlatform.isDarwin && + !(stdenv.hostPlatform.useLLVM or false) && + stdenv.cc.isGNU; + + nativeBuildInputs = [ perl ]; + buildInputs = lib.optional withCryptodev cryptodev + # perl is included to allow the interpreter path fixup hook to set the + # correct interpreter in c_rehash. + ++ lib.optional withPerl perl; + + # TODO(@Ericson2314): Improve with mass rebuild + configurePlatforms = []; + configureScript = { + armv5tel-linux = "./Configure linux-armv4 -march=armv5te"; + armv6l-linux = "./Configure linux-armv4 -march=armv6"; + armv7l-linux = "./Configure linux-armv4 -march=armv7-a"; + x86_64-darwin = "./Configure darwin64-x86_64-cc"; + aarch64-darwin = "./Configure darwin64-arm64-cc"; + x86_64-linux = "./Configure linux-x86_64"; + x86_64-solaris = "./Configure solaris64-x86_64-gcc"; + riscv64-linux = "./Configure linux64-riscv64"; + }.${stdenv.hostPlatform.system} or ( + if stdenv.hostPlatform == stdenv.buildPlatform + then "./config" + else if stdenv.hostPlatform.isBSD && stdenv.hostPlatform.isx86_64 + then "./Configure BSD-x86_64" + else if stdenv.hostPlatform.isBSD && stdenv.hostPlatform.isx86_32 + then "./Configure BSD-x86" + lib.optionalString (stdenv.hostPlatform.parsed.kernel.execFormat.name == "elf") "-elf" + else if stdenv.hostPlatform.isBSD + then "./Configure BSD-generic${toString stdenv.hostPlatform.parsed.cpu.bits}" + else if stdenv.hostPlatform.isMinGW + then "./Configure mingw${lib.optionalString + (stdenv.hostPlatform.parsed.cpu.bits != 32) + (toString stdenv.hostPlatform.parsed.cpu.bits)}" + else if stdenv.hostPlatform.isLinux + then "./Configure linux-generic${toString stdenv.hostPlatform.parsed.cpu.bits}" + else if stdenv.hostPlatform.isiOS + then "./Configure ios${toString stdenv.hostPlatform.parsed.cpu.bits}-cross" + else + throw "Not sure what configuration to use for ${stdenv.hostPlatform.config}" + ); + + # OpenSSL doesn't like the `--enable-static` / `--disable-shared` flags. + dontAddStaticConfigureFlags = true; + configureFlags = [ + "shared" # "shared" builds both shared and static libraries + "--libdir=lib" + "--openssldir=etc/ssl" + ] ++ lib.optionals withCryptodev [ + "-DHAVE_CRYPTODEV" + "-DUSE_CRYPTODEV_DIGESTS" + ] ++ lib.optional enableSSL2 "enable-ssl2" + ++ lib.optional enableSSL3 "enable-ssl3"; + + makeFlags = [ + "MANDIR=$(man)/share/man" + # This avoids conflicts between man pages of openssl subcommands (for + # example 'ts' and 'err') man pages and their equivalent top-level + # command in other packages (respectively man-pages and moreutils). + # This is done in ubuntu and archlinux, and possiibly many other distros. + "MANSUFFIX=ssl" + ]; + + enableParallelBuilding = true; + + postInstall = + lib.optionalString (!static) '' + # If we're building dynamic libraries, then don't install static + # libraries. + if [ -n "$(echo $out/lib/*.so $out/lib/*.dylib $out/lib/*.dll)" ]; then + rm "$out/lib/"*.a + fi + '' + lib.optionalString (!stdenv.hostPlatform.isWindows) + # Fix bin/c_rehash's perl interpreter line + # + # - openssl 1_0_2: embeds a reference to buildPackages.perl + # - openssl 1_1: emits "#!/usr/bin/env perl" + # + # In the case of openssl_1_0_2, reset the invalid reference and let the + # interpreter hook take care of it. + # + # In both cases, if withPerl = false, the intepreter line is expected be + # "#!/usr/bin/env perl" + '' + substituteInPlace $out/bin/c_rehash --replace ${buildPackages.perl}/bin/perl "/usr/bin/env perl" + '' + '' + mkdir -p $bin + mv $out/bin $bin/bin + + mkdir $dev + mv $out/include $dev/ + + # remove dependency on Perl at runtime + rm -r $out/etc/ssl/misc + + rmdir $out/etc/ssl/{certs,private} + ''; + + postFixup = lib.optionalString (!stdenv.hostPlatform.isWindows) '' + # Check to make sure the main output doesn't depend on perl + if grep -r '${buildPackages.perl}' $out; then + echo "Found an erroneous dependency on perl ^^^" >&2 + exit 1 + fi + ''; + + meta = with lib; { + homepage = "https://www.openssl.org/"; + description = "A cryptographic library that implements the SSL and TLS protocols"; + license = licenses.openssl; + platforms = platforms.all; + } // extraMeta; + }; + +in { + + openssl_1_0_2 = common { + version = "1.0.2u"; + sha256 = "ecd0c6ffb493dd06707d38b14bb4d8c2288bb7033735606569d8f90f89669d16"; + patches = [ + ./nix-ssl-cert-file.patch + ./use-etc-ssl-certs.patch + ]; + extraMeta.knownVulnerabilities = [ "Support for OpenSSL 1.0.2 ended with 2019." ]; + }; +} diff --git a/openssl/nix-ssl-cert-file.patch b/openssl/nix-ssl-cert-file.patch new file mode 100644 index 0000000..5765409 --- /dev/null +++ b/openssl/nix-ssl-cert-file.patch @@ -0,0 +1,16 @@ +diff --git a/crypto/x509/by_file.c b/crypto/x509/by_file.c +index e6d0e6e1a6..b89456fd87 100644 +--- a/crypto/x509/by_file.c ++++ b/crypto/x509/by_file.c +@@ -97,7 +97,10 @@ static int by_file_ctrl(X509_LOOKUP *ctx, int cmd, const char *argp, + switch (cmd) { + case X509_L_FILE_LOAD: + if (argl == X509_FILETYPE_DEFAULT) { +- file = ossl_safe_getenv(X509_get_default_cert_file_env()); ++ file = ossl_safe_getenv("NIX_SSL_CERT_FILE"); ++ ++ if (!file) ++ file = ossl_safe_getenv(X509_get_default_cert_file_env()); + + if (file) + ok = (X509_load_cert_crl_file(ctx, file, diff --git a/openssl/use-etc-ssl-certs.patch b/openssl/use-etc-ssl-certs.patch new file mode 100644 index 0000000..813c6bd --- /dev/null +++ b/openssl/use-etc-ssl-certs.patch @@ -0,0 +1,13 @@ +diff -ru -x '*~' openssl-1.0.1r-orig/crypto/cryptlib.h openssl-1.0.1r/crypto/cryptlib.h +--- openssl-1.0.1r-orig/crypto/cryptlib.h 2016-01-28 14:38:30.000000000 +0100 ++++ openssl-1.0.1r/crypto/cryptlib.h 2016-02-03 12:54:29.193165176 +0100 +@@ -81,8 +81,8 @@ + + # ifndef OPENSSL_SYS_VMS + # define X509_CERT_AREA OPENSSLDIR + # define X509_CERT_DIR OPENSSLDIR "/certs" +-# define X509_CERT_FILE OPENSSLDIR "/cert.pem" ++# define X509_CERT_FILE "/etc/ssl/certs/ca-certificates.crt" + # define X509_PRIVATE_DIR OPENSSLDIR "/private" + # else + # define X509_CERT_AREA "SSLROOT:[000000]" diff --git a/overlay.nix b/overlay.nix index a151c1e..e358076 100644 --- a/overlay.nix +++ b/overlay.nix @@ -5,14 +5,34 @@ bommels = pkgs.lib.makeScope pkgs.newScope (self: rec { autoreconfHook = pkgs.autoreconfHook269.override { automake = automake; }; + + openssl = (pkgs.callPackage ./openssl/default.nix { }).openssl_1_0_2; + libxml2 = pkgs.callPackage ./libxml2.nix { inherit autoreconfHook; }; libxslt = pkgs.callPackage ./libxslt.nix { inherit autoreconfHook libxml2; }; + libmemcached = pkgs.callPackage ./libmemcached.nix { inherit autoreconfHook; }; + mysql = pkgs.callPackage ./mysql.nix { inherit autoreconfHook; }; - pythonInterpreters = self.callPackage ./python-interpreters.nix { inherit nixpkgsPath; }; + pythonInterpreters = self.callPackage ./python-interpreters.nix { bopenssl = openssl; inherit nixpkgsPath; }; inherit (pythonInterpreters) python26; python26Packages = python26.pkgs; pythonPackages = python26Packages; + jinja2 = self.callPackage ./jinja2.nix { inherit python26Packages; }; + lxml = self.callPackage ./lxml.nix { inherit python26Packages libxml2 libxslt; }; + pylibmc = self.callPackage ./pylibmc.nix { inherit python26Packages libmemcached; }; + coverage = self.callPackage ./coverage.nix { inherit python26Packages; }; + pil = self.callPackage ./pil.nix { inherit python26Packages; }; + django-pylibmc = self.callPackage ./django-pylibmc.nix { inherit python26Packages; }; + mysql-python = self.callPackage ./mysql-python.nix { inherit python26Packages mysql; }; + #python-magic = self.callPackage ./python-magic.nix { inherit python26Packages; }; + + #gitModulesFixer = pkgs.callPackage ./gitModulesFixer.nix { }; + + #service1 = pkgs.callPackage ./service1.nix { }; + service1 = pkgs.callPackage ./runService1.nix { inherit jinja2 mysql-python pil lxml mysql; }; + service2 = pkgs.callPackage ./runService2.nix { }; + some-package = pkgs.callPackage ./some-package.nix { inherit pythonPackages; }; }); in diff --git a/pil.nix b/pil.nix new file mode 100644 index 0000000..20904c0 --- /dev/null +++ b/pil.nix @@ -0,0 +1,20 @@ +{stdenv, fetchzip, python26Packages, zlib, libjpeg}: python26Packages.buildPythonPackage rec { + pname = "PIL"; + version = "1.1.7"; + format = "setuptools"; + + src = fetchzip { + url = "https://launchpad.net/ubuntu/+archive/primary/+sourcefiles/python-imaging/" + version + "-4ubuntu0.12.04.3/python-imaging_" + version + ".orig.tar.gz"; + hash = "sha256-zH7hHIqP5UwBVFTdg5IvvckcCFI285Do/YSeqhzsTY0="; + }; + + propagatedBuildInputs = [python26Packages.setuptools]; + #nativeBuildInputs = [ libxml2 libxslt ]; + buildInputs = [ zlib libjpeg ]; + + env = { + NIX_CFLAGS_COMPILE="-Wno-incompatible-pointer-types"; + }; + + #pythonImportsCheck = [ "Image" ]; +} diff --git a/pylibmc.nix b/pylibmc.nix new file mode 100644 index 0000000..aeb40dc --- /dev/null +++ b/pylibmc.nix @@ -0,0 +1,16 @@ +{stdenv, python26Packages, libmemcached}: python26Packages.buildPythonPackage rec { + pname = "pylibmc"; + version = "0.9"; + format = "setuptools"; + + src = python26Packages.fetchPypi { + inherit pname version; + extension = "tar.gz"; + hash = "sha256-ZALQoRAFX2/BZG/pr+XVbYPxaHATIjJAnylcoRa67vI="; + }; + + propagatedBuildInputs = [python26Packages.setuptools]; + buildInputs = [ libmemcached ]; + + pythonImportsCheck = ["pylibmc"]; +} diff --git a/python-imports-check-hook.sh b/python-imports-check-hook.sh index 11b84c0..017df30 100644 --- a/python-imports-check-hook.sh +++ b/python-imports-check-hook.sh @@ -1,17 +1,17 @@ # shellcheck shell=bash # Setup hook for checking whether Python imports succeed -echo "Sourcing python-imports-check-hook.sh" +echo "TRACE: Sourcing python-imports-check-hook.sh" pythonImportsCheckPhase() { - echo "Executing pythonImportsCheckPhase" + echo "TRACE: Executing pythonImportsCheckPhase" if [[ -n "${pythonImportsCheck[*]-}" ]]; then - echo "Check whether the following modules can be imported: ${pythonImportsCheck[*]}" + echo "INFO: Check whether the following modules can be imported: ${pythonImportsCheck[*]}" # shellcheck disable=SC2154 pythonImportsCheckOutput="$out" if [[ -n "${python-}" ]]; then - echo "Using python specific output \$python for imports check" + echo "INFO: Using python specific output \$python for imports check" pythonImportsCheckOutput=$python fi export PYTHONPATH="$pythonImportsCheckOutput/@pythonSitePackages@:$PYTHONPATH" diff --git a/python-interpreters.nix b/python-interpreters.nix index c7efa22..bd06d24 100644 --- a/python-interpreters.nix +++ b/python-interpreters.nix @@ -1,5 +1,6 @@ { nixpkgsPath, + bopenssl, __splicedPackages, callPackage, fetchzip, @@ -33,6 +34,7 @@ }).override { rebuildBytecode = false; pythonAttr = "python26"; + openssl = bopenssl; packageOverrides = import ./python-overrides.nix; #packageOverridesss = _: super: { # setupTools = "lol"; diff --git a/python-overrides.nix b/python-overrides.nix index 5e5d7fd..d2bbf71 100644 --- a/python-overrides.nix +++ b/python-overrides.nix @@ -46,9 +46,4 @@ rec { setuptools = toPythonModule (callPackage ./setuptools.nix { }); wheel = callPackage ./python26/wheel.nix { }; #pip = pip.overridePythonAttrs (callPackage pipFunction {}); - - bommels = { - jinja2 = callPackage ./jinja2.nix { }; - lxml = callPackage ./lxml.nix { }; - }; } diff --git a/result b/result deleted file mode 120000 index 44d276f..0000000 --- a/result +++ /dev/null @@ -1 +0,0 @@ -/nix/store/3mdywqnsfmphw8jg4x8jk4cp7zi2pg5n-libxslt-1.1.26 \ No newline at end of file diff --git a/runService1.nix b/runService1.nix new file mode 100644 index 0000000..5b4427a --- /dev/null +++ b/runService1.nix @@ -0,0 +1,144 @@ +{stdenv, writeShellApplication, git, python26, jinja2, mysql-python, pil, lxml, file, mysql, html-tidy, wget}: writeShellApplication rec { + name = "service1"; + + + #propagatedBuildInputs = [python26Packages.setuptools]; + #nativeBuildInputs = [ jinja2 ]; + #buildInputs = [ jinja2 ]; + runtimeInputs = [git (python26.withPackages(ps: [jinja2 mysql-python pil lxml])) file mysql html-tidy wget]; + + #env = { + # NIX_CFLAGS_COMPILE="-Wno-incompatible-pointer-types"; + #}; + + text = '' + export LIBMAGIC_PATH="${file}/lib/libmagic.so.1" + export LIBTIDY_PATH="${html-tidy}/lib/libtidy.so" + + if [ ! -d "mdn" ]; then + mkdir mdn + cd mdn + + git clone https://github.com/mdn/kuma.git --progress + cd kuma + git switch dc45adde8b47269b8f088893fa14978b0c01a40a --detach --progress + sed -i 's#git://#https://#g' .gitmodules + git submodule update --init --progress + sed -i 's#git://#https://#g' ./vendor/.gitmodules + git submodule update --init --recursive --progress + + cd ./vendor/src/python-magic + content="diff --git a/magic.py b/magic.py +index 53a91fd..97c19dc 100644 +--- a/magic.py ++++ b/magic.py +@@ -112,6 +112,8 @@ dll = ctypes.util.find_library('magic') or ctypes.util.find_library('magic1') + # This is necessary because find_library returns None if it doesn't find the library + if dll: + libmagic = ctypes.CDLL(dll) ++else: ++ libmagic = ctypes.CDLL(os.environ[\"LIBMAGIC_PATH\"]) + + if not libmagic or not libmagic._name: + import sys +" + echo "$content" > libmagic.diff + git apply libmagic.diff + cd ../../.. + + cd ./vendor/src/pytidylib + content="diff --git a/tidylib/__init__.py b/tidylib/__init__.py +index b5b4367..091445b 100644 +--- a/tidylib/__init__.py ++++ b/tidylib/__init__.py +@@ -22,6 +22,7 @@ import ctypes + import threading + import re + import platform ++import os + from tidylib.sink import create_sink, destroy_sink + + __all__ = ['tidy_document', 'tidy_fragment', 'release_tidy_doc'] +@@ -30,7 +31,7 @@ __all__ = ['tidy_document', 'tidy_fragment', 'release_tidy_doc'] + # Constants + + LIB_NAMES = ['libtidy', 'libtidy.so', 'libtidy-0.99.so.0', 'cygtidy-0-99-0', +- 'tidylib', 'libtidy.dylib', 'tidy'] ++ 'tidylib', 'libtidy.dylib', 'tidy', os.environ[\"LIBTIDY_PATH\"]] + ENOMEM = -12 + RE_BODY = re.compile(r\"[\r\n]*(.+?)\", re.S) + BASE_OPTIONS = { +" + echo "$content" > libtidy.diff + git apply libtidy.diff + cd ../../.. + + cd ../.. + fi + + cd mdn + dbDir="$(pwd)/db" + + if [ ! -d "product_details_json" ]; then + mkdir product_details_json + + cd kuma + content="from settings import * +DATABASES = { + 'default': { + 'NAME': 'kuma', + 'ENGINE': 'django.db.backends.mysql', + 'HOST': 'localhost', + 'USER': 'kuma', + 'PASSWORD': 'bommels', + 'OPTIONS': {'init_command': 'SET storage_engine=InnoDB'}, + 'TEST_CHARSET': 'utf8', + 'TEST_COLLATION': 'utf8_unicode_ci', + }, +} +DEBUG = True +TEMPLATE_DEBUG = DEBUG +SERVE_MEDIA = True +SITE_URL = 'http://localhost:8000' +PROTOCOL = 'http://' +DOMAIN = 'localhost' +PORT = 8000 +SESSION_COOKIE_SECURE = False +SESSION_EXPIRE_AT_BROWSER_CLOSE = False" + echo "$content" > settings_local.py + cd .. + + mkdir "$dbDir" + mysql_install_db --datadir="$dbDir" + mysqld --datadir="$dbDir" & + dbServer="$!" + sleep 3 + echo "CREATE USER 'kuma'@'localhost' IDENTIFIED BY 'bommels';" | mysql -u root + echo "CREATE DATABASE kuma;" | mysql -u root + echo "GRANT ALL PRIVILEGES ON kuma.* TO 'kuma'@'localhost';" | mysql -u root + + cd kuma + ./manage.py syncdb + ./manage.py migrate + cd .. + + cd product_details_json + wget https://product-details.mozilla.org/1.0/languages.json + + kill "$dbServer" + sleep 3 + + cd .. + fi + + cd kuma + mysqld --datadir="$dbDir" & + dbServer="$!" + sleep 3 + + python ./manage.py runserver --noreload + + kill "$dbServer" + sleep 6 + ''; +} diff --git a/runService2.nix b/runService2.nix new file mode 100644 index 0000000..04e6ced --- /dev/null +++ b/runService2.nix @@ -0,0 +1,30 @@ +{stdenv, writeShellApplication, git, python27}: writeShellApplication rec { + name = "service1"; + + + #propagatedBuildInputs = [python26Packages.setuptools]; + #nativeBuildInputs = [ jinja2 ]; + #buildInputs = [ jinja2 ]; + runtimeInputs = [git (python27.withPackages(ps: []))]; + + #env = { + # NIX_CFLAGS_COMPILE="-Wno-incompatible-pointer-types"; + #}; + + text = '' + if [ ! -d "amo" ]; then + mkdir amo + cd amo + + git clone https://github.com/mozilla/addons-server.git --progress + git switch 8b4423547f932b2d9fa2b5a9c81d399bdc29bd6e --detach --progress + cd addons-server + + cd ../.. + fi + + cd amo + + python ./manage.py + ''; +} diff --git a/service1.nix b/service1.nix new file mode 100644 index 0000000..7b6b8e7 --- /dev/null +++ b/service1.nix @@ -0,0 +1,52 @@ +{stdenv, fetchFromGitHub}: stdenv.mkDerivation rec { + name = "service1"; + + #propagatedBuildInputs = [python26Packages.setuptools]; + #nativeBuildInputs = [ cacert ]; + + src = fetchFromGitHub { + owner = "Bommels05"; + repo = "CraftTweakerGUI"; + rev = "a1ea013754e201e98c3930d65d03f8fb5dcd66f3"; + hash = ""; + leaveDotGit = true; + + postFetch = '' + echo test! + cd $out + rm -r ./* + git clone https://github.com/mdn/kuma.git --progress + cd kuma + git switch dc45adde8b47269b8f088893fa14978b0c01a40a --detach --progress + sed -i 's#git://#https://#g' .gitmodules + git submodule update --init --progress + sed -i 's#git://#https://#g' ./vendor/.gitmodules + git submodule update --init --recursive --progress + ''; + }; + + #outputHashMode = "recursive"; + #outputHashAlgo = "sha256"; + #outputHash = ""; + + #dontUnpack = true; + dontConfigure = true; + dontFixup = true; + + #buildPhase = '' + # export NIX_SSL_CERT_FILE="${cacert}/etc/ssl/certs/ca-bundle.crt" + # ${git}/bin/git clone https://github.com/mdn/kuma.git --progress + # cd kuma + # ${git}/bin/git switch dc45adde8b47269b8f088893fa14978b0c01a40a --detach --progress + # sed -i 's#git://#https://#g' .gitmodules + # ${git}/bin/git submodule update --init --progress + # sed -i 's#git://#https://#g' ./vendor/.gitmodules + # ${git}/bin/git submodule update --init --recursive --progress + #''; + + installPhase = '' + mkdir -p $out/ + cp -r ./ $out/ + ''; + +}