Skip to content

Commit

Permalink
Setup CI with Nix (#4)
Browse files Browse the repository at this point in the history
* feat(workflows): setup ci with nix

* fix(workflows)
  • Loading branch information
erikreinert authored Feb 5, 2024
1 parent 2fdd35d commit b3dbb52
Show file tree
Hide file tree
Showing 7 changed files with 93 additions and 49 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/flake.yaml
Original file line number Diff line number Diff line change
@@ -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"
31 changes: 0 additions & 31 deletions .github/workflows/flake.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down
18 changes: 9 additions & 9 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand All @@ -24,7 +22,10 @@
};
};

packages = { inherit default neovim; };
packages = {
default = self.lib.mkVimPlugin { inherit system; };
neovim = self.lib.mkNeovim { inherit system; };
};
};
};
}
17 changes: 16 additions & 1 deletion justfile
Original file line number Diff line number Diff line change
@@ -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
7 changes: 3 additions & 4 deletions lib/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down

0 comments on commit b3dbb52

Please sign in to comment.