Skip to content

Commit

Permalink
Merge pull request #70 from tomberek/static_musl
Browse files Browse the repository at this point in the history
static builds for x86_64-unknown-linux-musl
  • Loading branch information
kamadorueda committed Feb 11, 2022
2 parents 4ff1547 + 856919e commit 31fe742
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 8 deletions.
6 changes: 6 additions & 0 deletions buildkite.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,18 @@ steps:
command:
- nix3 build

- label: build-musl
command:
- nix3 build .#packages.x86_64-linux.musl

- label: cache
if: build.branch == "main"
command:
- echo +++
- nix3 build
- cachix push alejandra result
- nix3 build .#packages.x86_64-linux.musl
- cachix push alejandra result

- nix3 develop --profile develop --command true
- cachix push alejandra develop
Expand Down
44 changes: 36 additions & 8 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -23,18 +23,29 @@
inputs.flakeUtils.lib.eachSystem [ "x86_64-darwin" "x86_64-linux" ] (
system: let
nixpkgs = import inputs.nixpkgs { inherit system; };
nixpkgsMusl = import inputs.nixpkgs {
inherit system;
crossSystem =
nixpkgs.lib.systems.examples.musl64
// {
rustc.config = "x86_64-unknown-linux-musl";
};
};
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
treefmt = inputs.treefmt.defaultPackage.${system};
fenix = inputs.fenix.packages.${system};
fenixPlatform = nixpkgs.makeRustPlatform { inherit (fenix.latest) cargo rustc; };
in
{
checks.defaultPackage = inputs.self.defaultPackage.${system};
defaultApp = {
type = "app";
program = "${inputs.self.defaultPackage.${system}}/bin/alejandra";
};
defaultPackage = fenixPlatform.buildRustPackage {
fenixPlatformMusl = nixpkgsMusl.makeRustPlatform {
cargo = muslToolchain;
rustc = muslToolchain;
};
muslToolchain = with inputs.fenix.packages.${system}; combine [
minimal.rustc
minimal.cargo
targets.x86_64-unknown-linux-musl.latest.rust-std
];
packageWith = platform: target:
platform.buildRustPackage {
pname = cargoToml.package.name;
version =
let
Expand All @@ -44,6 +55,7 @@
in
"${builtins.substring 0 8 date}_${commit}";
src = inputs.self.sourceInfo;
inherit target;
cargoLock.lockFile = ./Cargo.lock;
meta = {
description = cargoToml.package.description;
Expand All @@ -52,6 +64,14 @@
maintainers = [ nixpkgs.lib.maintainers.kamadorueda ];
};
};
in
{
checks.defaultPackage = inputs.self.defaultPackage.${system};
defaultApp = {
type = "app";
program = "${inputs.self.defaultPackage.${system}}/bin/alejandra";
};
defaultPackage = packageWith fenixPlatform system;
devShell = nixpkgs.mkShell {
name = "Alejandra";
packages = [
Expand All @@ -67,5 +87,13 @@
];
};
}
// (
if system == "x86_64-linux"
then
{
packages.musl = packageWith fenixPlatformMusl "x86_64-unknown-linux-musl";
}
else { }
)
);
}

0 comments on commit 31fe742

Please sign in to comment.