flake: Limit hydra jobs to x86 and aarch64
This commit is contained in:
parent
dd36dab497
commit
59864de6bd
195
flake.nix
195
flake.nix
@ -20,107 +20,116 @@
|
|||||||
flake-utils,
|
flake-utils,
|
||||||
...
|
...
|
||||||
}:
|
}:
|
||||||
flake-utils.lib.eachDefaultSystem (
|
let
|
||||||
system:
|
packageOutputs = flake-utils.lib.eachDefaultSystem (
|
||||||
let
|
system:
|
||||||
pkgs = nixpkgs.legacyPackages.${system};
|
let
|
||||||
|
pkgs = nixpkgs.legacyPackages.${system};
|
||||||
|
|
||||||
craneLib = crane.mkLib pkgs;
|
craneLib = crane.mkLib pkgs;
|
||||||
|
|
||||||
dbMigrationsFilter = path: _type: builtins.match ".*sql$" path != null;
|
dbMigrationsFilter = path: _type: builtins.match ".*sql$" path != null;
|
||||||
dbMigrationsOrCargoFilter =
|
dbMigrationsOrCargoFilter =
|
||||||
path: type: (dbMigrationsFilter path type) || (craneLib.filterCargoSources path type);
|
path: type: (dbMigrationsFilter path type) || (craneLib.filterCargoSources path type);
|
||||||
|
|
||||||
dbMigrations = pkgs.lib.cleanSourceWith {
|
dbMigrations = pkgs.lib.cleanSourceWith {
|
||||||
src = craneLib.path ./db-migrations; # The original, unfiltered source
|
src = craneLib.path ./db-migrations; # The original, unfiltered source
|
||||||
filter = dbMigrationsFilter;
|
filter = dbMigrationsFilter;
|
||||||
};
|
|
||||||
|
|
||||||
# Common arguments can be set here to avoid repeating them later
|
|
||||||
# Note: changes here will rebuild all dependency crates
|
|
||||||
commonArgs = rec {
|
|
||||||
strictDeps = true; # When this is not set, all dependency crates will be compiled again
|
|
||||||
src = pkgs.lib.cleanSourceWith {
|
|
||||||
src = craneLib.path ./.; # The original, unfiltered source
|
|
||||||
filter = dbMigrationsOrCargoFilter;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
# Add icons.toml to $src when compiling dependencies (needed by relm4-icons)
|
# Common arguments can be set here to avoid repeating them later
|
||||||
extraDummyScript = ''
|
# Note: changes here will rebuild all dependency crates
|
||||||
cp --no-preserve=mode,ownership ${./icons.toml} $out/icons.toml
|
commonArgs = rec {
|
||||||
'';
|
strictDeps = true; # When this is not set, all dependency crates will be compiled again
|
||||||
|
src = pkgs.lib.cleanSourceWith {
|
||||||
|
src = craneLib.path ./.; # The original, unfiltered source
|
||||||
|
filter = dbMigrationsOrCargoFilter;
|
||||||
|
};
|
||||||
|
|
||||||
nativeBuildInputs = with pkgs; [ pkg-config ];
|
# Add icons.toml to $src when compiling dependencies (needed by relm4-icons)
|
||||||
|
extraDummyScript = ''
|
||||||
buildInputs =
|
cp --no-preserve=mode,ownership ${./icons.toml} $out/icons.toml
|
||||||
with pkgs;
|
|
||||||
[
|
|
||||||
gtk4
|
|
||||||
xournalpp # not needed for building
|
|
||||||
]
|
|
||||||
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
|
|
||||||
# Additional darwin specific inputs can be set here
|
|
||||||
pkgs.libiconv
|
|
||||||
];
|
|
||||||
};
|
|
||||||
|
|
||||||
# Build *just* the cargo dependencies, so we can reuse
|
|
||||||
# all of that work (e.g. via cachix) when running in CI
|
|
||||||
cargoArtifacts = craneLib.buildDepsOnly (commonArgs);
|
|
||||||
|
|
||||||
# Run clippy (and deny all warnings) on the crate source,
|
|
||||||
# reusing the dependency artifacts (e.g. from build scripts or
|
|
||||||
# proc-macros) from above.
|
|
||||||
#
|
|
||||||
# Note that this is done as a separate derivation so it
|
|
||||||
# does not impact building just the crate by itself.
|
|
||||||
myCrateClippy = craneLib.cargoClippy (
|
|
||||||
commonArgs
|
|
||||||
// {
|
|
||||||
# Again we apply some extra arguments only to this derivation
|
|
||||||
# and not every where else. In this case we add some clippy flags
|
|
||||||
inherit cargoArtifacts;
|
|
||||||
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
# Build the actual crate itself, reusing the dependency
|
|
||||||
# artifacts from above.
|
|
||||||
myCrate = craneLib.buildPackage (
|
|
||||||
commonArgs
|
|
||||||
// {
|
|
||||||
inherit cargoArtifacts;
|
|
||||||
}
|
|
||||||
// {
|
|
||||||
postInstall = ''
|
|
||||||
mkdir -p $out/share/applications
|
|
||||||
cp ${./sheet-organizer.desktop} $out/share/applications/sheet-organizer.desktop
|
|
||||||
|
|
||||||
mkdir -p $out/share/icons
|
|
||||||
cp ${./sheet-organizer.png} $out/share/icons/sheet-organizer.png
|
|
||||||
'';
|
'';
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
# Also run the crate tests under cargo-tarpaulin so that we can keep
|
nativeBuildInputs = with pkgs; [ pkg-config ];
|
||||||
# track of code coverage
|
|
||||||
myCrateCoverage = craneLib.cargoTarpaulin (commonArgs // { inherit cargoArtifacts; });
|
|
||||||
|
|
||||||
in
|
buildInputs =
|
||||||
{
|
with pkgs;
|
||||||
packages.default = myCrate;
|
[
|
||||||
checks = {
|
gtk4
|
||||||
inherit
|
xournalpp # not needed for building
|
||||||
# Build the crate as part of `nix flake check` for convenience
|
]
|
||||||
myCrate
|
++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
|
||||||
myCrateClippy
|
# Additional darwin specific inputs can be set here
|
||||||
myCrateCoverage
|
pkgs.libiconv
|
||||||
;
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
hydraJobs = {
|
# Build *just* the cargo dependencies, so we can reuse
|
||||||
"sheet-organizer" = myCrate;
|
# all of that work (e.g. via cachix) when running in CI
|
||||||
};
|
cargoArtifacts = craneLib.buildDepsOnly (commonArgs);
|
||||||
}
|
|
||||||
);
|
# Run clippy (and deny all warnings) on the crate source,
|
||||||
|
# reusing the dependency artifacts (e.g. from build scripts or
|
||||||
|
# proc-macros) from above.
|
||||||
|
#
|
||||||
|
# Note that this is done as a separate derivation so it
|
||||||
|
# does not impact building just the crate by itself.
|
||||||
|
myCrateClippy = craneLib.cargoClippy (
|
||||||
|
commonArgs
|
||||||
|
// {
|
||||||
|
# Again we apply some extra arguments only to this derivation
|
||||||
|
# and not every where else. In this case we add some clippy flags
|
||||||
|
inherit cargoArtifacts;
|
||||||
|
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
# Build the actual crate itself, reusing the dependency
|
||||||
|
# artifacts from above.
|
||||||
|
myCrate = craneLib.buildPackage (
|
||||||
|
commonArgs
|
||||||
|
// {
|
||||||
|
inherit cargoArtifacts;
|
||||||
|
}
|
||||||
|
// {
|
||||||
|
postInstall = ''
|
||||||
|
mkdir -p $out/share/applications
|
||||||
|
cp ${./sheet-organizer.desktop} $out/share/applications/sheet-organizer.desktop
|
||||||
|
|
||||||
|
mkdir -p $out/share/icons
|
||||||
|
cp ${./sheet-organizer.png} $out/share/icons/sheet-organizer.png
|
||||||
|
'';
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
# Also run the crate tests under cargo-tarpaulin so that we can keep
|
||||||
|
# track of code coverage
|
||||||
|
myCrateCoverage = craneLib.cargoTarpaulin (commonArgs // { inherit cargoArtifacts; });
|
||||||
|
|
||||||
|
in
|
||||||
|
{
|
||||||
|
packages.default = myCrate;
|
||||||
|
checks = {
|
||||||
|
inherit
|
||||||
|
# Build the crate as part of `nix flake check` for convenience
|
||||||
|
myCrate
|
||||||
|
myCrateClippy
|
||||||
|
myCrateCoverage
|
||||||
|
;
|
||||||
|
};
|
||||||
|
|
||||||
|
# hydraJobs = {
|
||||||
|
# "sheet-organizer" = myCrate;
|
||||||
|
# };
|
||||||
|
}
|
||||||
|
);
|
||||||
|
in
|
||||||
|
packageOutputs
|
||||||
|
// {
|
||||||
|
hydraJobs = {
|
||||||
|
x86_64-linux.sheet-organizer = packageOutputs.packages.x86_64-linux;
|
||||||
|
aarch64-linux.sheet-organizer = packageOutputs.packages.aarch64-linux;
|
||||||
|
};
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user