Skip to content

Commit

Permalink
Rework flake
Browse files Browse the repository at this point in the history
  • Loading branch information
IGI-111 committed May 26, 2024
1 parent c630e44 commit 8bbeafd
Showing 1 changed file with 107 additions and 75 deletions.
182 changes: 107 additions & 75 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -16,89 +16,121 @@
nix-github-actions,
...
}:
{
githubActions = nix-github-actions.lib.mkGithubMatrix {
checks = nixpkgs.lib.getAttrs [
"x86_64-linux"
# "x86_64-darwin"
] self.checks;
};
}
// (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;
src =
let
# Only keeps slint files
dirFilter = path: _type: builtins.match ".*(assets|src|ui)/.*$" path != null;
slintFilter = path: _type: builtins.match ".*slint$" path != null;
sourceFilter =
path: type:
(dirFilter path type) || (slintFilter path type) || (craneLib.filterCargoSources path type);
in
nixpkgs.lib.cleanSourceWith {
src = craneLib.path ./.;
filter = sourceFilter;
let
buildPackageForSystem =
{
pkgs,
buildInputs,
nativeBuildInputs,
}:
let
craneLib = crane.mkLib pkgs;
libPath = pkgs.lib.makeLibraryPath buildInputs;
src =
let
# Only keeps slint files
dirFilter = path: _type: builtins.match ".*(assets|src|ui)/.*$" path != null;
slintFilter = path: _type: builtins.match ".*slint$" path != null;
sourceFilter =
path: type:
(dirFilter path type) || (slintFilter path type) || (craneLib.filterCargoSources path type);
in
nixpkgs.lib.cleanSourceWith {
src = craneLib.path ./.;
filter = sourceFilter;
};
cargoArtifacts = craneLib.buildDepsOnly {
inherit src buildInputs nativeBuildInputs;
LD_LIBRARY_PATH = libPath;
};
cargoArtifacts = craneLib.buildDepsOnly {
inherit src buildInputs nativeBuildInputs;
LD_LIBRARY_PATH = libPath;
};
kira = craneLib.buildPackage {
inherit
src
buildInputs
nativeBuildInputs
cargoArtifacts
;
LD_LIBRARY_PATH = libPath;
};
in
{
packages.default = kira;

checks = {
inherit kira;
kira-clippy = craneLib.cargoClippy {
kira = craneLib.buildPackage {
inherit
src
buildInputs
nativeBuildInputs
cargoArtifacts
;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
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;
};
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.libicov
];
nativeBuildInputs = with pkgs; [
rustc
cargo
rustfmt
rustPackages.clippy
rust-analyzer
slint-lsp

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

0 comments on commit 8bbeafd

Please sign in to comment.