From 50a19be7bfa425f69f77fd4219770353dbd19e01 Mon Sep 17 00:00:00 2001 From: Will Ruggiano Date: Wed, 31 Jul 2024 22:01:29 -0700 Subject: [PATCH] rebase Created using spr 1.3.4 --- .github/workflows/check.yaml | 9 ++++-- .github/workflows/update-example.yaml | 25 ----------------- example/flake.lock | 36 ++++++++++-------------- example/flake.nix | 19 ++++++------- example/spec/features_spec.lua | 4 +++ flake.lock | 40 +++++++++++++++++++++------ flake.nix | 39 ++++++++++++++++---------- 7 files changed, 90 insertions(+), 82 deletions(-) delete mode 100644 .github/workflows/update-example.yaml diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 76761ae..03a3eb5 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -2,13 +2,16 @@ name: Build and test example flake on: pull_request: + push: + branches: + - main jobs: - check-pr: + check: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v25 + - uses: cachix/install-nix-action@v27 with: github_access_token: ${{ secrets.GITHUB_TOKEN }} - - run: nix run .#check-local + - run: nix flake check diff --git a/.github/workflows/update-example.yaml b/.github/workflows/update-example.yaml deleted file mode 100644 index 7df29fd..0000000 --- a/.github/workflows/update-example.yaml +++ /dev/null @@ -1,25 +0,0 @@ -name: Update, build and test example flake - -on: - push: - branches: - - main - -permissions: - contents: write - -jobs: - update-example: - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - - uses: cachix/install-nix-action@v25 - with: - github_access_token: ${{ secrets.GITHUB_TOKEN }} - - run: nix flake lock --update-input neovim-nix ./example - - run: nix run .#check - - run: | - git config --global user.name 'github-actions[bot]' - git config --global user.email 'willruggiano@users.noreply.github.com' - git commit -am 'chore: update example' || exit 0 - git push diff --git a/example/flake.lock b/example/flake.lock index e8aac40..42983a1 100644 --- a/example/flake.lock +++ b/example/flake.lock @@ -21,11 +21,11 @@ "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1709336216, - "narHash": "sha256-Dt/wOWeW6Sqm11Yh+2+t0dfEWxoMxGBvv3JpIocFl9E=", + "lastModified": 1719994518, + "narHash": "sha256-pQMhCCHyQGRzdfAkdJ4cIWiw+JNuWsTX7f0ZYSyz0VY=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "f7b3c975cf067e56e7cda6cb098ebe3fb4d74ca2", + "rev": "9227223f6d922fee3c7b190b2cc238a99527bbb7", "type": "github" }, "original": { @@ -110,11 +110,11 @@ "nixpkgs": "nixpkgs" }, "locked": { - "lastModified": 1722480119, - "narHash": "sha256-iuCAGeftxAHNOtlFRGPfw8avmtqP3w2hJJTynGyIEc4=", + "lastModified": 1722481107, + "narHash": "sha256-MpGhxIyCEnxPeff+zBr1Y9c2fbhZ9S6g8ulqqxRPsVc=", "owner": "willruggiano", "repo": "neovim.nix", - "rev": "cf63e94ed10a8fcfda5a3d123edce28552214b3c", + "rev": "18137e5e105835c39895103094583892c212e6b3", "type": "github" }, "original": { @@ -141,29 +141,23 @@ }, "nixpkgs-lib": { "locked": { - "dir": "lib", - "lastModified": 1709237383, - "narHash": "sha256-cy6ArO4k5qTx+l5o+0mL9f5fa86tYUX3ozE1S+Txlds=", - "owner": "NixOS", - "repo": "nixpkgs", - "rev": "1536926ef5621b09bba54035ae2bb6d806d72ac8", - "type": "github" + "lastModified": 1719876945, + "narHash": "sha256-Fm2rDDs86sHy0/1jxTOKB1118Q0O3Uc7EC0iXvXKpbI=", + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/5daf0514482af3f97abaefc78a6606365c9108e2.tar.gz" }, "original": { - "dir": "lib", - "owner": "NixOS", - "ref": "nixos-unstable", - "repo": "nixpkgs", - "type": "github" + "type": "tarball", + "url": "https://github.com/NixOS/nixpkgs/archive/5daf0514482af3f97abaefc78a6606365c9108e2.tar.gz" } }, "nixpkgs_2": { "locked": { - "lastModified": 1710159071, - "narHash": "sha256-CT0WKgcmlcWZPZL/sSSICN/Vbm4Of0ZDgxc0GFf6sYU=", + "lastModified": 1722415718, + "narHash": "sha256-5US0/pgxbMksF92k1+eOa8arJTJiPvsdZj9Dl+vJkM4=", "owner": "nixos", "repo": "nixpkgs", - "rev": "0fbcc4b2e8571f4af39be41752581ea09dd9ab06", + "rev": "c3392ad349a5227f4a3464dce87bcc5046692fce", "type": "github" }, "original": { diff --git a/example/flake.nix b/example/flake.nix index 6c520c3..458be89 100644 --- a/example/flake.nix +++ b/example/flake.nix @@ -16,6 +16,7 @@ systems = ["x86_64-linux"]; perSystem = { config, + lib, pkgs, ... }: { @@ -38,6 +39,11 @@ plugins = { example = { src = ./example; + init = '' + function() + vim.g.loaded_example_init = true + end + ''; config = ./example.lua; lazy = false; priority = 1000; @@ -59,16 +65,9 @@ }; }; - packages = { - default = config.neovim.final; - test = pkgs.writeShellApplication { - name = "neovim-nix-spec"; - runtimeInputs = [config.neovim.final]; - text = '' - nvim --headless -c "PlenaryBustedDirectory ${./.}/spec { init = '${config.neovim.build.initlua}' }" - ''; - }; - }; + checks = config.packages.ci; + + packages.default = config.neovim.final; }; }; } diff --git a/example/spec/features_spec.lua b/example/spec/features_spec.lua index d647259..51383d4 100644 --- a/example/spec/features_spec.lua +++ b/example/spec/features_spec.lua @@ -26,6 +26,10 @@ describe("neovim", function() assert.is_table(require "plenary") end) + it("(init) configures plugins", function() + assert.is_true(vim.g.loaded_example_init) + end) + it("(config) configures plugins", function() assert.is_true(vim.g.loaded_example) end) diff --git a/flake.lock b/flake.lock index 98c5bc2..dd7e4e3 100644 --- a/flake.lock +++ b/flake.lock @@ -1,5 +1,26 @@ { "nodes": { + "example": { + "inputs": { + "flake-parts": [ + "flake-parts" + ], + "neovim-nix": [], + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 1, + "narHash": "sha256-Pqlo2+42dWMZke7Be5qZ2Q+X6hsX1AmfeDv3Qtsho74=", + "path": "./example", + "type": "path" + }, + "original": { + "path": "./example", + "type": "path" + } + }, "flake-compat": { "flake": false, "locked": { @@ -23,11 +44,11 @@ ] }, "locked": { - "lastModified": 1709336216, - "narHash": "sha256-Dt/wOWeW6Sqm11Yh+2+t0dfEWxoMxGBvv3JpIocFl9E=", + "lastModified": 1719994518, + "narHash": "sha256-pQMhCCHyQGRzdfAkdJ4cIWiw+JNuWsTX7f0ZYSyz0VY=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "f7b3c975cf067e56e7cda6cb098ebe3fb4d74ca2", + "rev": "9227223f6d922fee3c7b190b2cc238a99527bbb7", "type": "github" }, "original": { @@ -46,11 +67,11 @@ "nixpkgs-stable": [] }, "locked": { - "lastModified": 1720524665, - "narHash": "sha256-ni/87oHPZm6Gv0ECYxr1f6uxB0UKBWJ6HvS7lwLU6oY=", + "lastModified": 1721042469, + "narHash": "sha256-6FPUl7HVtvRHCCBQne7Ylp4p+dpP3P/OYuzjztZ4s70=", "owner": "cachix", "repo": "git-hooks.nix", - "rev": "8d6a17d0cdf411c55f12602624df6368ad86fac1", + "rev": "f451c19376071a90d8c58ab1a953c6e9840527fd", "type": "github" }, "original": { @@ -82,11 +103,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1706683685, - "narHash": "sha256-FtPPshEpxH/ewBOsdKBNhlsL2MLEFv1hEnQ19f/bFsQ=", + "lastModified": 1722415718, + "narHash": "sha256-5US0/pgxbMksF92k1+eOa8arJTJiPvsdZj9Dl+vJkM4=", "owner": "nixos", "repo": "nixpkgs", - "rev": "5ad9903c16126a7d949101687af0aa589b1d7d3d", + "rev": "c3392ad349a5227f4a3464dce87bcc5046692fce", "type": "github" }, "original": { @@ -98,6 +119,7 @@ }, "root": { "inputs": { + "example": "example", "flake-parts": "flake-parts", "git-hooks": "git-hooks", "nixpkgs": "nixpkgs" diff --git a/flake.nix b/flake.nix index fa46544..03d3a00 100644 --- a/flake.nix +++ b/flake.nix @@ -3,6 +3,14 @@ inputs = { nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; + example = { + url = "path:./example"; + inputs = { + flake-parts.follows = "flake-parts"; + neovim-nix.follows = "/"; + nixpkgs.follows = "nixpkgs"; + }; + }; flake-parts = { url = "github:hercules-ci/flake-parts"; inputs.nixpkgs-lib.follows = "nixpkgs"; @@ -29,27 +37,30 @@ perSystem = { config, inputs', + lib, pkgs, system, ... }: { - apps = { - check.program = pkgs.writeShellApplication { - name = "check"; - text = '' - nix run ./example#test - ''; - }; - check-local.program = pkgs.writeShellApplication { - name = "check-local"; - text = '' - nix run --override-input neovim-nix path:./. ./example#test - ''; - }; + checks.ci = pkgs.stdenvNoCC.mkDerivation { + name = "neovim-nix-ci"; + dontUnpack = true; + dontPatch = true; + dontConfigure = true; + dontBuild = true; + doCheck = true; + checkPhase = let + pkg = config.packages.example; + in '' + HOME=$TMP ${lib.getExe pkg} --headless -n -c "PlenaryBustedDirectory ${./example/spec} { init = '${pkg.initlua}' }" + ''; + installPhase = '' + touch $out + ''; }; - formatter = pkgs.alejandra; + packages.example = inputs'.example.packages.default; } // inputs.nixpkgs.lib.optionalAttrs (inputs.git-hooks ? flakeModule) { devShells.default = pkgs.mkShell {