forked from kamadorueda/alejandra
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathflake.nix
150 lines (134 loc) · 4.72 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
{
description = "The Uncompromising Nix Code Formatter";
inputs = {
flakeCompat.url = github:edolstra/flake-compat;
flakeCompat.flake = false;
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
};
outputs = inputs: let
commit = inputs.self.shortRev or "dirty";
date = inputs.self.lastModifiedDate or inputs.self.lastModified or "19700101";
version = "1.0.0+${builtins.substring 0 8 date}.${commit}";
nixpkgsForHost = host:
import inputs.nixpkgs {
overlays = [
(self: super: {
alejandra = self.rustPlatform.buildRustPackage {
pname = "alejandra";
inherit version;
src = self.stdenv.mkDerivation {
name = "src";
builder = builtins.toFile "builder.sh" ''
source $stdenv/setup
mkdir $out
cp -rT --no-preserve=mode,ownership $src $out/src/
cp $cargoLock $out/Cargo.lock
cp $cargoToml $out/Cargo.toml
'';
cargoLock = ./Cargo.lock;
cargoToml = ./Cargo.toml;
src = ./src;
};
cargoLock.lockFile = ./Cargo.lock;
passthru.tests = {
version = self.testVersion {package = super.alejandra;};
};
meta = {
description = "The Uncompromising Nix Code Formatter.";
homepage = "https://github.com/kamadorueda/alejandra";
license = self.lib.licenses.unlicense;
maintainers = [self.lib.maintainers.kamadorueda];
platforms = self.lib.systems.doubles.all;
};
};
})
];
system = host;
};
nixpkgs."aarch64-darwin" = nixpkgsForHost "aarch64-darwin";
nixpkgs."aarch64-linux" = nixpkgsForHost "aarch64-linux";
nixpkgs."x86_64-darwin" = nixpkgsForHost "x86_64-darwin";
nixpkgs."x86_64-linux" = nixpkgsForHost "x86_64-linux";
buildBinariesForHost = host: pkgs: let
binaries = builtins.listToAttrs (
builtins.map (pkg: {
name = "alejandra-${pkg.stdenv.targetPlatform.config}";
value = pkg;
})
pkgs
);
in
binaries
// {
"alejandra-binaries" = nixpkgs.${host}.linkFarm "alejandra-binaries" (
nixpkgs.${host}.lib.mapAttrsToList
(name: binary: {
inherit name;
path = "${binary}/bin/alejandra";
})
binaries
);
};
in rec {
checks."aarch64-darwin" = packages."aarch64-darwin";
checks."aarch64-linux" = packages."aarch64-linux";
checks."x86_64-darwin" = packages."x86_64-darwin";
checks."x86_64-linux" = packages."x86_64-linux";
defaultPackage."aarch64-darwin" = packages."aarch64-darwin"."alejandra-aarch64-apple-darwin";
defaultPackage."aarch64-linux" = packages."aarch64-linux"."alejandra-aarch64-unknown-linux-gnu";
defaultPackage."x86_64-darwin" = packages."x86_64-darwin"."alejandra-x86_64-apple-darwin";
defaultPackage."x86_64-linux" = packages."x86_64-linux"."alejandra-x86_64-unknown-linux-gnu";
devShell."x86_64-linux" = with nixpkgs."x86_64-linux";
mkShell {
name = "alejandra";
packages = [
cargo
cargo-bloat
cargo-license
cargo-tarpaulin
clippy
jq
linuxPackages_latest.perf
nodejs
nodePackages.prettier
nodePackages.prettier-plugin-toml
rustc
shfmt
treefmt
yarn
yarn2nix
];
};
packages."aarch64-darwin" = with nixpkgs."aarch64-darwin";
buildBinariesForHost "aarch64-darwin" [
alejandra
];
packages."aarch64-linux" = with nixpkgs."aarch64-linux";
buildBinariesForHost "aarch64-linux" [
alejandra
pkgsStatic.alejandra
];
packages."x86_64-darwin" = with nixpkgs."x86_64-darwin";
buildBinariesForHost "x86_64-darwin" [
alejandra
];
packages."x86_64-linux" = with nixpkgs."x86_64-linux";
(buildBinariesForHost "x86_64-linux" [
alejandra
pkgsStatic.alejandra
pkgsCross.aarch64-multiplatform.pkgsStatic.alejandra
pkgsCross.armv7l-hf-multiplatform.pkgsStatic.alejandra
pkgsCross.gnu32.pkgsStatic.alejandra
pkgsCross.raspberryPi.pkgsStatic.alejandra
])
// {
"alejandra-vscode-vsix" = mkYarnPackage {
name = "alejandra";
src = ./integrations/vscode;
packageJSON = ./integrations/vscode/package.json;
yarnLock = ./integrations/vscode/yarn.lock;
yarnNix = ./integrations/vscode/yarn.lock.nix;
};
};
};
}