Skip to content

Commit

Permalink
Fix nix flake build and check this on CI (#145)
Browse files Browse the repository at this point in the history
Broken by #144, which made
dependencies incompatible with the pinned rust toolchain.

This PR will check Nix Flake build on CI, but won't block PR merges if
the check fails.
  • Loading branch information
rtimush authored Jul 15, 2024
1 parent 7b741d3 commit 9868523
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 121 deletions.
15 changes: 15 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,21 @@ jobs:

- name: Check semver
uses: obi1kenobi/cargo-semver-checks-action@v2

flake:
runs-on: ubuntu-latest
steps:
- name: Checkout sources
uses: actions/checkout@v3

- name: Install nix
uses: DeterminateSystems/nix-installer-action@v12

- name: Cache nix dependencies
uses: DeterminateSystems/magic-nix-cache-action@v7

- name: Build
run: nix flake check

update-release-draft:
runs-on: ubuntu-latest
Expand Down
99 changes: 11 additions & 88 deletions flake.lock

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

79 changes: 46 additions & 33 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,41 +1,54 @@
{
description = "Protofetch - A source dependency management tool for Protobuf files";
description = "Protofetch - A source dependency management tool for Protobuf files";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
crane = { url = "github:ipetkov/crane"; inputs.nixpkgs.follows = "nixpkgs"; };
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
crane = {
url = "github:ipetkov/crane";
inputs.nixpkgs.follows = "nixpkgs";
};
};

outputs = { self, nixpkgs, flake-utils, crane }: flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
outputs =
{
self,
nixpkgs,
flake-utils,
crane,
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
inherit (pkgs) lib;
craneLib = crane.lib.${system};
in {
craneLib = crane.mkLib pkgs;

protofetch = craneLib.buildPackage {
pname = "protofetch";
src = lib.cleanSourceWith {
src = ./.; # The original, unfiltered source
filter = path: type: (lib.hasSuffix "\.proto" path) || (craneLib.filterCargoSources path type);
};
buildInputs = [
pkgs.openssl
pkgs.libgit2
pkgs.pkg-config
] ++ lib.optionals pkgs.stdenv.isDarwin [ pkgs.darwin.apple_sdk.frameworks.Security ];
preBuild = ''
export HOME=$(mktemp -d)
'';
};
in
{
packages = rec {
default = protofetch;
protofetch = craneLib.buildPackage {
pname = "protofetch";
src = lib.cleanSourceWith {
src = ./.; # The original, unfiltered source
filter = path: type:
(lib.hasSuffix "\.proto" path) ||
(craneLib.filterCargoSources path type);
};
buildInputs = with pkgs; [
openssl
libgit2
pkg-config
] ++ (if stdenv.isDarwin then [darwin.apple_sdk.frameworks.Security] else []);
preBuild = ''
export HOME=$(mktemp -d)
'';
};
inherit protofetch;
default = protofetch;
};
});
checks = {
# Build the crate as part of `nix flake check`
inherit protofetch;
};
}
);
}




0 comments on commit 9868523

Please sign in to comment.