Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable nix based build actions #31

Merged
merged 4 commits into from
May 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions .github/workflows/nix-github-actions.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
name: Nix Flake actions

on:
pull_request:
push:
branches:
- master
- main

jobs:
nix-matrix:
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.matrix }}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v27
- id: set-matrix
name: Generate Nix Matrix
run: |
set -Eeu
matrix="$(nix eval --json '.#githubActions.matrix')"
echo "matrix=$matrix" >> "$GITHUB_OUTPUT"

nix-build:
needs: nix-matrix
runs-on: ${{ matrix.os }}
strategy:
matrix: ${{fromJSON(needs.nix-matrix.outputs.matrix)}}
steps:
- uses: actions/checkout@v4
- uses: cachix/install-nix-action@v27
- run: nix build -L ".#${{ matrix.attr }}"
22 changes: 22 additions & 0 deletions flake.lock

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

167 changes: 122 additions & 45 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4,46 +4,28 @@
flake-utils.url = "github:numtide/flake-utils";
crane.url = "github:ipetkov/crane";
crane.inputs.nixpkgs.follows = "nixpkgs";
nix-github-actions.url = "github:IGI-111/nix-github-actions?ref=IGI-111/add-aarch64-darwin";
nix-github-actions.inputs.nixpkgs.follows = "nixpkgs";
};

outputs =
{
self,
nixpkgs,
crane,
flake-utils,
nix-github-actions,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};
craneLib = crane.mkLib pkgs;
buildInputs = with pkgs; [
xorg.libXi
xorg.libX11
xorg.libXcursor
libxkbcommon
fontconfig
libGL
wayland
openssl
];
nativeBuildInputs = with pkgs; [
rustc
cargo
rustfmt
rustPackages.clippy
rust-analyzer
slint-lsp

pkg-config
# kdialog
];
libPath = pkgs.lib.makeLibraryPath buildInputs;
in
{
packages.default = craneLib.buildPackage {
let
buildPackageForSystem =
{
pkgs,
buildInputs,
nativeBuildInputs,
}:
let
craneLib = crane.mkLib pkgs;
libPath = pkgs.lib.makeLibraryPath buildInputs;
src =
let
# Only keeps slint files
Expand All @@ -57,19 +39,114 @@
src = craneLib.path ./.;
filter = sourceFilter;
};

# Add extra inputs here or any other derivation settings
# doCheck = true;
buildInputs = buildInputs;
nativeBuildInputs = nativeBuildInputs;
LD_LIBRARY_PATH = libPath;
};
# `nix develop`
devShell = pkgs.mkShell {
buildInputs = buildInputs;
nativeBuildInputs = nativeBuildInputs;
LD_LIBRARY_PATH = libPath;
cargoArtifacts = craneLib.buildDepsOnly {
inherit src buildInputs nativeBuildInputs;
LD_LIBRARY_PATH = libPath;
};
kira = craneLib.buildPackage {
inherit
src
buildInputs
nativeBuildInputs
cargoArtifacts
;
doNotSign = true; # FIXME: disable apple binary signature
LD_LIBRARY_PATH = libPath;
};
in
{
defaultPackage = kira;
checks = {
inherit kira;
kira-clippy = craneLib.cargoClippy {
inherit
src
buildInputs
nativeBuildInputs
cargoArtifacts
;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
};
kira-fmt = craneLib.cargoFmt { inherit src; };
};
devShell = pkgs.mkShell {
inherit buildInputs nativeBuildInputs;
LD_LIBRARY_PATH = libPath;
};
};
}
);

buildPackageDeps = {
"x86_64-linux" =
let
pkgs = nixpkgs.legacyPackages.x86_64-linux;
in
{
inherit pkgs;
buildInputs = with pkgs; [
xorg.libXi
xorg.libX11
xorg.libXcursor
libxkbcommon
fontconfig
libGL
wayland
openssl
];
nativeBuildInputs = with pkgs; [
rustc
cargo
rustfmt
rustPackages.clippy
rust-analyzer
slint-lsp

pkg-config
# kdialog
];
};

"aarch64-darwin" =
let
pkgs = nixpkgs.legacyPackages.aarch64-darwin;
in
{
inherit pkgs;
buildInputs = with pkgs; [
openssl
darwin.signingUtils
darwin.libiconv
darwin.libobjc
# darwin.xcode
# darwin.apple_sdk.sdk
darwin.apple_sdk.Libsystem
# darwin.apple_sdk.frameworks
darwin.apple_sdk.frameworks.SystemConfiguration
darwin.apple_sdk.frameworks.AppKit
darwin.apple_sdk.frameworks.CoreFoundation
darwin.apple_sdk.frameworks.Cocoa
darwin.apple_sdk.frameworks.Security
];
nativeBuildInputs = with pkgs; [
rustc
cargo
rustfmt
rustPackages.clippy
rust-analyzer
slint-lsp

pkg-config
uutils-coreutils
findutils
];
};
};
in
{
githubActions = nix-github-actions.lib.mkGithubMatrix { inherit (self) checks; };
}
// flake-utils.lib.eachSystem [
"x86_64-linux"
# "x86_64-darwin"
"aarch64-darwin"
] (system: buildPackageForSystem buildPackageDeps."${system}");
}