|
3 | 3 |
|
4 | 4 | inputs = {
|
5 | 5 | nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
6 |
| - flake-utils.url = "github:numtide/flake-utils"; |
7 | 6 | rust-overlay = {
|
8 | 7 | url = "github:oxalica/rust-overlay";
|
9 | 8 | inputs.nixpkgs.follows = "nixpkgs";
|
|
13 | 12 | outputs = {
|
14 | 13 | self,
|
15 | 14 | nixpkgs,
|
16 |
| - flake-utils, |
17 | 15 | rust-overlay,
|
18 | 16 | ...
|
19 | 17 | }: let
|
| 18 | + inherit (nixpkgs) lib; |
| 19 | + systems = [ |
| 20 | + "x86_64-linux" |
| 21 | + "aarch64-linux" |
| 22 | + "x86_64-darwin" |
| 23 | + "aarch64-darwin" |
| 24 | + ]; |
| 25 | + eachSystem = lib.genAttrs systems; |
| 26 | + pkgsFor = eachSystem (system: |
| 27 | + import nixpkgs { |
| 28 | + localSystem.system = system; |
| 29 | + overlays = [(import rust-overlay) self.overlays.helix]; |
| 30 | + }); |
20 | 31 | gitRev = self.rev or self.dirtyRev or null;
|
21 |
| - in |
22 |
| - flake-utils.lib.eachDefaultSystem (system: let |
23 |
| - pkgs = import nixpkgs { |
24 |
| - inherit system; |
25 |
| - overlays = [(import rust-overlay)]; |
26 |
| - }; |
| 32 | + in { |
| 33 | + packages = eachSystem (system: { |
| 34 | + inherit (pkgsFor.${system}) helix; |
| 35 | + /* |
| 36 | + The default Helix build. Uses the latest stable Rust toolchain, and unstable |
| 37 | + nixpkgs. |
27 | 38 |
|
28 |
| - # Get Helix's MSRV toolchain to build with by default. |
29 |
| - msrvToolchain = pkgs.pkgsBuildHost.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; |
30 |
| - msrvPlatform = pkgs.makeRustPlatform { |
31 |
| - cargo = msrvToolchain; |
32 |
| - rustc = msrvToolchain; |
33 |
| - }; |
34 |
| - in { |
35 |
| - packages = rec { |
36 |
| - helix = pkgs.callPackage ./default.nix {inherit gitRev;}; |
| 39 | + The build inputs can be overriden with the following: |
37 | 40 |
|
38 |
| - /** |
39 |
| - The default Helix build. Uses the latest stable Rust toolchain, and unstable |
40 |
| - nixpkgs. |
41 |
| - |
42 |
| - The build inputs can be overriden with the following: |
43 |
| - |
44 |
| - packages.${system}.default.override { rustPlatform = newPlatform; }; |
45 |
| - |
46 |
| - Overriding a derivation attribute can be done as well: |
47 |
| - |
48 |
| - packages.${system}.default.overrideAttrs { buildType = "debug"; }; |
49 |
| - */ |
50 |
| - default = helix; |
51 |
| - }; |
| 41 | + packages.${system}.default.override { rustPlatform = newPlatform; }; |
52 | 42 |
|
53 |
| - checks.helix = self.outputs.packages.${system}.helix.override { |
54 |
| - buildType = "debug"; |
55 |
| - rustPlatform = msrvPlatform; |
56 |
| - }; |
| 43 | + Overriding a derivation attribute can be done as well: |
57 | 44 |
|
58 |
| - # Devshell behavior is preserved. |
59 |
| - devShells.default = let |
60 |
| - commonRustFlagsEnv = "-C link-arg=-fuse-ld=lld -C target-cpu=native --cfg tokio_unstable"; |
61 |
| - platformRustFlagsEnv = pkgs.lib.optionalString pkgs.stdenv.isLinux "-Clink-arg=-Wl,--no-rosegment"; |
62 |
| - in |
63 |
| - pkgs.mkShell |
64 |
| - { |
65 |
| - inputsFrom = [self.checks.${system}.helix]; |
66 |
| - nativeBuildInputs = with pkgs; |
67 |
| - [ |
68 |
| - lld |
69 |
| - cargo-flamegraph |
70 |
| - rust-bin.nightly.latest.rust-analyzer |
71 |
| - ] |
72 |
| - ++ (lib.optional (stdenv.isx86_64 && stdenv.isLinux) cargo-tarpaulin) |
73 |
| - ++ (lib.optional stdenv.isLinux lldb) |
74 |
| - ++ (lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.CoreFoundation); |
75 |
| - shellHook = '' |
76 |
| - export RUST_BACKTRACE="1" |
77 |
| - export RUSTFLAGS="''${RUSTFLAGS:-""} ${commonRustFlagsEnv} ${platformRustFlagsEnv}" |
78 |
| - ''; |
| 45 | + packages.${system}.default.overrideAttrs { buildType = "debug"; }; |
| 46 | + */ |
| 47 | + default = self.packages.${system}.helix; |
| 48 | + }); |
| 49 | + checks = |
| 50 | + lib.mapAttrs (system: pkgs: let |
| 51 | + # Get Helix's MSRV toolchain to build with by default. |
| 52 | + msrvToolchain = pkgs.pkgsBuildHost.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; |
| 53 | + msrvPlatform = pkgs.makeRustPlatform { |
| 54 | + cargo = msrvToolchain; |
| 55 | + rustc = msrvToolchain; |
| 56 | + }; |
| 57 | + in { |
| 58 | + helix = self.packages.${system}.helix.override { |
| 59 | + buildType = "debug"; |
| 60 | + rustPlatform = msrvPlatform; |
79 | 61 | };
|
80 |
| - }) |
81 |
| - // { |
82 |
| - overlays.default = final: prev: { |
| 62 | + }) |
| 63 | + pkgsFor; |
| 64 | + |
| 65 | + # Devshell behavior is preserved. |
| 66 | + devShells = |
| 67 | + lib.mapAttrs (system: pkgs: { |
| 68 | + default = let |
| 69 | + commonRustFlagsEnv = "-C link-arg=-fuse-ld=lld -C target-cpu=native --cfg tokio_unstable"; |
| 70 | + platformRustFlagsEnv = lib.optionalString pkgs.stdenv.isLinux "-Clink-arg=-Wl,--no-rosegment"; |
| 71 | + in |
| 72 | + pkgs.mkShell { |
| 73 | + inputsFrom = [self.checks.${system}.helix]; |
| 74 | + nativeBuildInputs = with pkgs; |
| 75 | + [ |
| 76 | + lld |
| 77 | + cargo-flamegraph |
| 78 | + rust-bin.nightly.latest.rust-analyzer |
| 79 | + ] |
| 80 | + ++ (lib.optional (stdenv.isx86_64 && stdenv.isLinux) cargo-tarpaulin) |
| 81 | + ++ (lib.optional stdenv.isLinux lldb) |
| 82 | + ++ (lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.CoreFoundation); |
| 83 | + shellHook = '' |
| 84 | + export RUST_BACKTRACE="1" |
| 85 | + export RUSTFLAGS="''${RUSTFLAGS:-""} ${commonRustFlagsEnv} ${platformRustFlagsEnv}" |
| 86 | + ''; |
| 87 | + }; |
| 88 | + }) |
| 89 | + pkgsFor; |
| 90 | + |
| 91 | + overlays = { |
| 92 | + helix = final: prev: { |
83 | 93 | helix = final.callPackage ./default.nix {inherit gitRev;};
|
84 | 94 | };
|
85 |
| - }; |
86 | 95 |
|
| 96 | + default = self.overlays.helix; |
| 97 | + }; |
| 98 | + }; |
87 | 99 | nixConfig = {
|
88 | 100 | extra-substituters = ["https://helix.cachix.org"];
|
89 | 101 | extra-trusted-public-keys = ["helix.cachix.org-1:ejp9KQpR1FBI2onstMQ34yogDm4OgU2ru6lIwPvuCVs="];
|
|
0 commit comments