-
Notifications
You must be signed in to change notification settings - Fork 1
/
flake.nix
168 lines (150 loc) · 4.67 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
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
{
description = "cgt-tools";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
flake-parts = {
url = "github:hercules-ci/flake-parts";
inputs.nixpkgs-lib.follows = "nixpkgs";
};
pre-commit-hooks-nix = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.nixpkgs-stable.follows = "nixpkgs";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
};
hercules-ci-effects = {
url = "github:hercules-ci/hercules-ci-effects";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-parts.follows = "flake-parts";
};
};
outputs = inputs @ {self, ...}:
inputs.flake-parts.lib.mkFlake {inherit inputs;} {
imports = [
inputs.pre-commit-hooks-nix.flakeModule
inputs.hercules-ci-effects.flakeModule
];
# `nix flake show --impure` hack
systems =
if builtins.hasAttr "currentSystem" builtins
then [builtins.currentSystem]
else inputs.nixpkgs.lib.systems.flakeExposed;
herculesCI.ciSystems = ["x86_64-linux"];
hercules-ci.github-releases.files = [
{
label = "cgt-tools-x86_64-windows.zip";
path = "${self.outputs.packages.x86_64-linux.cgt-tools-x86_64-windows-bundle}";
}
];
perSystem = {
config,
self',
inputs',
pkgs,
lib,
system,
...
}: let
rustToolchain = pkgs.rust-bin.fromRustupToolchain {
channel = "stable";
components = ["rust-analyzer" "rust-src" "rustfmt" "rustc" "cargo"];
targets = [
"x86_64-unknown-linux-gnu"
"x86_64-unknown-linux-musl"
];
};
pythonToolchain = "python311";
hostPkgs = pkgs;
mkCgtTools = {pkgs}:
pkgs.rustPlatform.buildRustPackage {
name = "cgt-tools";
src = lib.cleanSourceWith {
src = ./.;
filter = name: type: let
baseName = baseNameOf (toString name);
in
!((!lib.cleanSourceFilter name type)
|| (baseName == "flake.lock")
|| (lib.hasSuffix ".nix" baseName)
|| (lib.hasSuffix ".md" baseName));
};
cargoLock.lockFile = ./Cargo.lock;
cargoBuildFlags = ["-p cgt_gui -p cgt_cli"];
buildInputs = [
pkgs.SDL2
];
doCheck = false;
};
in {
_module.args.pkgs = import self.inputs.nixpkgs {
inherit system;
overlays = [
inputs.rust-overlay.overlays.rust-overlay
];
};
pre-commit.settings = {
src = ./.;
hooks = {
alejandra.enable = true;
rustfmt.enable = true;
};
tools = {
rustfmt = lib.mkForce rustToolchain;
clippy = lib.mkForce rustToolchain;
};
};
packages = {
cgt-tools-x86_64-windows = mkCgtTools {
pkgs = pkgs.pkgsCross.mingwW64;
};
cgt-tools-x86_64-windows-bundle =
pkgs.runCommand "cgt-tools-x86_64-windows.zip" {
nativeBuildInputs = [pkgs.zip];
} ''
cp --no-preserve=all -vLr ${self'.packages.cgt-tools-x86_64-windows}/bin/ ./cgt-tools-x86_64-windows
cp --no-preserve=all ${./LICENSE} ./cgt-tools-x86_64-windows/LICENSE
zip -r cgt-tools-x86_64-windows.zip cgt-tools-x86_64-windows
mv cgt-tools-x86_64-windows.zip $out
'';
cgt-tools = mkCgtTools {
inherit pkgs;
};
};
devShells.default = pkgs.mkShell {
shellHook = ''
${config.pre-commit.installationScript}
PATH=$PATH:$(pwd)/target/release
'';
nativeBuildInputs = [
pkgs.${pythonToolchain}
pkgs.${pythonToolchain}.pkgs.pip
pkgs.alejandra
pkgs.cargo-expand
pkgs.cargo-flamegraph
pkgs.cargo-leptos
pkgs.cargo-machete
pkgs.cargo-modules
pkgs.cargo-nextest
pkgs.cargo-semver-checks
pkgs.cargo-tarpaulin
pkgs.cargo-udeps
pkgs.fd
pkgs.graphviz
pkgs.heaptrack
pkgs.hyperfine
pkgs.maturin
pkgs.sage
pkgs.texlive.combined.scheme-full
pkgs.trunk
pkgs.pkg-config
pkgs.SDL2
rustToolchain
pkgs.wineWow64Packages.unstableFull
];
};
formatter = pkgs.alejandra;
};
};
}