From b3dbb52e3228ee0a839b2886a24a670634c43752 Mon Sep 17 00:00:00 2001 From: Erik Reinert <4638629+erikreinert@users.noreply.github.com> Date: Mon, 5 Feb 2024 01:52:04 -0800 Subject: [PATCH] Setup CI with Nix (#4) * feat(workflows): setup ci with nix * fix(workflows) --- .github/workflows/flake.yaml | 60 ++++++++++++++++++++++++++++++++++++ .github/workflows/flake.yml | 31 ------------------- README.md | 2 +- flake.lock | 18 +++++------ flake.nix | 7 +++-- justfile | 17 +++++++++- lib/default.nix | 7 ++--- 7 files changed, 93 insertions(+), 49 deletions(-) create mode 100644 .github/workflows/flake.yaml delete mode 100644 .github/workflows/flake.yml diff --git a/.github/workflows/flake.yaml b/.github/workflows/flake.yaml new file mode 100644 index 0000000..9661ca8 --- /dev/null +++ b/.github/workflows/flake.yaml @@ -0,0 +1,60 @@ +name: Test flake + +on: + pull_request: + push: + branches: + - main + +jobs: + check: + env: + CACHIX_AUTH_TOKEN: '${{ secrets.CACHIX_AUTH_TOKEN }}' + CACHIX_BINARY_CACHE: altf4llc-os + runs-on: ubuntu-latest + steps: + - uses: DeterminateSystems/nix-installer-action@main + - uses: actions/checkout@v3 + - run: nix-channel --add https://nixos.org/channels/nixpkgs-unstable unstable + - run: nix-channel --update + - run: nix-env -iA unstable.cachix + - run: cachix use "$CACHIX_BINARY_CACHE" + - run: nix develop -c just check + - run: nix develop -c just cache-inputs "$CACHIX_BINARY_CACHE" + + build-shell: + env: + CACHIX_AUTH_TOKEN: '${{ secrets.CACHIX_AUTH_TOKEN }}' + CACHIX_BINARY_CACHE: altf4llc-os + needs: check + runs-on: ubuntu-latest + steps: + - uses: DeterminateSystems/nix-installer-action@main + - uses: actions/checkout@v3 + - run: nix-channel --add https://nixos.org/channels/nixpkgs-unstable unstable + - run: nix-channel --update + - run: nix-env -iA unstable.cachix + - run: cachix use "$CACHIX_BINARY_CACHE" + - run: nix develop -c just cache-shell "$CACHIX_BINARY_CACHE" + + build: + env: + CACHIX_AUTH_TOKEN: '${{ secrets.CACHIX_AUTH_TOKEN }}' + CACHIX_BINARY_CACHE: altf4llc-os + needs: + - check + - build-shell + runs-on: ubuntu-latest + strategy: + matrix: + profile: + - default + - neovim + steps: + - uses: DeterminateSystems/nix-installer-action@main + - uses: actions/checkout@v4 + - run: nix-channel --add https://nixos.org/channels/nixpkgs-unstable unstable + - run: nix-channel --update + - run: nix-env -iA unstable.cachix + - run: cachix use "$CACHIX_BINARY_CACHE" + - run: nix develop -c just cache-build "${{ matrix.profile }}" "$CACHIX_BINARY_CACHE" diff --git a/.github/workflows/flake.yml b/.github/workflows/flake.yml deleted file mode 100644 index 3106f03..0000000 --- a/.github/workflows/flake.yml +++ /dev/null @@ -1,31 +0,0 @@ -name: Test flake - -on: - pull_request: - push: - branches: - - main - -jobs: - check: - runs-on: ubuntu-latest - steps: - - uses: DeterminateSystems/nix-installer-action@main - - uses: DeterminateSystems/magic-nix-cache-action@main - - uses: actions/checkout@v3 - - run: nix flake check - - build: - needs: check - runs-on: ubuntu-latest - strategy: - matrix: - profile: - - default - - neovim - steps: - - uses: DeterminateSystems/nix-installer-action@main - - uses: DeterminateSystems/magic-nix-cache-action@main - - uses: extractions/setup-just@v1 - - uses: actions/checkout@v3 - - run: just build "${{ matrix.profile }}" diff --git a/README.md b/README.md index afbffab..f2e5347 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # thealtf4stream.nvim Neovim configuration for TheAltF4Stream as a plugin. -[![Test flake](https://github.com/ALT-F4-LLC/thealtf4stream.nvim/actions/workflows/flake.yml/badge.svg)](https://github.com/ALT-F4-LLC/thealtf4stream.nvim/actions/workflows/flake.yml) +[![Test flake](https://github.com/ALT-F4-LLC/thealtf4stream.nvim/actions/workflows/flake.yaml/badge.svg)](https://github.com/ALT-F4-LLC/thealtf4stream.nvim/actions/workflows/flake.yaml) ![Preview](https://github.com/ALT-F4-LLC/thealtf4stream.nvim/blob/main/lib/preview.webp) diff --git a/flake.lock b/flake.lock index a164e5a..e2f6d20 100644 --- a/flake.lock +++ b/flake.lock @@ -5,11 +5,11 @@ "nixpkgs-lib": "nixpkgs-lib" }, "locked": { - "lastModified": 1704982712, - "narHash": "sha256-2Ptt+9h8dczgle2Oo6z5ni5rt/uLMG47UFTR1ry/wgg=", + "lastModified": 1706830856, + "narHash": "sha256-a0NYyp+h9hlb7ddVz4LUn1vT/PLwqfrWYcHMvFB1xYg=", "owner": "hercules-ci", "repo": "flake-parts", - "rev": "07f6395285469419cf9d078f59b5b49993198c00", + "rev": "b253292d9c0a5ead9bc98c4e9a26c6312e27d69f", "type": "github" }, "original": { @@ -19,11 +19,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1704722960, - "narHash": "sha256-mKGJ3sPsT6//s+Knglai5YflJUF2DGj7Ai6Ynopz0kI=", + "lastModified": 1706913249, + "narHash": "sha256-x3M7iV++CsvRXI1fpyFPduGELUckZEhSv0XWnUopAG8=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "317484b1ead87b9c1b8ac5261a8d2dd748a0492d", + "rev": "e92b6015881907e698782c77641aa49298330223", "type": "github" }, "original": { @@ -36,11 +36,11 @@ "nixpkgs-lib": { "locked": { "dir": "lib", - "lastModified": 1703961334, - "narHash": "sha256-M1mV/Cq+pgjk0rt6VxoyyD+O8cOUiai8t9Q6Yyq4noY=", + "lastModified": 1706550542, + "narHash": "sha256-UcsnCG6wx++23yeER4Hg18CXWbgNpqNXcHIo5/1Y+hc=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "b0d36bd0a420ecee3bc916c91886caca87c894e9", + "rev": "97b17f32362e475016f942bbdfda4a4a72a8a652", "type": "github" }, "original": { diff --git a/flake.nix b/flake.nix index aead150..2b5fd98 100644 --- a/flake.nix +++ b/flake.nix @@ -14,8 +14,6 @@ perSystem = { config, self', inputs', pkgs, system, ... }: let inherit (pkgs) just mkShell; - default = self.lib.mkVimPlugin { inherit system; }; - neovim = self.lib.mkNeovim { inherit system; }; in { devShells = { @@ -24,7 +22,10 @@ }; }; - packages = { inherit default neovim; }; + packages = { + default = self.lib.mkVimPlugin { inherit system; }; + neovim = self.lib.mkNeovim { inherit system; }; + }; }; }; } diff --git a/justfile b/justfile index fa0676e..b59db26 100644 --- a/justfile +++ b/justfile @@ -1,2 +1,17 @@ -build profile="default": +build profile: nix build --json --no-link --print-build-logs ".#{{ profile }}" + +cache-build profile cache_name: + just build "{{ profile }}" | jq -r '.[].outputs | to_entries[].value' | cachix push {{ cache_name }} + +cache-inputs cache_name: + nix flake archive --json \ + | jq -r '.path,(.inputs|to_entries[].value.path)' \ + | cachix push "{{ cache_name }}" + +cache-shell cache_name: + nix develop --profile "dev-profile" -c true + cachix push "{{ cache_name }}" "dev-profile" + +check: + nix flake check diff --git a/lib/default.nix b/lib/default.nix index dbb1218..d532490 100644 --- a/lib/default.nix +++ b/lib/default.nix @@ -68,8 +68,7 @@ rec { mkExtraPackages = { system }: let - inherit (pkgs) nodePackages ocaml-ng python310Packages; - inherit (ocaml-ng) ocamlPackages_5_1; + inherit (pkgs) nodePackages ocamlPackages python310Packages; pkgs = (import inputs.nixpkgs { inherit system; config.allowUnfree = true; @@ -85,8 +84,8 @@ rec { nodePackages."typescript-language-server" nodePackages."vscode-langservers-extracted" nodePackages."yaml-language-server" - ocamlPackages_5_1.ocaml-lsp - ocamlPackages_5_1.ocamlformat + ocamlPackages.ocaml-lsp + ocamlPackages.ocamlformat pkgs.cuelsp pkgs.gopls pkgs.haskell-language-server