generated from srid/rust-nix-template
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathflake.nix
120 lines (110 loc) · 3.83 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
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
systems.url = "github:nix-systems/default";
# Rust
rust-flake.url = "github:juspay/rust-flake";
rust-flake.inputs.nixpkgs.follows = "nixpkgs";
cargo-doc-live.url = "github:srid/cargo-doc-live";
process-compose-flake.url = "github:Platonic-Systems/process-compose-flake";
just-flake.url = "github:juspay/just-flake";
pre-commit-hooks-nix = {
url = "github:cachix/pre-commit-hooks.nix";
inputs.nixpkgs.follows = "nixpkgs";
inputs.nixpkgs-stable.follows = "nixpkgs";
};
# Dev tools
treefmt-nix.url = "github:numtide/treefmt-nix";
# App dependenciues
devour-flake.url = "github:srid/devour-flake";
devour-flake.flake = false;
};
outputs = inputs:
inputs.flake-parts.lib.mkFlake { inherit inputs; } {
systems = import inputs.systems;
imports = [
inputs.flake-parts.flakeModules.easyOverlay
inputs.rust-flake.flakeModules.default
inputs.rust-flake.flakeModules.nixpkgs
inputs.cargo-doc-live.flakeModule
inputs.process-compose-flake.flakeModule
inputs.pre-commit-hooks-nix.flakeModule
inputs.treefmt-nix.flakeModule
inputs.just-flake.flakeModule
];
perSystem = { config, self', pkgs, lib, system, ... }: {
rust-project.crane.args = {
nativeBuildInputs = with pkgs; with pkgs.darwin.apple_sdk.frameworks; lib.optionals stdenv.isDarwin [
Security
SystemConfiguration
] ++ [
libiconv
pkg-config
];
buildInputs = lib.optionals pkgs.stdenv.isDarwin
(
with pkgs.darwin.apple_sdk.frameworks; [
IOKit
# apple_sdk refers to SDK version 10.12. To compile for `x86_64-darwin` we need 11.0
# see: https://github.com/NixOS/nixpkgs/pull/261683#issuecomment-1772935802
pkgs.darwin.apple_sdk_11_0.frameworks.CoreFoundation
]
)
++ lib.optionals pkgs.stdenv.isLinux [
pkgs.openssl
];
DEVOUR_FLAKE = inputs.devour-flake;
};
pre-commit = {
check.enable = true;
settings = {
hooks = {
treefmt.enable = true;
convco.enable = true;
};
};
};
just-flake.features = {
treefmt.enable = true;
convco.enable = true;
};
# Flake outputs
packages.default = self'.packages.nixci.overrideAttrs (oa: {
nativeBuildInputs = (oa.nativeBuildInputs or [ ]) ++ [ pkgs.installShellFiles pkgs.nix ];
postInstall = ''
installShellCompletion --cmd nixci \
--bash <($out/bin/nixci completion bash) \
--zsh <($out/bin/nixci completion zsh) \
--fish <($out/bin/nixci completion fish)
'';
});
overlayAttrs.nixci = self'.packages.default;
devShells.default = pkgs.mkShell {
name = "nixci";
inputsFrom = [
self'.devShells.nixci
config.treefmt.build.devShell
config.just-flake.outputs.devShell
];
shellHook = ''
export DEVOUR_FLAKE=${inputs.devour-flake}
'';
packages = [
pkgs.cargo-watch
config.process-compose.cargo-doc-live.outputs.package
config.pre-commit.settings.tools.convco
];
};
# Add your auto-formatters here.
# cf. https://numtide.github.io/treefmt/
treefmt.config = {
projectRootFile = "flake.nix";
programs = {
nixpkgs-fmt.enable = true;
rustfmt.enable = true;
};
};
};
};
}