|
1 | 1 | { |
2 | 2 | inputs = { |
3 | 3 | nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; |
4 | | - flake-utils.url = "github:numtide/flake-utils"; |
5 | | - rust-overlay.url = "github:oxalica/rust-overlay"; |
| 4 | + flake-parts = { |
| 5 | + url = "github:hercules-ci/flake-parts"; |
| 6 | + inputs.nixpkgs-lib.follows = "nixpkgs"; |
| 7 | + }; |
6 | 8 | }; |
7 | 9 |
|
8 | 10 | outputs = |
9 | | - { |
10 | | - self, |
| 11 | + inputs@{ |
11 | 12 | nixpkgs, |
12 | | - rust-overlay, |
13 | | - flake-utils, |
| 13 | + flake-parts, |
| 14 | + ... |
14 | 15 | }: |
15 | | - flake-utils.lib.eachDefaultSystem ( |
16 | | - system: |
17 | | - let |
18 | | - pkgs = import nixpkgs { |
19 | | - inherit system; |
20 | | - overlays = [ (import rust-overlay) ]; |
21 | | - }; |
22 | | - in |
23 | | - { |
24 | | - formatter = pkgs.treefmt.withConfig { |
25 | | - runtimeInputs = [ |
26 | | - pkgs.nixfmt |
27 | | - pkgs.rustfmt |
28 | | - ]; |
| 16 | + flake-parts.lib.mkFlake { inherit inputs; } { |
| 17 | + systems = nixpkgs.lib.systems.flakeExposed; |
| 18 | + perSystem = |
| 19 | + { system, pkgs, ... }: |
| 20 | + { |
| 21 | + formatter = pkgs.treefmt.withConfig { |
| 22 | + runtimeInputs = [ |
| 23 | + pkgs.nixfmt |
| 24 | + pkgs.rustfmt |
| 25 | + ]; |
29 | 26 |
|
30 | | - settings = { |
31 | | - on-unmatched = "info"; |
| 27 | + settings = { |
| 28 | + on-unmatched = "info"; |
32 | 29 |
|
33 | | - formatter.nixfmt = { |
34 | | - command = "nixfmt"; |
35 | | - includes = [ "*.nix" ]; |
36 | | - }; |
| 30 | + formatter.nixfmt = { |
| 31 | + command = "nixfmt"; |
| 32 | + includes = [ "*.nix" ]; |
| 33 | + }; |
37 | 34 |
|
38 | | - formatter.rustfmt = { |
39 | | - command = "rustfmt"; |
40 | | - includes = [ "*.rs" ]; |
| 35 | + formatter.rustfmt = { |
| 36 | + command = "rustfmt"; |
| 37 | + includes = [ "*.rs" ]; |
| 38 | + }; |
41 | 39 | }; |
42 | 40 | }; |
43 | | - }; |
44 | 41 |
|
45 | | - packages.default = |
46 | | - let |
47 | | - cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml); |
48 | | - in |
49 | | - pkgs.rustPlatform.buildRustPackage { |
50 | | - pname = "seabird-plugin-bundle"; |
51 | | - version = cargoToml.package.version; |
52 | | - src = ./.; |
53 | | - cargoLock.lockFile = ./Cargo.lock; |
| 42 | + packages.default = |
| 43 | + let |
| 44 | + version = builtins.fromTOML (builtins.readFile ./Cargo.toml).package.version; |
| 45 | + in |
| 46 | + pkgs.rustPlatform.buildRustPackage { |
| 47 | + inherit version; |
54 | 48 |
|
55 | | - nativeBuildInputs = [ pkgs.protobuf ]; |
| 49 | + pname = "seabird-plugin-bundle"; |
| 50 | + src = ./.; |
| 51 | + cargoLock.lockFile = ./Cargo.lock; |
56 | 52 |
|
57 | | - # sqlx uses the checked-in .sqlx cache instead of a live database. |
58 | | - SQLX_OFFLINE = true; |
| 53 | + nativeBuildInputs = [ pkgs.protobuf ]; |
59 | 54 |
|
60 | | - # Flake builds run against the git tree without a .git directory, so |
61 | | - # git_version can't read the hash. Stamp a stable version string for |
62 | | - # the introspection plugin to report instead. |
63 | | - SEABIRD_GIT_VERSION = "v${cargoToml.package.version}-nix"; |
64 | | - }; |
| 55 | + # sqlx uses the checked-in .sqlx cache instead of a live database. |
| 56 | + SQLX_OFFLINE = true; |
65 | 57 |
|
66 | | - devShells.default = pkgs.mkShell { |
67 | | - nativeBuildInputs = [ |
68 | | - (pkgs.rust-bin.stable."1.93.0".default.override { |
69 | | - extensions = [ "rust-src" ]; |
70 | | - }) |
71 | | - pkgs.rust-analyzer |
72 | | - pkgs.sqlx-cli |
73 | | - pkgs.protobuf |
74 | | - pkgs.sqlite |
75 | | - ]; |
| 58 | + # Flake builds run against the git tree without a .git directory, so |
| 59 | + # git_version can't read the hash. Stamp a stable version string for |
| 60 | + # the introspection plugin to report instead. |
| 61 | + SEABIRD_GIT_VERSION = "v${version}-nix"; |
| 62 | + }; |
| 63 | + |
| 64 | + devShells.default = pkgs.mkShell { |
| 65 | + nativeBuildInputs = [ |
| 66 | + pkgs.cargo |
| 67 | + pkgs.rustc |
| 68 | + pkgs.rust-analyzer |
| 69 | + pkgs.sqlx-cli |
| 70 | + pkgs.protobuf |
| 71 | + pkgs.sqlite |
| 72 | + ]; |
76 | 73 |
|
77 | | - RUST_BACKTRACE = 1; |
78 | | - DATABASE_URL = "sqlite://seabird.db"; |
| 74 | + RUST_BACKTRACE = 1; |
| 75 | + DATABASE_URL = "sqlite://seabird.db"; |
| 76 | + }; |
79 | 77 | }; |
80 | | - } |
81 | | - ); |
| 78 | + }; |
82 | 79 | } |
0 commit comments