move ci to flake

This commit is contained in:
Jörg Thalheim 2021-10-10 08:54:05 +02:00
parent c9cb2ab0de
commit 1a2bc3021c
23 changed files with 99 additions and 37 deletions

View file

@ -9,4 +9,6 @@ jobs:
- uses: cachix/install-nix-action@v14
with:
nix_path: nixpkgs=channel:nixos-unstable
extra_nix_config: |
experimental-features = nix-command flakes
- run: ./ci/test.sh

View file

@ -17,6 +17,8 @@ jobs:
- uses: cachix/install-nix-action@v14
with:
nix_path: nixpkgs=channel:nixos-unstable
extra_nix_config: |
experimental-features = nix-command flakes
- name: update nur / nur-combined
run: ./ci/update-nur.sh
env:
@ -29,6 +31,8 @@ jobs:
- uses: cachix/install-nix-action@v14
with:
nix_path: nixpkgs=channel:nixos-unstable
extra_nix_config: |
experimental-features = nix-command flakes
- name: update nur-search/data/packages.json
run: ./ci/update-nur-search.sh
env:

View file

@ -4,7 +4,7 @@ import sys
import os
sys.path.insert(0, os.path.join(
os.path.dirname(os.path.dirname(os.path.realpath(__file__)))))
os.path.dirname(os.path.dirname(os.path.realpath(__file__))), "ci"))
from nur import main

43
ci/flake.lock generated Normal file
View file

@ -0,0 +1,43 @@
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1631561581,
"narHash": "sha256-3VQMV5zvxaVLvqqUrNz3iJelLw30mIVSfZmAaauM3dA=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "7e5bf3925f6fbdfaf50a2a7ca0be2879c4261d19",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1633329294,
"narHash": "sha256-0LpQLS4KMgxslMgmDHmxG/5twFlXDBW9z4Or1iOrCvU=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "ee084c02040e864eeeb4cf4f8538d92f7c675671",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"flake-utils": "flake-utils",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

12
ci/flake.nix Normal file
View file

@ -0,0 +1,12 @@
{
description = "Internal flake for ci tasks of NUR";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
inputs.flake-utils.url = "github:numtide/flake-utils";
outputs = { self, nixpkgs, flake-utils }:
flake-utils.lib.eachDefaultSystem (system: {
packages.nur = nixpkgs.legacyPackages.${system}.python3.pkgs.callPackage ./nur.nix {};
defaultPackage = self.packages.${system}.nur;
});
}

13
ci/nur.nix Normal file
View file

@ -0,0 +1,13 @@
{ buildPythonApplication, lib, nix-prefetch-git, git, nixUnstable, glibcLocales }:
buildPythonApplication {
name = "nur";
src = ./.;
doCheck = false;
makeWrapperArgs = [
"--prefix" "PATH" ":" "${lib.makeBinPath [ nix-prefetch-git git nixUnstable ]}"
"--set" "LOCALE_ARCHIVE" "${glibcLocales}/lib/locale/locale-archive"
];
}

View file

@ -1,16 +1,11 @@
#!/usr/bin/env nix-shell
#!nix-shell -p bash -i bash -p python3Packages.mypy -p python3Packages.black -p python3Packages.flake8 -p nix
#!nix-shell -p bash -i bash -p python3Packages.mypy -p python3Packages.black -p python3Packages.flake8 -p nixUnstable
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
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null && pwd )"
cd "${DIR}"
# Type checker
mypy nur
# Format checker
@ -18,5 +13,14 @@ black --check .
# Linter
flake8 .
nix run '(import ./release.nix {})' -c nur update
cd "${DIR}/.."
nix run "${DIR}#" -- 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
nix run "${DIR}#" -- update
nix-build

View file

@ -1,5 +1,5 @@
#!/usr/bin/env nix-shell
#!nix-shell -p git -p nix -p bash -i bash
#!nix-shell -p git -p nixUnstable -p bash -i bash
set -eu -o pipefail # Exit with nonzero exit code if anything fails
@ -12,13 +12,15 @@ set -x
# build package.json for nur-search
# ---------------------------------
nix-build --quiet release.nix
nix build "${DIR}#"
git clone --single-branch "https://$API_TOKEN_GITHUB@github.com/nix-community/nur-combined.git"
cd "${DIR}/.."
git clone --recurse-submodules "https://$API_TOKEN_GITHUB@github.com/nix-community/nur-search.git"
git clone --single-branch "https://${API_TOKEN_GITHUB:-git}@github.com/nix-community/nur-combined.git" || git -C nur-combined pull
nix run '(import ./release.nix {})' -c nur index nur-combined > nur-search/data/packages.json
git clone --recurse-submodules "https://${API_TOKEN_GITHUB:-git}@github.com/nix-community/nur-search.git" || git -C nur-search pull
nix run "${DIR}#" -- index nur-combined > nur-search/data/packages.json
# rebuild and publish nur-search repository
# -----------------------------------------

View file

@ -1,5 +1,5 @@
#!/usr/bin/env nix-shell
#!nix-shell -p git -p nix -p bash -i bash
#!nix-shell -p git -p nixUnstable -p bash -i bash
set -eu -o pipefail # Exit with nonzero exit code if anything fails
@ -9,17 +9,14 @@ 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
nix run ${DIR}# -- update
cd ${DIR}/..
git clone \
--single-branch \
"https://$API_TOKEN_GITHUB@github.com/nix-community/nur-combined.git"
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

View file

@ -1,15 +0,0 @@
{ nixpkgs ? import <nixpkgs> }:
with import <nixpkgs> {};
python3Packages.buildPythonApplication {
name = "nur";
src = ./.;
doCheck = true;
makeWrapperArgs = [
"--prefix" "PATH" ":" "${pkgs.lib.makeBinPath [ nix-prefetch-git git nix ]}"
"--set" "LOCALE_ARCHIVE" "${glibcLocales}/lib/locale/locale-archive"
];
}