From 2c4fb982961eb0782fb5a3f73469a450969c9f19 Mon Sep 17 00:00:00 2001 From: Will Ruggiano Date: Tue, 12 Mar 2024 18:59:38 -0600 Subject: [PATCH] don't use runtimeEnv, update workflows --- .github/workflows/check.yaml | 10 +++------- .github/workflows/update-example.yaml | 3 ++- flake.nix | 15 +++++++++++++++ modules/default.nix | 23 +++++++++++------------ 4 files changed, 31 insertions(+), 20 deletions(-) diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 18d5ea8..76761ae 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -1,18 +1,14 @@ -name: Build example and run tests +name: Build and test example flake on: pull_request: - push: - branches: - - main jobs: - tests: + check-pr: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: cachix/install-nix-action@v25 with: github_access_token: ${{ secrets.GITHUB_TOKEN }} - - run: nix build ./example - - run: nix run ./example#test + - run: nix run .#check-local diff --git a/.github/workflows/update-example.yaml b/.github/workflows/update-example.yaml index 93d7e54..7df29fd 100644 --- a/.github/workflows/update-example.yaml +++ b/.github/workflows/update-example.yaml @@ -1,4 +1,4 @@ -name: Update example flake +name: Update, build and test example flake on: push: @@ -17,6 +17,7 @@ jobs: 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' diff --git a/flake.nix b/flake.nix index 0b471ed..0e433b9 100644 --- a/flake.nix +++ b/flake.nix @@ -33,6 +33,21 @@ 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 + ''; + }; + }; + devShells.default = pkgs.mkShell { name = "neovim.nix"; shellHook = '' diff --git a/modules/default.nix b/modules/default.nix index 4824319..39437ea 100644 --- a/modules/default.nix +++ b/modules/default.nix @@ -4,7 +4,7 @@ ... }: let inherit (flake-parts-lib) mkPerSystemOption; - inherit (lib) makeBinPath mkOption types unique; + inherit (lib) concatStringsSep makeBinPath mapAttrsToList mkOption optional optionals types unique; mkNeovimEnv = { config, @@ -15,19 +15,18 @@ in pkgs.writeShellApplication { name = "nvim"; - runtimeEnv = - (cfg.env or {}) - // { - NVIM_RPLUGIN_MANIFEST = "${config.neovim.build.rplugin}/rplugin.vim"; - }; - text = - lib.optionalString (cfg.paths != []) - '' + text = concatStringsSep "\n" ( + optionals (cfg.env != {}) (mapAttrsToList (name: value: ''export ${name}="''${${name}:-${toString value}}"'') cfg.env) + ++ optional (cfg.paths != []) '' export PATH="$PATH:${makeBinPath (unique cfg.paths)}" '' - + '' - ${cfg.package}/bin/nvim -u ${cfg.build.initlua} "$@" - ''; + ++ [ + '' + export NVIM_RPLUGIN_MANIFEST="${config.neovim.build.rplugin}/rplugin.vim" + ${cfg.package}/bin/nvim -u ${cfg.build.initlua} "$@" + '' + ] + ); derivationArgs.passthru = { inherit (config.neovim.build) initlua plugins; };