Skip to content
Merged
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
2 changes: 1 addition & 1 deletion .cargo/config.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
[build]
target = "wasm32-wasi"
target = "wasm32-wasip1"
4 changes: 4 additions & 0 deletions .envrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
watch_file $(git ls-files | grep ".nix")
watch_file rust-toolchain.toml

use flake
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/target
/result
1 change: 0 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,3 @@ ansi_term = "0.12.1"
chrono = "0.4.26"
owo-colors = "3"
zellij-tile = "0.41"

165 changes: 165 additions & 0 deletions flake.lock

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

126 changes: 126 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,126 @@
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-utils.url = "github:numtide/flake-utils";
gitignore = {
url = "github:hercules-ci/gitignore.nix";
inputs.nixpkgs.follows = "nixpkgs";
};
treefmt-nix = {
url = "github:numtide/treefmt-nix";
inputs.nixpkgs.follows = "nixpkgs";
};
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
pre-commit-hooks = {
url = "github:cachix/pre-commit-hooks.nix";
inputs = {
nixpkgs.follows = "nixpkgs";
gitignore.follows = "gitignore";
};
};
};

outputs =
{
nixpkgs,
flake-utils,
pre-commit-hooks,
rust-overlay,
treefmt-nix,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [ (import rust-overlay) ];
};
inherit (pkgs) mkShell;

rust = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
buildTarget = "wasm32-wasip1";

rustPlatform = pkgs.makeRustPlatform {
rustc = rust;
cargo = rust;
};

room-formatter =
(treefmt-nix.lib.evalModule pkgs {
projectRootFile = "flake.nix";

settings = {
allow-missing-formatter = true;
verbose = 0;

global.excludes = [ "*.lock" ];

formatter = {
nixfmt.options = [ "--strict" ];
rustfmt.package = rust;
};
};

programs = {
nixfmt.enable = true;
rustfmt = {
enable = true;
package = rust;
};
taplo.enable = true;
};
}).config.build.wrapper;

pre-commit-check = pre-commit-hooks.lib.${system}.run {
src = ./.;

hooks = {
deadnix.enable = true;
nixfmt-rfc-style.enable = true;
treefmt = {
enable = true;
package = room-formatter;
};
};
};

packages.default = rustPlatform.buildRustPackage rec {
name = "room";
src = ./.;
cargoLock.lockFile = ./Cargo.lock;

nativeBuildInputs = with pkgs; [ perl ];

buildPhase = ''
cargo build --release --target=${buildTarget}
'';

installPhase = ''
mkdir -p $out/lib/zellij/plugins
cp target/${buildTarget}/release/${name}.wasm $out/lib/zellij/plugins
'';
};
in
{
inherit packages;

checks = { inherit pre-commit-check; };

devShells.default = mkShell {
name = "room";

buildInputs = [
rust
room-formatter
];
};

formatter = room-formatter;
nixosModules.default = import ./. { inherit (packages) default; };
}
);
}
10 changes: 10 additions & 0 deletions rust-toolchain.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
[toolchain]
channel = "stable"
components = [
"clippy",
"llvm-tools-preview",
"rust-analyzer",
"rust-src",
"rustfmt",
]
targets = ["wasm32-wasip1"]
Loading