summary refs log tree commit diff
path: root/pkgs/build-support/fetchadc
diff options
context:
space:
mode:
authorDaniel Peebles <pumpkin@me.com>2014-09-30 01:03:55 -0400
committerMateusz Kowalczyk <fuuzetsu@fuuzetsu.co.uk>2014-10-01 02:10:31 +0100
commit0e9cf136af70220768af6f252d0e8151e312b714 (patch)
tree70a9f78c9071776d28ea8b1100edd4a91a1d761b /pkgs/build-support/fetchadc
parentd815b900f40829f463e1a9b034e68b1333e2bf7a (diff)
downloadnixlib-0e9cf136af70220768af6f252d0e8151e312b714.tar
nixlib-0e9cf136af70220768af6f252d0e8151e312b714.tar.gz
nixlib-0e9cf136af70220768af6f252d0e8151e312b714.tar.bz2
nixlib-0e9cf136af70220768af6f252d0e8151e312b714.tar.lz
nixlib-0e9cf136af70220768af6f252d0e8151e312b714.tar.xz
nixlib-0e9cf136af70220768af6f252d0e8151e312b714.tar.zst
nixlib-0e9cf136af70220768af6f252d0e8151e312b714.zip
A simple ADC downloader for upcoming darwin awesomeness
Closes #4327
Diffstat (limited to 'pkgs/build-support/fetchadc')
-rw-r--r--pkgs/build-support/fetchadc/builder.sh7
-rw-r--r--pkgs/build-support/fetchadc/default.nix45
2 files changed, 52 insertions, 0 deletions
diff --git a/pkgs/build-support/fetchadc/builder.sh b/pkgs/build-support/fetchadc/builder.sh
new file mode 100644
index 000000000000..ceeaa9213d65
--- /dev/null
+++ b/pkgs/build-support/fetchadc/builder.sh
@@ -0,0 +1,7 @@
+source $stdenv/setup
+
+loginpage=`curl --insecure -s -L -b cookies.txt "$url"`
+
+[[ $loginpage =~ form[^\>]+action=\"([^\"]+)\" ]] && loginurl=${BASH_REMATCH[1]}
+
+curl  --insecure -s --output "$out" -L -b cookies.txt --data "appleId=${adc_user}&accountPassword=${adc_pass}" "https://idmsa.apple.com/IDMSWebAuth/${loginurl}"
diff --git a/pkgs/build-support/fetchadc/default.nix b/pkgs/build-support/fetchadc/default.nix
new file mode 100644
index 000000000000..efd477d59889
--- /dev/null
+++ b/pkgs/build-support/fetchadc/default.nix
@@ -0,0 +1,45 @@
+{ stdenv, curl, adc_user, adc_pass }:
+
+let
+  impureEnvVars = [
+    # We borrow these environment variables from the caller to allow
+    # easy proxy configuration.  This is impure, but a fixed-output
+    # derivation like fetchurl is allowed to do so since its result is
+    # by definition pure.
+    "http_proxy" "https_proxy" "ftp_proxy" "all_proxy" "no_proxy"
+  ];
+in
+
+{ # URL to fetch.
+  url
+
+  # Hash of the downloaded file
+, sha256
+
+, # Additional curl options needed for the download to succeed.
+  curlOpts ? ""
+
+, # Name of the file.  If empty, use the basename of `url' (or of the
+  # first element of `urls').
+  name ? ""
+}:
+
+stdenv.mkDerivation {
+  name    = if name != "" then name else baseNameOf (toString url);
+  builder = ./builder.sh;
+
+  buildInputs = [ curl ];
+
+  meta = {
+    # Password-guarded files from ADC are certainly unfree, as far as we're concerned!
+    license = stdenv.lib.licenses.unfree;
+  };
+
+  outputHashAlgo = "sha256";
+  outputHash     =  sha256;
+  outputHashMode = "flat";
+
+  inherit curlOpts url adc_user adc_pass;
+
+  preferLocalBuild = true;
+}
\ No newline at end of file