Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 26 additions & 14 deletions default.nix
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
(
import
(
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
in
fetchTarball {
url = lock.nodes.flake-compat.locked.url or "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
sha256 = lock.nodes.flake-compat.locked.narHash;
}
)
{src = ./.;}
)
.defaultNix
# This file provides backward compatibility to nix < 2.4 clients
{
system ? builtins.currentSystem,
}:
let
lock = builtins.fromJSON (builtins.readFile ./flake.lock);

root = lock.nodes.${lock.root};
inherit (lock.nodes.${root.inputs.flake-compat}.locked)
owner
repo
rev
narHash
;

flake-compat = fetchTarball {
url = "https://github.com/${owner}/${repo}/archive/${rev}.tar.gz";
sha256 = narHash;
};

flake = import flake-compat {
inherit system;
src = ./.;
};
in
flake.defaultNix
40 changes: 12 additions & 28 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

54 changes: 11 additions & 43 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -2,66 +2,34 @@
description = "High-performance, multiplayer code editor from the creators of Atom and Tree-sitter";

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-unstable";
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
crane.url = "github:ipetkov/crane";
flake-compat.url = "github:edolstra/flake-compat";
flake-compat.url = "github:nix-community/flake-compat";
};

outputs =
{
nixpkgs,
rust-overlay,
crane,
...
}:
{ nixpkgs, ... }@inputs:
let
systems = [
"x86_64-linux"
"x86_64-darwin"
"aarch64-linux"
"aarch64-darwin"
];

overlays = {
rust-overlay = rust-overlay.overlays.default;
rust-toolchain = final: prev: {
rustToolchain = final.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
};
zed-editor = final: prev: {
zed-editor = final.callPackage ./nix/build.nix {
crane = crane.mkLib final;
rustToolchain = final.rustToolchain;
};
};
};
overlays = [ inputs.rust-overlay.overlays.default ];

mkPkgs =
system:
import nixpkgs {
inherit system;
overlays = builtins.attrValues overlays;
};

forAllSystems = f: nixpkgs.lib.genAttrs systems (system: f (mkPkgs system));
forAllSystems =
f:
nixpkgs.lib.genAttrs nixpkgs.lib.systems.flakeExposed (
system: f (import nixpkgs { inherit system overlays; })
);
in
{
packages = forAllSystems (pkgs: {
zed-editor = pkgs.zed-editor;
default = pkgs.zed-editor;
packages = forAllSystems (_: {
default = throw "Nix package was removed from repo, see PR #22825 for an approach you can use instead";
});

devShells = forAllSystems (pkgs: {
default = import ./nix/shell.nix { inherit pkgs; };
});

formatter = forAllSystems (pkgs: pkgs.nixfmt-rfc-style);

overlays = overlays // {
default = nixpkgs.lib.composeManyExtensions (builtins.attrValues overlays);
};
};
}
Loading