diff --git a/buildkite.yaml b/buildkite.yaml index 5f849aa..8d71b5d 100644 --- a/buildkite.yaml +++ b/buildkite.yaml @@ -3,10 +3,6 @@ steps: command: - nix3 build - - label: build-musl - command: - - nix3 build .#packages.x86_64-linux.musl - - label: cache if: build.branch == "main" command: @@ -65,6 +61,9 @@ steps: - echo --- Closure @ before - 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 - nix-env --query --available --attr-path --drv-path --file nixpkgs --xml > closure-after.txt diff --git a/flake.lock b/flake.lock index 0a8e5b4..71c9137 100644 --- a/flake.lock +++ b/flake.lock @@ -5,16 +5,14 @@ "nixpkgs": [ "nixpkgs" ], - "rust-analyzer-src": [ - "rustAnalyzer" - ] + "rust-analyzer-src": "rust-analyzer-src" }, "locked": { - "lastModified": 1644387840, - "narHash": "sha256-g3On+GqjP5YRlseypyJxOM/Dz9bKW3iTbV0Nfz5Py6I=", + "lastModified": 1644560676, + "narHash": "sha256-KBC2Fn6ynCIE2sUUmJiNPY2QDWeh9caP8M1RPiUW5nE=", "owner": "nix-community", "repo": "fenix", - "rev": "f950cc5036dc2a6631d39e0887e9f6a9a92c4dd9", + "rev": "6fbfc2821a058eb820bb3742a762bbba5a99f0df", "type": "github" }, "original": { @@ -39,33 +37,17 @@ "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": { "locked": { - "lastModified": 1644420267, - "narHash": "sha256-rFJuctggkjM412OC6OGPdXogFp7czGDW05ueWqpJbj8=", + "lastModified": 1644621736, + "narHash": "sha256-6baXgx2g80v/O99dSJOI8AStcQmfukXEE6rAzeV0OEk=", "owner": "nixos", "repo": "nixpkgs", - "rev": "98bb5b77c8c6666824a4c13d23befa1e07210ef1", + "rev": "8fdd33cfc443ad15876675475d52b4de2de58d3f", "type": "github" }, "original": { "owner": "nixos", - "ref": "nixpkgs-unstable", "repo": "nixpkgs", "type": "github" } @@ -74,13 +56,10 @@ "inputs": { "fenix": "fenix", "flakeCompat": "flakeCompat", - "flakeUtils": "flakeUtils", - "nixpkgs": "nixpkgs", - "rustAnalyzer": "rustAnalyzer", - "treefmt": "treefmt" + "nixpkgs": "nixpkgs" } }, - "rustAnalyzer": { + "rust-analyzer-src": { "flake": false, "locked": { "lastModified": 1644391473, @@ -92,32 +71,10 @@ }, "original": { "owner": "rust-analyzer", + "ref": "nightly", "repo": "rust-analyzer", "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", diff --git a/flake.nix b/flake.nix index bdb5bff..ca0d8e8 100644 --- a/flake.nix +++ b/flake.nix @@ -1,99 +1,105 @@ { - description = "The Uncompromising Nix Code Formatter."; + description = "The Uncompromising Nix Code Formatter"; inputs = { fenix.url = "github:nix-community/fenix"; fenix.inputs.nixpkgs.follows = "nixpkgs"; - fenix.inputs.rust-analyzer-src.follows = "rustAnalyzer"; flakeCompat.url = github:edolstra/flake-compat; flakeCompat.flake = false; - flakeUtils.url = "github:numtide/flake-utils"; - - 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"; + nixpkgs.url = "github:nixos/nixpkgs"; }; - outputs = inputs: - 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"; - }; + outputs = inputs: let + build = host: target: let + nixpkgs = import inputs.nixpkgs { + system = host; + crossSystem = builtins.getAttr target { + "aarch64-apple-darwin" = inputs.nixpkgs.lib.systems.examples.aarch64-darwin; + "aarch64-unknown-linux-musl".config = "aarch64-unknown-linux-musl"; + "x86_64-apple-darwin" = null; + "x86_64-unknown-linux-gnu".config = "x86_64-unknown-linux-gnu"; + "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}; - fenixPlatform = nixpkgs.makeRustPlatform { inherit (fenix.latest) cargo rustc; }; - 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 + }; + + fenix = inputs.fenix.packages.${host}; + rustPlatform = nixpkgs.makeRustPlatform { + cargo = fenix.latest.cargo; + rustc = fenix.combine [ + fenix.latest.rustc + fenix.targets.${target}.latest.rust-std ]; - packageWith = platform: target: - platform.buildRustPackage { - pname = cargoToml.package.name; - version = - let - commit = inputs.self.shortRev or "dirty"; - date = - inputs.self.lastModifiedDate or inputs.self.lastModified or "19700101"; - in - "${builtins.substring 0 8 date}_${commit}"; - src = inputs.self.sourceInfo; - inherit target; - cargoLock.lockFile = ./Cargo.lock; - meta = { - description = cargoToml.package.description; - homepage = "https://github.com/kamadorueda/alejandra"; - license = nixpkgs.lib.licenses.unlicense; - maintainers = [ nixpkgs.lib.maintainers.kamadorueda ]; - }; + }; + in + { + bin = rustPlatform.buildRustPackage { + pname = "alejandra"; + version = + let + commit = inputs.self.shortRev or "dirty"; + date = inputs.self.lastModifiedDate or inputs.self.lastModified or "19700101"; + in + "${builtins.substring 0 8 date}_${commit}"; + src = ./.; + inherit target; + cargoLock.lockFile = ./Cargo.lock; + meta = { + description = "The Uncompromising Nix Code Formatter."; + homepage = "https://github.com/kamadorueda/alejandra"; + license = nixpkgs.lib.licenses.unlicense; + 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 = [ - fenix.rust-analyzer - fenix.latest.toolchain - nixpkgs.cargo-tarpaulin - nixpkgs.jq - nixpkgs.nodejs - nixpkgs.nodePackages.prettier - nixpkgs.nodePackages.prettier-plugin-toml - nixpkgs.shfmt - treefmt - ]; - }; - } - // ( - if system == "x86_64-linux" - then - { - packages.musl = packageWith fenixPlatformMusl "x86_64-unknown-linux-musl"; - } - else { } - ) - ); + }; + shell = nixpkgs.mkShell { + name = "alejandra"; + packages = [ + fenix.latest.toolchain + nixpkgs.cargo-tarpaulin + nixpkgs.jq + nixpkgs.nodejs + nixpkgs.nodePackages.prettier + nixpkgs.nodePackages.prettier-plugin-toml + nixpkgs.shfmt + nixpkgs.treefmt + ]; + }; + }; + in + rec { + checks."aarch64-darwin" = packages."aarch64-darwin"; + checks."x86_64-darwin" = packages."x86_64-darwin"; + checks."aarch64-linux" = packages."aarch64-linux"; + checks."x86_64-linux" = packages."x86_64-linux"; + + defaultPackage."aarch64-darwin" = + packages."aarch64-darwin"."aarch64-apple-darwin"; + + defaultPackage."aarch64-linux" = + packages."aarch64-linux"."aarch64-unknown-linux-musl"; + + defaultPackage."x86_64-darwin" = + 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; + }; }