diff --git a/.travis.yml b/.travis.yml index 46c2cb35b..a1b67c308 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,3 +1,24 @@ language: nix -script: - - bash ci/deploy.sh + +notifications: + irc: + on_success: change + on_failure: always + channels: + - "irc.freenode.net#nixos-nur" + template: + - "%{result} - %{branch} \"%{commit_subject}\" %{build_url}" + +jobs: + include: + - name: test pull request + script: bash ci/test.sh + if: type = pull_request + + - name: update nur / nur-combined + script: bash ci/update-nur.sh + if: branch = master AND type != pull_request + + - name: update nur-search/data/packages.json + script: ci/update-nur-search.sh + if: branch = master AND type != pull_request diff --git a/README.md b/README.md index 53cf22fc3..3528e36c8 100644 --- a/README.md +++ b/README.md @@ -134,9 +134,11 @@ in ## Finding packages -At the moment we do not have a dedicated package search available. However our -[nur-combined](https://github.com/nix-community/nur-combined) repository contains all -nix expressions from all users and can be search via +You can find all packages using +[Packages search for NUR](https://nix-community.github.io/nur-search/) +or search our +[nur-combined](https://github.com/nix-community/nur-combined) +repository, which contains all nix expressions from all users, via [github](https://github.com/nix-community/nur-combined/search). ## How to add your own repository. diff --git a/ci/deploy.sh b/ci/deploy.sh deleted file mode 100755 index 1bcb8262f..000000000 --- a/ci/deploy.sh +++ /dev/null @@ -1,66 +0,0 @@ -#!/usr/bin/env bash - -set -eu -o pipefail # Exit with nonzero exit code if anything fails - -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" - -is-automatic-update() { - [[ "$TRAVIS_EVENT_TYPE" == "cron" ]] || [[ "$TRAVIS_EVENT_TYPE" == "api" ]] -} - -if is-automatic-update; then - keys_dir=$(mktemp -d) - openssl aes-256-cbc \ - -K $encrypted_080f214a372c_key \ - -iv $encrypted_080f214a372c_iv \ - -in ci/keys.tar.gz.enc -out ci/keys.tar.gz -d - tar -C "$keys_dir" -xzvf ci/keys.tar.gz - - eval "$(ssh-agent -s)" - - chmod 600 "${keys_dir}/ssh-key" - ssh-add "${keys_dir}/ssh-key" - gpg --import "${keys_dir}/gpg-private-key" - rm -rf "$keys_dir" -fi - -export encrypted_080f214a372c_key= encrypted_080f214a372c_iv= - -nix-build --quiet release.nix - -if ! is-automatic-update; then - bash $DIR/lint.sh -fi - -set -x - -result/bin/nur update -nix-build - -if ! is-automatic-update; then - # Pull requests and commits to other branches shouldn't try to deploy, just build to verify - echo "Skipping deploy; just doing a build." - exit 0 -fi - -git config --global user.name "Nur a bot" -git config --global user.email "joerg.nur-bot@thalheim.io" -git config --global user.signingkey "B4E40EEC9053254E" -git config --global commit.gpgsign true - -git clone git@github.com:nix-community/nur-combined - -result/bin/nur combine \ - --irc-notify nur-bot@chat.freenode.net:6697/nixos-nur \ - nur-combined - -if [[ -z "$(git diff --exit-code)" ]]; then - echo "No changes to the output on this push; exiting." -else - git add --all repos.json* - - git commit -m "automatic update" - git push git@github.com:nix-community/NUR HEAD:master -fi - -(cd nur-combined && git push origin master) diff --git a/ci/lib/setup-git.sh b/ci/lib/setup-git.sh new file mode 100644 index 000000000..2b1725f34 --- /dev/null +++ b/ci/lib/setup-git.sh @@ -0,0 +1,24 @@ +# only source this file +# to setup git to push and pull repositories via ssh +# ================================================== + +# set up git and ssh +# ------------------ +keys_dir=$(mktemp -d) +openssl aes-256-cbc \ + -K $encrypted_080f214a372c_key \ + -iv $encrypted_080f214a372c_iv \ + -in ci/keys.tar.gz.enc -out ci/keys.tar.gz -d +tar -C "$keys_dir" -xzvf ci/keys.tar.gz +eval "$(ssh-agent -s)" +chmod 600 "${keys_dir}/ssh-key" +ssh-add "${keys_dir}/ssh-key" +gpg --import "${keys_dir}/gpg-private-key" +rm -rf "$keys_dir" + +export encrypted_080f214a372c_key= encrypted_080f214a372c_iv= + +git config --global user.name "Nur a bot" +git config --global user.email "joerg.nur-bot@thalheim.io" +git config --global user.signingkey "B4E40EEC9053254E" +git config --global commit.gpgsign true diff --git a/ci/lint.sh b/ci/lint.sh deleted file mode 100755 index 5bed39c7d..000000000 --- a/ci/lint.sh +++ /dev/null @@ -1,18 +0,0 @@ -#!/usr/bin/env bash - -set -eu -o pipefail # Exit with nonzero exit code if anything fails - -$(nix-build --no-out-link release.nix)/bin/nur format-manifest -if [ -n "$(git diff --exit-code repos.json)" ]; then - echo "repos.json was not formatted before committing repos.json:" >&2 - git diff --exit-code repos.json - echo "Please run ./bin/nur/format-manifest.py and updates repos.json accordingly!" >&2 - exit 1 -fi - -# Type checker -nix run nixpkgs.python3Packages.mypy -c mypy nur -# Format checker -nix run nixpkgs.python3Packages.black -c black --check . -# Linter -nix run nixpkgs.python3Packages.flake8 -c flake8 . diff --git a/ci/test.sh b/ci/test.sh new file mode 100755 index 000000000..b41105b6f --- /dev/null +++ b/ci/test.sh @@ -0,0 +1,21 @@ +#!/usr/bin/env bash + +set -eux -o pipefail # Exit with nonzero exit code if anything fails + +nix run '(import ./release.nix {})' -c nur format-manifest +if [ -n "$(git diff --exit-code repos.json)" ]; then + echo "repos.json was not formatted before committing repos.json:" >&2 + git diff --exit-code repos.json + echo "Please run ./bin/nur/format-manifest.py and updates repos.json accordingly!" >&2 + exit 1 +fi + +# Type checker +nix run nixpkgs.python3Packages.mypy -c mypy nur +# Format checker +nix run nixpkgs.python3Packages.black -c black --check . +# Linter +nix run nixpkgs.python3Packages.flake8 -c flake8 . + +nix run '(import ./release.nix {})' -c nur update +nix-build diff --git a/ci/update-nur-search.sh b/ci/update-nur-search.sh new file mode 100755 index 000000000..b4a536d37 --- /dev/null +++ b/ci/update-nur-search.sh @@ -0,0 +1,31 @@ +#!/usr/bin/env bash + +set -eu -o pipefail # Exit with nonzero exit code if anything fails + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" + +source ${DIR}/lib/setup-git.sh +set -x + + +# build package.json for nur-search +# --------------------------------- + +nix-build --quiet release.nix + +git clone git@github.com:nix-community/nur-search + +nix run '(import ./release.nix {})' -c nur index . > nur-search/data/packages.json + +# rebuild and publish nur-search repository +# ----------------------------------------- + +cd nur-search +if [[ ! -z "$(git diff --exit-code)" ]]; then + git add ./data/packages.json + git commit -m "automatic update package.json" + git push origin master + nix-shell --run "make && make publish" +else + echo "nothings changed will not commit anything" +fi diff --git a/ci/update-nur.sh b/ci/update-nur.sh new file mode 100755 index 000000000..fd85b9aa0 --- /dev/null +++ b/ci/update-nur.sh @@ -0,0 +1,27 @@ +#!/usr/bin/env bash + +set -eu -o pipefail # Exit with nonzero exit code if anything fails + +DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )" + +source ${DIR}/lib/setup-git.sh +set -x + +nix run '(import ./release.nix {})' -c nur update +nix-build + +git clone git@github.com:nix-community/nur-combined + +nix run '(import ./release.nix {})' -c nur combine \ + --irc-notify nur-bot@chat.freenode.net:6697/nixos-nur \ + nur-combined + +if [[ -z "$(git diff --exit-code)" ]]; then + echo "No changes to the output on this push; exiting." +else + git add --all repos.json* + git commit -m "automatic update" + git push git@github.com:nix-community/NUR HEAD:master +fi + +(cd nur-combined && git push origin master)