Skip to content

Commit

Permalink
Merging nix to master
Browse files Browse the repository at this point in the history
  • Loading branch information
mbrock committed Jun 12, 2018
2 parents 196b61f + 9cebe3f commit 3d374c1
Show file tree
Hide file tree
Showing 120 changed files with 9,414 additions and 0 deletions.
36 changes: 36 additions & 0 deletions nix/.buildkite/pipeline.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
steps:
- label: Build stable Linux
command: nix-build release.nix -A dapphub.linux.stable --no-out-link
agents:
linux: 'true'
- label: Build stable Darwin
command: nix-build release.nix -A dapphub.darwin.stable --no-out-link
agents:
mac: 'true'
- wait
- label: Sign stable Linux
command: nix-build release.nix -A dapphub.linux.stable -o nixout && nix sign-paths -r -v -k /var/lib/buildkite-agent/nix-key.sk ./nixout*
agents:
linux: 'true'
- label: Sign stable Darwin
command: nix-build release.nix -A dapphub.darwin.stable -o nixout && nix sign-paths -r -v -k /Users/administrator/nix-key.sk ./nixout*
agents:
mac: 'true'
- wait
- label: Upload stable Linux
command: nix-build release.nix -A dapphub.linux.stable -o nixout && nix copy -v --to s3://dapphub-nix-cache ./nixout*
agents:
linux: 'true'
- label: Upload stable Darwin
command: nix-build release.nix -A dapphub.darwin.stable -o nixout && nix copy -v --to s3://dapphub-nix-cache ./nixout*
agents:
mac: 'true'
- wait
- label: Update channel
command:
- 'tar --exclude-vcs --transform="s|^|nixpkgs-dapphub/|" -cf /tmp/nixexprs.tar *'
- 'xz -f /tmp/nixexprs.tar'
- 'aws s3 cp --acl public-read /tmp/nixexprs.tar.xz s3://dapphub-nix-cache/pkgs/dapphub/nixexprs.tar.xz'
agents:
linux: 'true'
- wait
76 changes: 76 additions & 0 deletions nix/.gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
[submodule "nixpkgs"]
path = nixpkgs
url = https://github.com/dapphub/nixpkgs
branch = carnix
[submodule "dappsys/ds-auth"]
path = dappsys/ds-auth
url = https://github.com/dapphub/ds-auth
branch = dappnix
[submodule "dappsys/erc20"]
path = dappsys/erc20
url = https://github.com/dapphub/erc20
branch = dappnix
[submodule "dappsys/ds-exec"]
path = dappsys/ds-exec
url = https://github.com/dapphub/ds-exec
branch = dappnix
[submodule "dappsys/ds-math"]
path = dappsys/ds-math
url = https://github.com/dapphub/ds-math
branch = dappnix
[submodule "dappsys/ds-note"]
path = dappsys/ds-note
url = https://github.com/dapphub/ds-note
branch = dappnix
[submodule "dappsys/ds-stop"]
path = dappsys/ds-stop
url = https://github.com/dapphub/ds-stop
branch = dappnix
[submodule "dappsys/ds-test"]
path = dappsys/ds-test
url = https://github.com/dapphub/ds-test
branch = dappnix
[submodule "dappsys/ds-warp"]
path = dappsys/ds-warp
url = https://github.com/dapphub/ds-warp
branch = dappnix
[submodule "dappsys/ds-cache"]
path = dappsys/ds-cache
url = https://github.com/dapphub/ds-cache
branch = dappnix
[submodule "dappsys/ds-chief"]
path = dappsys/ds-chief
url = https://github.com/dapphub/ds-chief
branch = dappnix
[submodule "dappsys/ds-group"]
path = dappsys/ds-group
url = https://github.com/dapphub/ds-group
branch = dappnix
[submodule "dappsys/ds-guard"]
path = dappsys/ds-guard
url = https://github.com/dapphub/ds-guard
branch = dappnix
[submodule "dappsys/ds-proxy"]
path = dappsys/ds-proxy
url = https://github.com/dapphub/ds-proxy
branch = dappnix
[submodule "dappsys/ds-roles"]
path = dappsys/ds-roles
url = https://github.com/dapphub/ds-roles
branch = dappnix
[submodule "dappsys/ds-thing"]
path = dappsys/ds-thing
url = https://github.com/dapphub/ds-thing
branch = dappnix
[submodule "dappsys/ds-token"]
path = dappsys/ds-token
url = https://github.com/dapphub/ds-token
branch = dappnix
[submodule "dappsys/ds-value"]
path = dappsys/ds-value
url = https://github.com/dapphub/ds-value
branch = dappnix
[submodule "dappsys/ds-vault"]
path = dappsys/ds-vault
url = https://github.com/dapphub/ds-vault
branch = dappnix
22 changes: 22 additions & 0 deletions nix/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
This license ONLY applies to source code of the `overlay` directory,
and not to any of the upstream `nixpkgs` or any of the packages built
by these build specifications.

Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:

The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
8 changes: 8 additions & 0 deletions nix/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# Dapphub's Nixpkgs channel

This directory can act as a root `<nixpkgs>`. We use a submodule to
pin a specific version of the upstream, and our `default.nix` loads
that, configured with our overlay.

You can also use the `overlay` directory as an overlay on whatever
version of nixpkgs you wish.
3 changes: 3 additions & 0 deletions nix/bump
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#!/usr/bin/env bash
cd "${0%/*}"
nix-shell -p bash nix-prefetch-scripts curl jshon jq --run ./bump.sh
62 changes: 62 additions & 0 deletions nix/bump-one.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/usr/bin/env bash
set -eu

exec > >(sed "s/^/${1/\//\\\/}: /") 2> >(sed >&2 "s/^/${1/\//\\\/}: /")

GET() {
curl -s -H "Authorization: token ${GITHUB_TOKEN?Need OAuth token}" "$@"
}

echo "bumping"
pkg="$1"
name=$(basename "$pkg")
tag=$(GET https://api.github.com/repos/"$pkg"/tags?per_page=1 | jshon -e 0)
version=$(jshon -e name -u <<<"$tag")
taghash=$(jshon -e commit -e sha -u <<<"$tag")
head=$(GET https://api.github.com/repos/"$pkg"/commits?per_page=1 | jshon -e 0)
headhash=$(jshon -e sha -u <<<"$head")

echo "stable $version, master $headhash"

tagsha256=$(
nix-prefetch-url \
--unpack \
https://github.com/"$pkg"/archive/"$version".tar.gz 2>/dev/null)

headsha256=$(
nix-prefetch-url \
--unpack \
https://github.com/"$pkg"/archive/"$headhash".tar.gz 2>/dev/null)

tree=$(GET https://api.github.com/repos/"$pkg"/git/trees/"$taghash")
nix=$(jq -r <<<"$tree" '.tree | .[] | select(.path == "default.nix") | .url')
GET "$nix" | jshon -e content -u | base64 -d > overlay/upstream/stable/$name.nix

tree=$(GET https://api.github.com/repos/"$pkg"/git/trees/"$headhash")
nix=$(jq -r <<<"$tree" '.tree | .[] | select(.path == "default.nix") | .url')
GET "$nix" | jshon -e content -u | base64 -d > overlay/upstream/master/$name.nix

(
flock 9 || exit 1
json=$(cat bump.json)
json=$(
jshon <<<"$json" -n {} \
-s "${version#v}" -i version \
-n {} \
-s "$headhash" -i rev \
-s "$headsha256" -i sha256 \
-s "$(dirname "$pkg")" -i owner \
-s "$name" -i repo \
-i master \
-n {} \
-s "$taghash" -i rev \
-s "$tagsha256" -i sha256 \
-s "$(dirname "$pkg")" -i owner \
-s "$name" -i repo \
-i stable \
-i "$name"
)
echo "$json" >bump.json
) 9>/tmp/dapphub-bump.lock

echo "done"
26 changes: 26 additions & 0 deletions nix/bump.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
#!/usr/bin/env bash
set -e

mkdir -p overlay/upstream/{master,stable}
echo '{}' >bump.json

pkgs=(
dapphub/dapp
mbrock/jays
dapphub/hevm
dapphub/seth
dapphub/ethsign
dapphub/token
lessrest/restless-git
dapphub/libethjet
dapphub/libethjet-haskell
mbrock/symbex
makerdao/setzer
makerdao/dai-cli
mbrock/oasis-orders
)

printf "%s\n" "${pkgs[@]}" | xargs -L 1 --max-procs=8 ./bump-one.sh

jq --sort-keys . < ./bump.json > overlay/versions.json
rm bump.json
61 changes: 61 additions & 0 deletions nix/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# This file acts like the main file of an entire <nixpkgs>.
# It imports a full nixpkgs from our pinned submodule,
# and extends it with our overlay.
#
# This is meant to be used as a channel.

{ pkgsPath ? null
, overlays ? []
, system ? null
}:

let
## Horrible; copied from nixpkgs to get extra overlays to work with our overlay.
homeDir = builtins.getEnv "HOME";
try = x: def: let res = builtins.tryEval x; in if res.success then res.value else def;
extra-overlays = with builtins; let
isDir = path: pathExists (path + "/.");
pathOverlays = try <nixpkgs-overlays> "";
homeOverlaysFile = homeDir + "/.config/nixpkgs/overlays.nix";
homeOverlaysDir = homeDir + "/.config/nixpkgs/overlays";
overlays = path:
# check if the path is a directory or a file
if isDir path then
# it's a directory, so the set of overlays from the directory, ordered lexicographically
let content = readDir path; in
map (n: import (path + ("/" + n)))
(builtins.filter (n: builtins.match ".*\\.nix" n != null || pathExists (path + ("/" + n + "/default.nix")))
(attrNames content))
else
# it's a file, so the result is the contents of the file itself
import path;
in
if pathOverlays != "" && pathExists pathOverlays then overlays pathOverlays
else if pathExists homeOverlaysFile && pathExists homeOverlaysDir then
throw ''
Nixpkgs overlays can be specified with ${homeOverlaysFile} or ${homeOverlaysDir}, but not both.
Please remove one of them and try again.
''
else if pathExists homeOverlaysFile then
if isDir homeOverlaysFile then
throw (homeOverlaysFile + " should be a file")
else overlays homeOverlaysFile
else if pathExists homeOverlaysDir then
if !(isDir homeOverlaysDir) then
throw (homeOverlaysDir + " should be a directory")
else overlays homeOverlaysDir
else [];

in (
(import ./nixpkgs) ({
overlays = [(import ./overlay { flavor = "stable"; })] ++ extra-overlays;
} // (
if system != null then { inherit system; } else {}
))
) // {
master = (import ./nixpkgs) ({
overlays = [(import ./overlay { flavor = "master"; })] ++ extra-overlays;
} // (
if system != null then { inherit system; } else {}
));
}
Loading

0 comments on commit 3d374c1

Please sign in to comment.