From c2360cc128a6e1b651b6871c27799a1230e79b68 Mon Sep 17 00:00:00 2001 From: Guilhem Saurel Date: Sat, 9 Mar 2024 00:13:00 +0100 Subject: [PATCH 1/2] flakify --- .github/workflows/nix.yml | 17 +++++++++++ .nixignore | 8 +++++ docs/release.sh | 1 + flake.lock | 61 +++++++++++++++++++++++++++++++++++++++ flake.nix | 47 ++++++++++++++++++++++++++++++ 5 files changed, 134 insertions(+) create mode 100644 .github/workflows/nix.yml create mode 100644 .nixignore create mode 100644 flake.lock create mode 100644 flake.nix diff --git a/.github/workflows/nix.yml b/.github/workflows/nix.yml new file mode 100644 index 0000000..fd854be --- /dev/null +++ b/.github/workflows/nix.yml @@ -0,0 +1,17 @@ +name: "Nix CI" + +on: [pull_request, push] + +jobs: + tests: + name: "Nix build on ${{ matrix.os }}" + runs-on: "${{ matrix.os }}-latest" + strategy: + matrix: + os: [ubuntu, macos] + steps: + - uses: actions/checkout@v4 + - uses: DeterminateSystems/nix-installer-action@main + - uses: DeterminateSystems/magic-nix-cache-action@main + - uses: DeterminateSystems/flake-checker-action@main + - run: nix build diff --git a/.nixignore b/.nixignore new file mode 100644 index 0000000..703b30c --- /dev/null +++ b/.nixignore @@ -0,0 +1,8 @@ +*.nix +.git* +.nixignore +.pre-commit-config.yaml +Dockerfile +docker-compose.yml +CHANGELOG.md +LICENSE diff --git a/docs/release.sh b/docs/release.sh index c2ef8e3..91a0dc7 100755 --- a/docs/release.sh +++ b/docs/release.sh @@ -14,6 +14,7 @@ DATE=$(date +%Y-%m-%d) sed -i "/^## \[Unreleased\]/a \\\n## [v$NEW] - $DATE" CHANGELOG.md sed -i "/^\[Unreleased\]/s/$OLD/$NEW/" CHANGELOG.md sed -i "/^\[Unreleased\]/a [v$NEW]: https://github.com/nim65s/matrix-webhook/compare/v$OLD...v$NEW" CHANGELOG.md +sed -i "/version/$OLD/$NEW/" flake.nix git add pyproject.toml CHANGELOG.md git commit -m "Release v$NEW" diff --git a/flake.lock b/flake.lock new file mode 100644 index 0000000..d7bc628 --- /dev/null +++ b/flake.lock @@ -0,0 +1,61 @@ +{ + "nodes": { + "flake-utils": { + "inputs": { + "systems": "systems" + }, + "locked": { + "lastModified": 1709126324, + "narHash": "sha256-q6EQdSeUZOG26WelxqkmR7kArjgWCdw5sfJVHPH/7j8=", + "owner": "numtide", + "repo": "flake-utils", + "rev": "d465f4819400de7c8d874d50b982301f28a84605", + "type": "github" + }, + "original": { + "owner": "numtide", + "repo": "flake-utils", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1709703039, + "narHash": "sha256-6hqgQ8OK6gsMu1VtcGKBxKQInRLHtzulDo9Z5jxHEFY=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "9df3e30ce24fd28c7b3e2de0d986769db5d6225d", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "flake-utils": "flake-utils", + "nixpkgs": "nixpkgs" + } + }, + "systems": { + "locked": { + "lastModified": 1681028828, + "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", + "owner": "nix-systems", + "repo": "default", + "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", + "type": "github" + }, + "original": { + "owner": "nix-systems", + "repo": "default", + "type": "github" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/flake.nix b/flake.nix new file mode 100644 index 0000000..d0b7644 --- /dev/null +++ b/flake.nix @@ -0,0 +1,47 @@ +{ + description = "Post a message to a matrix room with a simple HTTP POST"; + + inputs = { + flake-utils.url = "github:numtide/flake-utils"; + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + }; + + outputs = + { + self, + nixpkgs, + flake-utils, + }: + flake-utils.lib.eachDefaultSystem ( + system: + let + pkgs = nixpkgs.legacyPackages.${system}; + matrix-webhook = + with pkgs.python3Packages; + buildPythonApplication { + pname = "matrix-webhook"; + version = "3.8.0"; + src = pkgs.nix-gitignore.gitignoreSource [ ./.nixignore ] ./.; + pyproject = true; + buildInputs = [ poetry-core ]; + propagatedBuildInputs = [ + markdown + matrix-nio + ]; + }; + in + { + packages.default = matrix-webhook; + apps.default = flake-utils.lib.mkApp { drv = matrix-webhook; }; + devShells.default = pkgs.mkShell { + inputsFrom = [ matrix-webhook ]; + packages = with pkgs; [ + poetry + python3Packages.coverage + python3Packages.httpx + python3Packages.safety + ]; + }; + } + ); +} From c89f9b55baf9af235b3bfdd5c1d76135f81c0558 Mon Sep 17 00:00:00 2001 From: Guilhem Saurel Date: Sat, 9 Mar 2024 00:19:16 +0100 Subject: [PATCH 2/2] flakify: changelog & readme --- CHANGELOG.md | 2 ++ README.md | 2 ++ 2 files changed, 4 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index ed550f0..a713fa0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 by [@timo-schluessler](https://github.com/timo-schluessler) - try to reconnect on LocalProtocolError in [#135](https://github.com/nim65s/matrix-webhook/pull/135) +- flakify + in [#136](https://github.com/nim65s/matrix-webhook/pull/136) - add mwe gitlab webhook formatter. Intergrations are better for now - replace black & isort by ruff - update dependencies diff --git a/README.md b/README.md index 371fbbd..3980c7b 100644 --- a/README.md +++ b/README.md @@ -34,6 +34,8 @@ python -m matrix_webhook -h # OR poetry run matrix-webhook -h # OR +nix run github:nim65s/matrix-webhook -- -h +# OR docker run --rm -it nim65s/matrix-webhook -h ```