From 70e464da5c93ddf87dce3560d7fd9968cd39c3d9 Mon Sep 17 00:00:00 2001 From: Marc Jakobi Date: Tue, 14 Mar 2023 23:16:32 +0100 Subject: [PATCH] feat: add extra_packages input --- .github/workflows/pr.yml | 2 ++ CHANGELOG.md | 3 +++ Dockerfile | 1 + README.md | 20 ++++++++++++++++++-- action.yml | 6 ++++++ entrypoint.sh | 14 +++++++++++++- flake.lock | 12 ++++++------ flake.nix | 21 ++++++++++++--------- nix/extraRuntimeInputs.nix | 5 +++++ 9 files changed, 66 insertions(+), 18 deletions(-) create mode 100644 nix/extraRuntimeInputs.nix diff --git a/.github/workflows/pr.yml b/.github/workflows/pr.yml index 0ae7ab5..1b5e286 100644 --- a/.github/workflows/pr.yml +++ b/.github/workflows/pr.yml @@ -21,3 +21,5 @@ jobs: copy_directories: | {{ neovim.plugin.dirs }} bin + extra_packages: | + deno diff --git a/CHANGELOG.md b/CHANGELOG.md index a5eff7b..c4c76b0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -8,6 +8,9 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ## [Unreleased] +### Added +- `extra_packages` input for adding additional build dependencies from `nixpkgs`. + ## [v3.0.0] - 2023-03-08 ### Added - Add directories from Neovim's `runtimepath` and some common plugin directories diff --git a/Dockerfile b/Dockerfile index 7cf1d56..aed24f6 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,6 +2,7 @@ FROM nixpkgs/nix-flakes:nixos-22.11 AS luarocks-tag-release COPY bin /pkg/bin +COPY nix /pkg/nix COPY luarocks-tag-release-scm-1.rockspec /pkg/ COPY flake.nix /pkg/flake.nix COPY flake.lock /pkg/flake.lock diff --git a/README.md b/README.md index 4ff9bb1..3eb0a53 100644 --- a/README.md +++ b/README.md @@ -190,7 +190,23 @@ Example: template: "/path/to/my/template.rockspec" ``` -### `license` (optional) +### `extra_packages` + +List of extra packages from [`nixpkgs`](https://search.nixos.org/packages?channel=unstable) +that can be used for building the LuaRocks package. + +Example: + +```yaml +- name: LuaRocks Upload + uses: nvim-neorocks/luarocks-tag-release@v3 + with: + extra_packages: | + deno + inkscape +``` + +### `license` The license used by this package. If not set (by default), this workflow will fetch the license SPDX ID from GitHub. @@ -211,7 +227,7 @@ Example: > ![about](https://user-images.githubusercontent.com/12857160/218101570-b0605716-0457-47c1-ab2e-91d48a48881c.png) -### `version` (optional) +### `version` The package version to release to LuaRocks (without the rockspec revision). By default, this workflow will use the git tag to determine the LuaRocks package version. diff --git a/action.yml b/action.yml index b7df2c0..826831e 100644 --- a/action.yml +++ b/action.yml @@ -47,6 +47,11 @@ inputs: options: - builtin - make + extra_packages: + description: | + List of extra packages from nixpkgs that can be used for the build. + required: true + default: "" template: description: "Path to a rockspec template." required: true @@ -68,6 +73,7 @@ runs: using: "docker" image: "Dockerfile" args: + - ${{ inputs.extra_packages }} - ${{ inputs.name }} - ${{ inputs.version }} - ${{ inputs.dependencies }} diff --git a/entrypoint.sh b/entrypoint.sh index 9f0ae82..c878f88 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,5 +1,17 @@ #!/usr/bin/env bash +set -e + +EXTRA_PACKAGES="$1" + +while read -r nixpkg; do + NIXPKG="$(echo "$nixpkg" | tr -d '"')" # (why, Bash?) + if [[ "$NIXPKG" != "" ]]; then + echo "Adding extra package: $NIXPKG" + nix run "nixpkgs#gnused" -- "-i" "s/#PLACEHOLDER/$NIXPKG\n #PLACEHOLDER/" "/pkg/nix/extraRuntimeInputs.nix" + fi +done <<<"$EXTRA_PACKAGES" + nix build "/pkg#luarocks-tag-release" -./result/bin/luarocks-tag-release "$@" +./result/bin/luarocks-tag-release "${@:2}" diff --git a/flake.lock b/flake.lock index d6b1ff0..7d46fcd 100644 --- a/flake.lock +++ b/flake.lock @@ -54,11 +54,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1674236650, - "narHash": "sha256-B4GKL1YdJnII6DQNNJ4wDW1ySJVx2suB1h/v4Ql8J0Q=", + "lastModified": 1678724065, + "narHash": "sha256-MjeRjunqfGTBGU401nxIjs7PC9PZZ1FBCZp/bRB3C2M=", "owner": "nixos", "repo": "nixpkgs", - "rev": "cfb43ad7b941d9c3606fb35d91228da7ebddbfc5", + "rev": "b8afc8489dc96f29f69bec50fdc51e27883f89c1", "type": "github" }, "original": { @@ -95,11 +95,11 @@ "nixpkgs-stable": "nixpkgs-stable" }, "locked": { - "lastModified": 1674487663, - "narHash": "sha256-wuDr8rfBLcY7EIsFrFEj2dKYvsKjGib42Q2X3ZaDVf4=", + "lastModified": 1678376203, + "narHash": "sha256-3tyYGyC8h7fBwncLZy5nCUjTJPrHbmNwp47LlNLOHSM=", "owner": "cachix", "repo": "pre-commit-hooks.nix", - "rev": "3a12b647bc6da39b69bffcc7aaa31cdbc9b7ff7c", + "rev": "1a20b9708962096ec2481eeb2ddca29ed747770a", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index 3b846a4..25c6d37 100644 --- a/flake.nix +++ b/flake.nix @@ -35,18 +35,21 @@ luafilesystem ]; }; + extraRuntimeInputs = (import ./nix/extraRuntimeInputs.nix pkgs).extraRuntimeInputs; in pkgs.writeShellApplication { name = "luarocks-tag-release"; - runtimeInputs = with pkgs; [ - curl - gnumake - lua51Packages.dkjson # Used by luarocks - lua51Packages.luarocks - luarocks-tag-release-wrapped - unzip - zip - ]; + runtimeInputs = with pkgs; + [ + curl + gnumake + lua51Packages.dkjson # Used by luarocks + lua51Packages.luarocks + luarocks-tag-release-wrapped + unzip + zip + ] + ++ extraRuntimeInputs; text = '' luarocks-tag-release.lua "$@" diff --git a/nix/extraRuntimeInputs.nix b/nix/extraRuntimeInputs.nix new file mode 100644 index 0000000..bd7273c --- /dev/null +++ b/nix/extraRuntimeInputs.nix @@ -0,0 +1,5 @@ +pkgs: { + extraRuntimeInputs = with pkgs; [ + #PLACEHOLDER + ]; +}