diff options
author | Robin Gloster <mail@glob.in> | 2016-07-19 10:37:02 +0000 |
---|---|---|
committer | Robin Gloster <mail@glob.in> | 2016-07-19 10:37:02 +0000 |
commit | 203846b9de3bc67e77c93be9d111408286a17d5d (patch) | |
tree | 3306a68a635fad0de834440c25f7e1b69b1e4b10 /pkgs/build-support | |
parent | 6539901c7f5eeb18cf5e9a493c230a912ff27f82 (diff) | |
parent | b54009fdfb7951bb5423c4fabcb28b70581b5ba8 (diff) | |
download | nixlib-203846b9de3bc67e77c93be9d111408286a17d5d.tar nixlib-203846b9de3bc67e77c93be9d111408286a17d5d.tar.gz nixlib-203846b9de3bc67e77c93be9d111408286a17d5d.tar.bz2 nixlib-203846b9de3bc67e77c93be9d111408286a17d5d.tar.lz nixlib-203846b9de3bc67e77c93be9d111408286a17d5d.tar.xz nixlib-203846b9de3bc67e77c93be9d111408286a17d5d.tar.zst nixlib-203846b9de3bc67e77c93be9d111408286a17d5d.zip |
Merge remote-tracking branch 'upstream/master' into hardened-stdenv
Diffstat (limited to 'pkgs/build-support')
-rw-r--r-- | pkgs/build-support/docker/tarsum.go | 32 | ||||
-rw-r--r-- | pkgs/build-support/fetchmavenartifact/default.nix | 75 | ||||
-rw-r--r-- | pkgs/build-support/fetchurl/mirrors.nix | 1 |
3 files changed, 92 insertions, 16 deletions
diff --git a/pkgs/build-support/docker/tarsum.go b/pkgs/build-support/docker/tarsum.go index 4c25f11b71e0..ad33bbac75b4 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, true, 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)) +} 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/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/ |