fork/helix

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

Michael Davisflake: Remove darwin CoreFoundation dev-shell input97aee495

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