add: plugins to nix builds (#1314)
* add: plugins to nix builds * chore(fmt): treefmt
This commit is contained in:
parent
ac3c09066b
commit
bc44a77f1c
3 changed files with 91 additions and 18 deletions
|
|
@ -3,6 +3,7 @@
|
||||||
crate2nix,
|
crate2nix,
|
||||||
name,
|
name,
|
||||||
src,
|
src,
|
||||||
|
patchPhase,
|
||||||
postInstall,
|
postInstall,
|
||||||
nativeBuildInputs,
|
nativeBuildInputs,
|
||||||
desktopItems,
|
desktopItems,
|
||||||
|
|
@ -27,7 +28,7 @@
|
||||||
// {
|
// {
|
||||||
# Crate dependency overrides go here
|
# Crate dependency overrides go here
|
||||||
zellij = attrs: {
|
zellij = attrs: {
|
||||||
inherit postInstall desktopItems meta name nativeBuildInputs;
|
inherit postInstall desktopItems meta name nativeBuildInputs patchPhase;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
|
||||||
|
|
@ -40,10 +40,12 @@ flake-utils.lib.eachSystem [
|
||||||
|
|
||||||
src = pkgs.nix-gitignore.gitignoreSource ignoreSource root;
|
src = pkgs.nix-gitignore.gitignoreSource ignoreSource root;
|
||||||
|
|
||||||
|
cargoToml = builtins.fromTOML (builtins.readFile (src + ./Cargo.toml));
|
||||||
rustToolchainToml = pkgs.rust-bin.fromRustupToolchainFile (src + "/rust-toolchain.toml");
|
rustToolchainToml = pkgs.rust-bin.fromRustupToolchainFile (src + "/rust-toolchain.toml");
|
||||||
|
|
||||||
cargoLock = {
|
cargoLock = {
|
||||||
lockFile = builtins.path {
|
lockFile = builtins.path {
|
||||||
path = ../Cargo.lock;
|
path = src + "/Cargo.lock";
|
||||||
name = "Cargo.lock";
|
name = "Cargo.lock";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
@ -56,10 +58,14 @@ flake-utils.lib.eachSystem [
|
||||||
];
|
];
|
||||||
|
|
||||||
nativeBuildInputs = [
|
nativeBuildInputs = [
|
||||||
rustToolchainToml
|
|
||||||
# for openssl/openssl-sys
|
# for openssl/openssl-sys
|
||||||
pkgs.pkg-config
|
pkgs.pkg-config
|
||||||
|
|
||||||
|
# default plugins
|
||||||
|
plugins.status-bar
|
||||||
|
plugins.tab-bar
|
||||||
|
plugins.strider
|
||||||
|
|
||||||
# generates manpages
|
# generates manpages
|
||||||
pkgs.mandown
|
pkgs.mandown
|
||||||
|
|
||||||
|
|
@ -67,7 +73,15 @@ flake-utils.lib.eachSystem [
|
||||||
pkgs.copyDesktopItems
|
pkgs.copyDesktopItems
|
||||||
];
|
];
|
||||||
|
|
||||||
|
pluginNativeBuildInputs = [
|
||||||
|
pkgs.pkg-config
|
||||||
|
# optimizes wasm binaries
|
||||||
|
pkgs.binaryen
|
||||||
|
];
|
||||||
|
|
||||||
devInputs = [
|
devInputs = [
|
||||||
|
rustToolchainToml
|
||||||
|
|
||||||
pkgs.cargo-make
|
pkgs.cargo-make
|
||||||
pkgs.rust-analyzer
|
pkgs.rust-analyzer
|
||||||
|
|
||||||
|
|
@ -83,6 +97,11 @@ flake-utils.lib.eachSystem [
|
||||||
pkgs.treefmt
|
pkgs.treefmt
|
||||||
];
|
];
|
||||||
|
|
||||||
|
plugins = import ./plugins.nix {
|
||||||
|
inherit root pkgs cargo rustc cargoLock buildInputs;
|
||||||
|
nativeBuildInputs = pluginNativeBuildInputs;
|
||||||
|
};
|
||||||
|
|
||||||
postInstall = ''
|
postInstall = ''
|
||||||
mandown ./docs/MANPAGE.md > ./zellij.1
|
mandown ./docs/MANPAGE.md > ./zellij.1
|
||||||
installManPage ./zellij.1
|
installManPage ./zellij.1
|
||||||
|
|
@ -99,6 +118,11 @@ flake-utils.lib.eachSystem [
|
||||||
|
|
||||||
copyDesktopItems
|
copyDesktopItems
|
||||||
'';
|
'';
|
||||||
|
patchPhase = ''
|
||||||
|
cp ${plugins.tab-bar}/bin/tab-bar.wasm assets/plugins/tab-bar.wasm
|
||||||
|
cp ${plugins.status-bar}/bin/status-bar.wasm assets/plugins/status-bar.wasm
|
||||||
|
cp ${plugins.strider}/bin/strider.wasm assets/plugins/strider.wasm
|
||||||
|
'';
|
||||||
|
|
||||||
desktopItems = [
|
desktopItems = [
|
||||||
(pkgs.makeDesktopItem {
|
(pkgs.makeDesktopItem {
|
||||||
|
|
@ -124,10 +148,11 @@ in rec {
|
||||||
inherit
|
inherit
|
||||||
name
|
name
|
||||||
src
|
src
|
||||||
nativeBuildInputs
|
|
||||||
crate2nix
|
crate2nix
|
||||||
|
nativeBuildInputs
|
||||||
desktopItems
|
desktopItems
|
||||||
postInstall
|
postInstall
|
||||||
|
patchPhase
|
||||||
meta
|
meta
|
||||||
;
|
;
|
||||||
};
|
};
|
||||||
|
|
@ -138,26 +163,20 @@ in rec {
|
||||||
src
|
src
|
||||||
name
|
name
|
||||||
cargoLock
|
cargoLock
|
||||||
buildInputs
|
|
||||||
nativeBuildInputs
|
nativeBuildInputs
|
||||||
|
buildInputs
|
||||||
postInstall
|
postInstall
|
||||||
|
patchPhase
|
||||||
desktopItems
|
desktopItems
|
||||||
meta
|
meta
|
||||||
;
|
;
|
||||||
};
|
};
|
||||||
# musl cross-compilation - static binary
|
packages.default = packages.zellij;
|
||||||
packages.zellij-musl = (pkgsMusl.makeRustPlatform {inherit rustc cargo;}).buildRustPackage {
|
|
||||||
inherit
|
packages.plugins-status-bar = plugins.status-bar;
|
||||||
src
|
packages.plugins-tab-bar = plugins.tab-bar;
|
||||||
name
|
packages.plugins-strider = plugins.strider;
|
||||||
cargoLock
|
|
||||||
postInstall
|
|
||||||
buildInputs
|
|
||||||
nativeBuildInputs
|
|
||||||
desktopItems
|
|
||||||
meta
|
|
||||||
;
|
|
||||||
};
|
|
||||||
defaultPackage = packages.zellij;
|
defaultPackage = packages.zellij;
|
||||||
|
|
||||||
# nix run
|
# nix run
|
||||||
|
|
|
||||||
53
nix/plugins.nix
Normal file
53
nix/plugins.nix
Normal file
|
|
@ -0,0 +1,53 @@
|
||||||
|
{
|
||||||
|
pkgs,
|
||||||
|
root,
|
||||||
|
cargo,
|
||||||
|
rustc,
|
||||||
|
cargoLock,
|
||||||
|
nativeBuildInputs,
|
||||||
|
buildInputs,
|
||||||
|
}: let
|
||||||
|
ignoreSource = [
|
||||||
|
".git"
|
||||||
|
".github"
|
||||||
|
"assets"
|
||||||
|
"docs"
|
||||||
|
"example"
|
||||||
|
"target"
|
||||||
|
".editorconfig"
|
||||||
|
".envrc"
|
||||||
|
".git-blame-ignore-revs"
|
||||||
|
"CHANGELOG.md"
|
||||||
|
"CODE_OF_CONDUCT.md"
|
||||||
|
"CONTRIBUTING.md"
|
||||||
|
"GOVERNANCE.md"
|
||||||
|
"LICENSE.md"
|
||||||
|
"docker-compose.yml"
|
||||||
|
];
|
||||||
|
src = pkgs.nix-gitignore.gitignoreSource ignoreSource root;
|
||||||
|
|
||||||
|
makeDefaultPlugin = name:
|
||||||
|
(pkgs.makeRustPlatform {inherit cargo rustc;}).buildRustPackage {
|
||||||
|
inherit
|
||||||
|
src
|
||||||
|
name
|
||||||
|
cargoLock
|
||||||
|
buildInputs
|
||||||
|
nativeBuildInputs
|
||||||
|
;
|
||||||
|
buildPhase = ''
|
||||||
|
cargo build --package ${name} --release --target=wasm32-wasi
|
||||||
|
mkdir -p $out/bin;
|
||||||
|
#cp target/wasm32-wasi/release/${name}.wasm $out/bin/${name}.wasm
|
||||||
|
wasm-opt \
|
||||||
|
-O target/wasm32-wasi/release/${name}.wasm \
|
||||||
|
-o $out/bin/${name}.wasm
|
||||||
|
'';
|
||||||
|
installPhase = ":";
|
||||||
|
checkPhase = ":";
|
||||||
|
};
|
||||||
|
in {
|
||||||
|
status-bar = makeDefaultPlugin "status-bar";
|
||||||
|
tab-bar = makeDefaultPlugin "tab-bar";
|
||||||
|
strider = makeDefaultPlugin "strider";
|
||||||
|
}
|
||||||
Loading…
Add table
Reference in a new issue