Skip to content

Commit

Permalink
ci(nix): add cachix (#87)
Browse files Browse the repository at this point in the history
  • Loading branch information
nekowinston authored Nov 5, 2023
1 parent bf5b16d commit 9aef1af
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 11 deletions.
33 changes: 33 additions & 0 deletions .github/workflows/cachix.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Build and populate cache

on:
push:
branches: [main]
pull_request:

jobs:
build:
strategy:
matrix:
os: ["ubuntu-latest", "macos-latest"]

runs-on: ${{ matrix.os }}

steps:
- uses: actions/checkout@v4

- uses: cachix/install-nix-action@v23
with:
github_access_token: ${{ secrets.GITHUB_TOKEN }}

- name: Setup cachix
uses: cachix/cachix-action@v12
with:
name: "catppuccin"
authToken: "${{ secrets.CACHIX_AUTH_TOKEN }}"

- name: Flake check
run: nix flake check

- name: Build package
run: nix build -L .
31 changes: 20 additions & 11 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -7,43 +7,52 @@
...
}: let
systems = ["aarch64-darwin" "aarch64-linux" "armv6l-linux" "armv7l-linux" "x86_64-darwin" "x86_64-linux"];
forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f system);
version = builtins.substring 0 8 self.lastModifiedDate;
inherit (nixpkgs) lib;
forAllSystems = f: lib.genAttrs systems (system: f nixpkgs.legacyPackages.${system});
in {
checks = forAllSystems (system: {
default = self.packages.${system}.default;
checks = forAllSystems (pkgs: {
default = self.packages.${pkgs.system}.default;
});

packages = forAllSystems (system: let
pkgs = nixpkgs.legacyPackages.${system};
in rec {
packages = forAllSystems (pkgs: rec {
mdbook-catppuccin = pkgs.rustPlatform.buildRustPackage {
pname = "mdbook-catppuccin";
version = (builtins.fromTOML (builtins.readFile ./Cargo.toml)).package.version;
inherit version;
buildInputs = with pkgs; ([] ++ lib.optionals stdenv.isDarwin [libiconv]);
src = pkgs.nix-gitignore.gitignoreSource [] ./.;
cargoLock.lockFile = ./Cargo.lock;
};
default = mdbook-catppuccin;
});

devShells = forAllSystems (system: let
pkgs = nixpkgs.legacyPackages.${system};
in rec {
devShells = forAllSystems (pkgs: rec {
default = pkgs.mkShell {
buildInputs = with pkgs; (
[
rustc
cargo
gcc
rustfmt
clippy
rust-analyzer
# mdbook
mdbook-admonish
node2nix
nodejs
]
++ lib.optionals stdenv.isDarwin [libiconv]
);
RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}";
};
demo = pkgs.mkShell {
buildInputs = default.buildInputs ++ [self.packages.${system}.mdbook-catppuccin];
buildInputs = default.buildInputs ++ [self.packages.${pkgs.system}.mdbook-catppuccin];
};
});
};

nixConfig = {
extra-substituters = ["https://catppuccin.cachix.org"];
extra-trusted-public-keys = ["catppuccin.cachix.org-1:noG/4HkbhJb+lUAdKrph6LaozJvAeEEZj4N732IysmU="];
};
}

0 comments on commit 9aef1af

Please sign in to comment.