fork/helix

git clone https://git.julia.blue/fork/helix

omahsfix: typos (#13505)bfd2c727

25.07.1
3.0 KiB102 linesraw
1{
2  description = "A post-modern text editor.";
3
4  inputs = {
5    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
6    rust-overlay = {
7      url = "github:oxalica/rust-overlay";
8      inputs.nixpkgs.follows = "nixpkgs";
9    };
10  };
11
12  outputs = {
13    self,
14    nixpkgs,
15    rust-overlay,
16    ...
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      });
31    gitRev = self.rev or self.dirtyRev or null;
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.
38
39      The build inputs can be overridden with the following:
40
41      packages.${system}.default.override { rustPlatform = newPlatform; };
42
43      Overriding a derivation attribute can be done as well:
44
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          rustPlatform = msrvPlatform;
60        };
61      })
62      pkgsFor;
63
64    # Devshell behavior is preserved.
65    devShells =
66      lib.mapAttrs (system: pkgs: {
67        default = let
68          commonRustFlagsEnv = "-C link-arg=-fuse-ld=lld -C target-cpu=native --cfg tokio_unstable";
69          platformRustFlagsEnv = lib.optionalString pkgs.stdenv.isLinux "-Clink-arg=-Wl,--no-rosegment";
70        in
71          pkgs.mkShell {
72            inputsFrom = [self.checks.${system}.helix];
73            nativeBuildInputs = with pkgs;
74              [
75                lld
76                cargo-flamegraph
77                rust-bin.nightly.latest.rust-analyzer
78              ]
79              ++ (lib.optional (stdenv.isx86_64 && stdenv.isLinux) cargo-tarpaulin)
80              ++ (lib.optional stdenv.isLinux lldb)
81              ++ (lib.optional stdenv.isDarwin darwin.apple_sdk.frameworks.CoreFoundation);
82            shellHook = ''
83              export RUST_BACKTRACE="1"
84              export RUSTFLAGS="''${RUSTFLAGS:-""} ${commonRustFlagsEnv} ${platformRustFlagsEnv}"
85            '';
86          };
87      })
88      pkgsFor;
89
90    overlays = {
91      helix = final: prev: {
92        helix = final.callPackage ./default.nix {inherit gitRev;};
93      };
94
95      default = self.overlays.helix;
96    };
97  };
98  nixConfig = {
99    extra-substituters = ["https://helix.cachix.org"];
100    extra-trusted-public-keys = ["helix.cachix.org-1:ejp9KQpR1FBI2onstMQ34yogDm4OgU2ru6lIwPvuCVs="];
101  };
102}