mirror of
https://github.com/RGBCube/alejandra
synced 2025-07-31 04:27:45 +00:00
feat: cross compile as much as possible
This commit is contained in:
parent
31fe742025
commit
446a7b01a7
3 changed files with 105 additions and 143 deletions
|
@ -3,10 +3,6 @@ steps:
|
||||||
command:
|
command:
|
||||||
- nix3 build
|
- nix3 build
|
||||||
|
|
||||||
- label: build-musl
|
|
||||||
command:
|
|
||||||
- nix3 build .#packages.x86_64-linux.musl
|
|
||||||
|
|
||||||
- label: cache
|
- label: cache
|
||||||
if: build.branch == "main"
|
if: build.branch == "main"
|
||||||
command:
|
command:
|
||||||
|
@ -65,6 +61,9 @@ steps:
|
||||||
- echo --- Closure @ before
|
- echo --- Closure @ before
|
||||||
- nix-env --query --available --attr-path --drv-path --file nixpkgs --xml > closure-before.txt
|
- nix-env --query --available --attr-path --drv-path --file nixpkgs --xml > closure-before.txt
|
||||||
|
|
||||||
|
- echo --- Formatting
|
||||||
|
- nix3 run . -- nixpkgs 2>/dev/null
|
||||||
|
|
||||||
- echo --- Closure @ after
|
- echo --- Closure @ after
|
||||||
- nix-env --query --available --attr-path --drv-path --file nixpkgs --xml > closure-after.txt
|
- nix-env --query --available --attr-path --drv-path --file nixpkgs --xml > closure-after.txt
|
||||||
|
|
||||||
|
|
63
flake.lock
generated
63
flake.lock
generated
|
@ -5,16 +5,14 @@
|
||||||
"nixpkgs": [
|
"nixpkgs": [
|
||||||
"nixpkgs"
|
"nixpkgs"
|
||||||
],
|
],
|
||||||
"rust-analyzer-src": [
|
"rust-analyzer-src": "rust-analyzer-src"
|
||||||
"rustAnalyzer"
|
|
||||||
]
|
|
||||||
},
|
},
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1644387840,
|
"lastModified": 1644560676,
|
||||||
"narHash": "sha256-g3On+GqjP5YRlseypyJxOM/Dz9bKW3iTbV0Nfz5Py6I=",
|
"narHash": "sha256-KBC2Fn6ynCIE2sUUmJiNPY2QDWeh9caP8M1RPiUW5nE=",
|
||||||
"owner": "nix-community",
|
"owner": "nix-community",
|
||||||
"repo": "fenix",
|
"repo": "fenix",
|
||||||
"rev": "f950cc5036dc2a6631d39e0887e9f6a9a92c4dd9",
|
"rev": "6fbfc2821a058eb820bb3742a762bbba5a99f0df",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
|
@ -39,33 +37,17 @@
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"flakeUtils": {
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1644229661,
|
|
||||||
"narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "flake-utils",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"nixpkgs": {
|
"nixpkgs": {
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1644420267,
|
"lastModified": 1644621736,
|
||||||
"narHash": "sha256-rFJuctggkjM412OC6OGPdXogFp7czGDW05ueWqpJbj8=",
|
"narHash": "sha256-6baXgx2g80v/O99dSJOI8AStcQmfukXEE6rAzeV0OEk=",
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"rev": "98bb5b77c8c6666824a4c13d23befa1e07210ef1",
|
"rev": "8fdd33cfc443ad15876675475d52b4de2de58d3f",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "nixos",
|
"owner": "nixos",
|
||||||
"ref": "nixpkgs-unstable",
|
|
||||||
"repo": "nixpkgs",
|
"repo": "nixpkgs",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
|
@ -74,13 +56,10 @@
|
||||||
"inputs": {
|
"inputs": {
|
||||||
"fenix": "fenix",
|
"fenix": "fenix",
|
||||||
"flakeCompat": "flakeCompat",
|
"flakeCompat": "flakeCompat",
|
||||||
"flakeUtils": "flakeUtils",
|
"nixpkgs": "nixpkgs"
|
||||||
"nixpkgs": "nixpkgs",
|
|
||||||
"rustAnalyzer": "rustAnalyzer",
|
|
||||||
"treefmt": "treefmt"
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"rustAnalyzer": {
|
"rust-analyzer-src": {
|
||||||
"flake": false,
|
"flake": false,
|
||||||
"locked": {
|
"locked": {
|
||||||
"lastModified": 1644391473,
|
"lastModified": 1644391473,
|
||||||
|
@ -92,32 +71,10 @@
|
||||||
},
|
},
|
||||||
"original": {
|
"original": {
|
||||||
"owner": "rust-analyzer",
|
"owner": "rust-analyzer",
|
||||||
|
"ref": "nightly",
|
||||||
"repo": "rust-analyzer",
|
"repo": "rust-analyzer",
|
||||||
"type": "github"
|
"type": "github"
|
||||||
}
|
}
|
||||||
},
|
|
||||||
"treefmt": {
|
|
||||||
"inputs": {
|
|
||||||
"flake-utils": [
|
|
||||||
"flakeUtils"
|
|
||||||
],
|
|
||||||
"nixpkgs": [
|
|
||||||
"nixpkgs"
|
|
||||||
]
|
|
||||||
},
|
|
||||||
"locked": {
|
|
||||||
"lastModified": 1640364438,
|
|
||||||
"narHash": "sha256-sV1Oa9JVNmpAwZ4cnVs7ovHrKL8EPg3J08jPX/a48LI=",
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "treefmt",
|
|
||||||
"rev": "26d7f5f15e5d22d4413ba7c5ae0447fdc0b5cc76",
|
|
||||||
"type": "github"
|
|
||||||
},
|
|
||||||
"original": {
|
|
||||||
"owner": "numtide",
|
|
||||||
"repo": "treefmt",
|
|
||||||
"type": "github"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
"root": "root",
|
"root": "root",
|
||||||
|
|
178
flake.nix
178
flake.nix
|
@ -1,99 +1,105 @@
|
||||||
{
|
{
|
||||||
description = "The Uncompromising Nix Code Formatter.";
|
description = "The Uncompromising Nix Code Formatter";
|
||||||
inputs = {
|
inputs = {
|
||||||
fenix.url = "github:nix-community/fenix";
|
fenix.url = "github:nix-community/fenix";
|
||||||
fenix.inputs.nixpkgs.follows = "nixpkgs";
|
fenix.inputs.nixpkgs.follows = "nixpkgs";
|
||||||
fenix.inputs.rust-analyzer-src.follows = "rustAnalyzer";
|
|
||||||
|
|
||||||
flakeCompat.url = github:edolstra/flake-compat;
|
flakeCompat.url = github:edolstra/flake-compat;
|
||||||
flakeCompat.flake = false;
|
flakeCompat.flake = false;
|
||||||
|
|
||||||
flakeUtils.url = "github:numtide/flake-utils";
|
nixpkgs.url = "github:nixos/nixpkgs";
|
||||||
|
|
||||||
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
|
|
||||||
|
|
||||||
rustAnalyzer.url = "github:rust-analyzer/rust-analyzer";
|
|
||||||
rustAnalyzer.flake = false;
|
|
||||||
|
|
||||||
treefmt.url = "github:numtide/treefmt";
|
|
||||||
treefmt.inputs.flake-utils.follows = "flakeUtils";
|
|
||||||
treefmt.inputs.nixpkgs.follows = "nixpkgs";
|
|
||||||
};
|
};
|
||||||
outputs = inputs:
|
outputs = inputs: let
|
||||||
inputs.flakeUtils.lib.eachSystem [ "x86_64-darwin" "x86_64-linux" ] (
|
build = host: target: let
|
||||||
system: let
|
nixpkgs = import inputs.nixpkgs {
|
||||||
nixpkgs = import inputs.nixpkgs { inherit system; };
|
system = host;
|
||||||
nixpkgsMusl = import inputs.nixpkgs {
|
crossSystem = builtins.getAttr target {
|
||||||
inherit system;
|
"aarch64-apple-darwin" = inputs.nixpkgs.lib.systems.examples.aarch64-darwin;
|
||||||
crossSystem =
|
"aarch64-unknown-linux-musl".config = "aarch64-unknown-linux-musl";
|
||||||
nixpkgs.lib.systems.examples.musl64
|
"x86_64-apple-darwin" = null;
|
||||||
// {
|
"x86_64-unknown-linux-gnu".config = "x86_64-unknown-linux-gnu";
|
||||||
rustc.config = "x86_64-unknown-linux-musl";
|
"x86_64-unknown-linux-musl".config = "x86_64-unknown-linux-musl";
|
||||||
};
|
|
||||||
};
|
};
|
||||||
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
|
};
|
||||||
treefmt = inputs.treefmt.defaultPackage.${system};
|
|
||||||
fenix = inputs.fenix.packages.${system};
|
fenix = inputs.fenix.packages.${host};
|
||||||
fenixPlatform = nixpkgs.makeRustPlatform { inherit (fenix.latest) cargo rustc; };
|
rustPlatform = nixpkgs.makeRustPlatform {
|
||||||
fenixPlatformMusl = nixpkgsMusl.makeRustPlatform {
|
cargo = fenix.latest.cargo;
|
||||||
cargo = muslToolchain;
|
rustc = fenix.combine [
|
||||||
rustc = muslToolchain;
|
fenix.latest.rustc
|
||||||
};
|
fenix.targets.${target}.latest.rust-std
|
||||||
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 {
|
in
|
||||||
pname = cargoToml.package.name;
|
{
|
||||||
version =
|
bin = rustPlatform.buildRustPackage {
|
||||||
let
|
pname = "alejandra";
|
||||||
commit = inputs.self.shortRev or "dirty";
|
version =
|
||||||
date =
|
let
|
||||||
inputs.self.lastModifiedDate or inputs.self.lastModified or "19700101";
|
commit = inputs.self.shortRev or "dirty";
|
||||||
in
|
date = inputs.self.lastModifiedDate or inputs.self.lastModified or "19700101";
|
||||||
"${builtins.substring 0 8 date}_${commit}";
|
in
|
||||||
src = inputs.self.sourceInfo;
|
"${builtins.substring 0 8 date}_${commit}";
|
||||||
inherit target;
|
src = ./.;
|
||||||
cargoLock.lockFile = ./Cargo.lock;
|
inherit target;
|
||||||
meta = {
|
cargoLock.lockFile = ./Cargo.lock;
|
||||||
description = cargoToml.package.description;
|
meta = {
|
||||||
homepage = "https://github.com/kamadorueda/alejandra";
|
description = "The Uncompromising Nix Code Formatter.";
|
||||||
license = nixpkgs.lib.licenses.unlicense;
|
homepage = "https://github.com/kamadorueda/alejandra";
|
||||||
maintainers = [ nixpkgs.lib.maintainers.kamadorueda ];
|
license = nixpkgs.lib.licenses.unlicense;
|
||||||
};
|
maintainers = [ nixpkgs.lib.maintainers.kamadorueda ];
|
||||||
};
|
};
|
||||||
in
|
};
|
||||||
{
|
shell = nixpkgs.mkShell {
|
||||||
checks.defaultPackage = inputs.self.defaultPackage.${system};
|
name = "alejandra";
|
||||||
defaultApp = {
|
packages = [
|
||||||
type = "app";
|
fenix.latest.toolchain
|
||||||
program = "${inputs.self.defaultPackage.${system}}/bin/alejandra";
|
nixpkgs.cargo-tarpaulin
|
||||||
};
|
nixpkgs.jq
|
||||||
defaultPackage = packageWith fenixPlatform system;
|
nixpkgs.nodejs
|
||||||
devShell = nixpkgs.mkShell {
|
nixpkgs.nodePackages.prettier
|
||||||
name = "Alejandra";
|
nixpkgs.nodePackages.prettier-plugin-toml
|
||||||
packages = [
|
nixpkgs.shfmt
|
||||||
fenix.rust-analyzer
|
nixpkgs.treefmt
|
||||||
fenix.latest.toolchain
|
];
|
||||||
nixpkgs.cargo-tarpaulin
|
};
|
||||||
nixpkgs.jq
|
};
|
||||||
nixpkgs.nodejs
|
in
|
||||||
nixpkgs.nodePackages.prettier
|
rec {
|
||||||
nixpkgs.nodePackages.prettier-plugin-toml
|
checks."aarch64-darwin" = packages."aarch64-darwin";
|
||||||
nixpkgs.shfmt
|
checks."x86_64-darwin" = packages."x86_64-darwin";
|
||||||
treefmt
|
checks."aarch64-linux" = packages."aarch64-linux";
|
||||||
];
|
checks."x86_64-linux" = packages."x86_64-linux";
|
||||||
};
|
|
||||||
}
|
defaultPackage."aarch64-darwin" =
|
||||||
// (
|
packages."aarch64-darwin"."aarch64-apple-darwin";
|
||||||
if system == "x86_64-linux"
|
|
||||||
then
|
defaultPackage."aarch64-linux" =
|
||||||
{
|
packages."aarch64-linux"."aarch64-unknown-linux-musl";
|
||||||
packages.musl = packageWith fenixPlatformMusl "x86_64-unknown-linux-musl";
|
|
||||||
}
|
defaultPackage."x86_64-darwin" =
|
||||||
else { }
|
packages."x86_64-darwin"."x86_64-apple-darwin";
|
||||||
)
|
|
||||||
);
|
defaultPackage."x86_64-linux" =
|
||||||
|
packages."x86_64-linux"."x86_64-unknown-linux-gnu";
|
||||||
|
|
||||||
|
devShell."x86_64-linux" =
|
||||||
|
(build "x86_64-linux" "x86_64-unknown-linux-gnu").shell;
|
||||||
|
|
||||||
|
packages."aarch64-darwin"."aarch64-apple-darwin" =
|
||||||
|
(build "aarch64-darwin" "aarch64-apple-darwin").bin;
|
||||||
|
|
||||||
|
packages."aarch64-linux"."aarch64-unknown-linux-musl" =
|
||||||
|
(build "aarch64-linux" "aarch64-unknown-linux-musl").bin;
|
||||||
|
|
||||||
|
packages."x86_64-darwin"."x86_64-apple-darwin" =
|
||||||
|
(build "x86_64-darwin" "x86_64-apple-darwin").bin;
|
||||||
|
|
||||||
|
packages."x86_64-linux"."aarch64-unknown-linux-musl" =
|
||||||
|
(build "x86_64-linux" "aarch64-unknown-linux-musl").bin;
|
||||||
|
packages."x86_64-linux"."x86_64-unknown-linux-gnu" =
|
||||||
|
(build "x86_64-linux" "x86_64-unknown-linux-gnu").bin;
|
||||||
|
packages."x86_64-linux"."x86_64-unknown-linux-musl" =
|
||||||
|
(build "x86_64-linux" "x86_64-unknown-linux-musl").bin;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue