This is a library to turn Nix Flake attribute sets into Github Actions matrices.
Features:
- Unopinionated
Install Nix using any method you like
- Flexible
Nix-github-actions is not an action in itself but a series of templates and a Nix library to build your own CI.
- Parallel job execution
Use one Github Actions runner per package attribute
nix-github-actions comes with a quickstart script that interactively guides you through integrating it:
$ nix run github:nix-community/nix-github-actions
-
Find a CI template in ./.github/workflows and copy it to your project
-
Integrate into your project
flake.nix
{
inputs.nix-github-actions.url = "github:nix-community/nix-github-actions";
inputs.nix-github-actions.inputs.nixpkgs.follows = "nixpkgs";
outputs = { self, nixpkgs, nix-github-actions }: {
githubActions = nix-github-actions.lib.mkGithubMatrix { checks = self.packages; };
packages.x86_64-linux.hello = nixpkgs.legacyPackages.x86_64-linux.hello;
packages.x86_64-linux.default = self.packages.x86_64-linux.hello;
};
}
flake.nix
{
inputs.nix-github-actions.url = "github:nix-community/nix-github-actions";
inputs.nix-github-actions.inputs.nixpkgs.follows = "nixpkgs";
outputs = { self, nixpkgs, nix-github-actions }: {
githubActions = nix-github-actions.lib.mkGithubMatrix { inherit (self) checks; };
checks.x86_64-linux.hello = nixpkgs.legacyPackages.x86_64-linux.hello;
checks.x86_64-linux.default = self.packages.x86_64-linux.hello;
};
}
If your Flake contains checks for platforms unsupported by Actions, e.g. aarch64-darwin
,
you can restrict the systems for which the matrix will be generated:
githubActions = nix-github-actions.lib.mkGithubMatrix {
checks = nixpkgs.lib.getAttrs [ "x86_64-linux" "x86_64-darwin" ] self.checks;
};