From 23e9e33975bf560ec3fd6e5b2e01d7cd9ce1c14e Mon Sep 17 00:00:00 2001 From: Nathan Zadoks Date: Sat, 2 Jul 2016 02:20:02 -0400 Subject: dockerTools: format tarsum.go with gofmt Nearly all Go code on this earth is formatted with gofmt, and it's somewhat surprising to find a Go file that isn't formatted accordingly. --- pkgs/build-support/docker/tarsum.go | 32 ++++++++++++++++---------------- 1 file changed, 16 insertions(+), 16 deletions(-) (limited to 'pkgs/build-support') diff --git a/pkgs/build-support/docker/tarsum.go b/pkgs/build-support/docker/tarsum.go index 4c25f11b71e0..81a3341fff03 100644 --- a/pkgs/build-support/docker/tarsum.go +++ b/pkgs/build-support/docker/tarsum.go @@ -1,24 +1,24 @@ package main import ( - "tarsum" - "io" - "io/ioutil" - "fmt" - "os" + "fmt" + "io" + "io/ioutil" + "os" + "tarsum" ) func main() { - ts, err := tarsum.NewTarSum(os.Stdin, false, tarsum.Version1) - if err != nil { - fmt.Println(err) - os.Exit(1) - } + ts, err := tarsum.NewTarSum(os.Stdin, false, tarsum.Version1) + if err != nil { + fmt.Println(err) + os.Exit(1) + } - if _, err = io.Copy(ioutil.Discard, ts); err != nil { - fmt.Println(err) - os.Exit(1) - } + if _, err = io.Copy(ioutil.Discard, ts); err != nil { + fmt.Println(err) + os.Exit(1) + } - fmt.Println(ts.Sum(nil)) -} \ No newline at end of file + fmt.Println(ts.Sum(nil)) +} -- cgit 1.4.1 From b9284e445b3d27532c3493eb0fc09822b949e817 Mon Sep 17 00:00:00 2001 From: Nathan Zadoks Date: Sat, 2 Jul 2016 02:21:20 -0400 Subject: dockerTools: disable compression in tarsum.go Previously, tarsum would compress the (discarded) tarball produced. That's a waste of CPU, and a waste of time. --- pkgs/build-support/docker/tarsum.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'pkgs/build-support') diff --git a/pkgs/build-support/docker/tarsum.go b/pkgs/build-support/docker/tarsum.go index 81a3341fff03..ad33bbac75b4 100644 --- a/pkgs/build-support/docker/tarsum.go +++ b/pkgs/build-support/docker/tarsum.go @@ -9,7 +9,7 @@ import ( ) func main() { - ts, err := tarsum.NewTarSum(os.Stdin, false, tarsum.Version1) + ts, err := tarsum.NewTarSum(os.Stdin, true, tarsum.Version1) if err != nil { fmt.Println(err) os.Exit(1) -- cgit 1.4.1 From c4fa18b7a2f64f6aa01fb83fc80069b921c45372 Mon Sep 17 00:00:00 2001 From: J Phani Mahesh Date: Fri, 15 Jul 2016 13:20:35 +0530 Subject: mirrors: add downloads.sourceforge.net downloads.sourceforge.net is the official way to download tarballs from SourceForge. However, it is reported as unreliable due to SF's weird load balancing system. This commit gives the official mirror utmost priority, and will use other configured mirrors (which may be temporary) as a fallback only when the official one can't be reached/download fails/hangs. References: NixOs/nixpkgs#16900 --- pkgs/build-support/fetchurl/mirrors.nix | 1 + 1 file changed, 1 insertion(+) (limited to 'pkgs/build-support') diff --git a/pkgs/build-support/fetchurl/mirrors.nix b/pkgs/build-support/fetchurl/mirrors.nix index d97ecb32be5d..68244a43e58f 100644 --- a/pkgs/build-support/fetchurl/mirrors.nix +++ b/pkgs/build-support/fetchurl/mirrors.nix @@ -10,6 +10,7 @@ rec { # SourceForge. sourceforge = [ + http://downloads.sourceforge.net/ http://prdownloads.sourceforge.net/ http://heanet.dl.sourceforge.net/sourceforge/ http://surfnet.dl.sourceforge.net/sourceforge/ -- cgit 1.4.1 From e54ec2f907e8980027ba040f11375adac478cc84 Mon Sep 17 00:00:00 2001 From: Renzo Carbonara Date: Tue, 19 Jul 2016 04:48:36 -0300 Subject: fetchMavenArtifact: init (#16825) fetchMavenArtifact downloads a Maven artifact given a group id, an artifact id, and a version. Example usage: org_apache_httpcomponents_httpclient_4_5_2 = fetchMavenArtifact { groupId = "org.apache.httpcomponents"; artifactId = "httpclient"; version = "4.5.2"; sha256 = "0ms00zc28pwqk83nwwbafhq6p8zci9mrjzbqalpn6v0d80hwdzqd"; # Optionally: repos = [ ... urls to some Maven repos to use ... ]; # Optionally: url, urls - pointing directly to a specific jar url. }; Now `org_apache_httpcomponents_httpclient_4_5_2.jar` points to the downloaded JAR file, while `org_apache_httpcomponents_httpclient_4_5_2` refers to a derivation that when used used in `buildInputs` will be automatically added to the Java classpath. --- pkgs/build-support/fetchmavenartifact/default.nix | 75 +++++++++++++++++++++++ pkgs/top-level/all-packages.nix | 2 + 2 files changed, 77 insertions(+) create mode 100644 pkgs/build-support/fetchmavenartifact/default.nix (limited to 'pkgs/build-support') diff --git a/pkgs/build-support/fetchmavenartifact/default.nix b/pkgs/build-support/fetchmavenartifact/default.nix new file mode 100644 index 000000000000..a9c53249ae81 --- /dev/null +++ b/pkgs/build-support/fetchmavenartifact/default.nix @@ -0,0 +1,75 @@ +# Adaptation of the MIT-licensed work on `sbt2nix` done by Charles O'Farrell + +{ fetchurl, stdenv }: +let + defaultRepos = [ + http://central.maven.org/maven2 + http://oss.sonatype.org/content/repositories/releases + http://oss.sonatype.org/content/repositories/public + http://repo.typesafe.com/typesafe/releases + ]; +in + +args@ +{ # Example: "org.apache.httpcomponents" + groupId +, # Example: "httpclient" + artifactId +, # Example: "4.3.6" + version +, # List of maven repositories from where to fetch the artifact. + # Example: [ http://oss.sonatype.org/content/repositories/public ]. + repos ? defaultRepos + # The `url` and `urls` parameters, if specified should point to the JAR + # file and will take precedence over the `repos` parameter. Only one of `url` + # and `urls` can be specified, not both. +, url ? "" +, urls ? [] +, # The rest of the arguments are just forwarded to `fetchurl`. + ... +}: + +# only one of url and urls can be specified at a time. +assert (url == "") || (urls == []); +# if repos is empty, then url or urls must be specified. +assert (repos != []) || (url != "") || (urls != []); + + +let + name_ = + with stdenv.lib; concatStrings [ + (replaceChars ["."] ["_"] groupId) "_" + (replaceChars ["."] ["_"] artifactId) "-" + version + ]; + mkJarUrl = repoUrl: + with stdenv.lib; concatStringsSep "/" [ + (removeSuffix "/" repoUrl) + (replaceChars ["."] ["/"] groupId) + artifactId + version + "${artifactId}-${version}.jar" + ]; + urls_ = + if url != "" then [url] + else if urls != [] then urls + else map mkJarUrl repos; + jar = + fetchurl ( + builtins.removeAttrs args ["groupId" "artifactId" "version" "repos" "url" ] + // { urls = urls_; name = "${name_}.jar"; } + ); +in + stdenv.mkDerivation { + name = name_; + phases = "installPhase fixupPhase"; + # By moving the jar to $out/share/java we make it discoverable by java + # packages packages that mention this derivation in their buildInputs. + installPhase = '' + mkdir -p $out/share/java + ln -s ${jar} $out/share/java + ''; + # We also add a `jar` attribute that can be used to easily obtain the path + # to the downloaded jar file. + passthru.jar = jar; + } diff --git a/pkgs/top-level/all-packages.nix b/pkgs/top-level/all-packages.nix index 4a707de57177..f694349f9a3d 100644 --- a/pkgs/top-level/all-packages.nix +++ b/pkgs/top-level/all-packages.nix @@ -167,6 +167,8 @@ in fetchmtn = callPackage ../build-support/fetchmtn (config.fetchmtn or {}); + fetchMavenArtifact = callPackage ../build-support/fetchmavenartifact { }; + packer = callPackage ../development/tools/packer { }; fetchpatch = callPackage ../build-support/fetchpatch { }; -- cgit 1.4.1