diff --git a/.github/workflows/cachix.yml b/.github/workflows/cachix.yml new file mode 100644 index 0000000..14768b2 --- /dev/null +++ b/.github/workflows/cachix.yml @@ -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 . diff --git a/flake.nix b/flake.nix index ab2cbba..81fed0f 100644 --- a/flake.nix +++ b/flake.nix @@ -7,18 +7,18 @@ ... }: 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; @@ -26,13 +26,16 @@ 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 @@ -40,10 +43,16 @@ ] ++ 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="]; + }; }