mirror of
https://github.com/zellij-org/zellij.git
synced 2024-12-23 09:11:40 +03:00
init: nix support (#1131)
* init(nix): initial nix support * nix(compat): add flake-compat * remove `macro expansion` * remove `extraEntries` from `makeDesktopItem` * fix Categories * add darwin compatibilty
This commit is contained in:
parent
cecc3ea988
commit
49396fab21
7
.gitignore
vendored
7
.gitignore
vendored
@ -2,5 +2,10 @@ target/
|
||||
*.new
|
||||
.vscode
|
||||
.vim
|
||||
.DS_Store
|
||||
.DS_Store
|
||||
/assets/man/zellij.1
|
||||
|
||||
# nix
|
||||
.direnv/
|
||||
.result/
|
||||
./result
|
||||
|
13
default.nix
Normal file
13
default.nix
Normal file
@ -0,0 +1,13 @@
|
||||
(import
|
||||
(
|
||||
let
|
||||
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
|
||||
in
|
||||
fetchTarball {
|
||||
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
|
||||
sha256 = lock.nodes.flake-compat.locked.narHash;
|
||||
}
|
||||
)
|
||||
{
|
||||
src = ./.;
|
||||
}).defaultNix
|
84
flake.lock
Normal file
84
flake.lock
Normal file
@ -0,0 +1,84 @@
|
||||
{
|
||||
"nodes": {
|
||||
"flake-compat": {
|
||||
"flake": false,
|
||||
"locked": {
|
||||
"lastModified": 1641205782,
|
||||
"narHash": "sha256-4jY7RCWUoZ9cKD8co0/4tFARpWB+57+r1bLLvXNJliY=",
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"rev": "b7547d3eed6f32d06102ead8991ec52ab0a4f1a7",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "edolstra",
|
||||
"repo": "flake-compat",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"flake-utils": {
|
||||
"locked": {
|
||||
"lastModified": 1644229661,
|
||||
"narHash": "sha256-1YdnJAsNy69bpcjuoKdOYQX0YxZBiCYZo4Twxerqv7k=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "3cecb5b042f7f209c56ffd8371b2711a290ec797",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1645433236,
|
||||
"narHash": "sha256-4va4MvJ076XyPp5h8sm5eMQvCrJ6yZAbBmyw95dGyw4=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "7f9b6e2babf232412682c09e57ed666d8f84ac2d",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nixos",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-compat": "flake-compat",
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"rust-overlay": "rust-overlay"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"flake-utils": [
|
||||
"flake-utils"
|
||||
],
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1645841894,
|
||||
"narHash": "sha256-xNeqVlZEmg/QlhQLY5SfVa73x6IUfET+tHCJP3w067U=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "7f273929e83a196f96a0dbee9ea565952e340bd6",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
132
flake.nix
Normal file
132
flake.nix
Normal file
@ -0,0 +1,132 @@
|
||||
{
|
||||
description = "Zellij, a terminal workspace with batteries included";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
flake-utils.inputs.nixpkgs.follows = "nixpkgs";
|
||||
rust-overlay.url = "github:oxalica/rust-overlay";
|
||||
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
|
||||
rust-overlay.inputs.flake-utils.follows = "flake-utils";
|
||||
flake-compat.url = "github:edolstra/flake-compat";
|
||||
flake-compat.flake = false;
|
||||
};
|
||||
|
||||
outputs = { self, rust-overlay, nixpkgs, flake-utils, flake-compat }:
|
||||
flake-utils.lib.eachSystem [
|
||||
"aarch64-linux"
|
||||
"aarch64-darwin"
|
||||
"i686-linux"
|
||||
"x86_64-darwin"
|
||||
"x86_64-linux"
|
||||
] (system:
|
||||
let
|
||||
overlays = [ (import rust-overlay) ];
|
||||
|
||||
pkgs = import nixpkgs { inherit system overlays; };
|
||||
|
||||
name = "zellij";
|
||||
pname = name;
|
||||
root = toString ./.;
|
||||
|
||||
ignoreSource = [ ".git" "target" ];
|
||||
|
||||
src = pkgs.nix-gitignore.gitignoreSource ignoreSource root;
|
||||
|
||||
rustToolchainToml =
|
||||
pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain;
|
||||
cargoLock = { lockFile = ./Cargo.lock; };
|
||||
cargo = rustToolchainToml;
|
||||
rustc = rustToolchainToml;
|
||||
|
||||
#env
|
||||
RUST_BACKTRACE = 1;
|
||||
|
||||
buildInputs = [
|
||||
rustToolchainToml
|
||||
|
||||
# in order to run tests
|
||||
pkgs.openssl
|
||||
];
|
||||
|
||||
nativeBuildInputs = [
|
||||
pkgs.installShellFiles
|
||||
pkgs.copyDesktopItems
|
||||
|
||||
# for openssl/openssl-sys
|
||||
pkgs.pkg-config
|
||||
] ++ pkgs.lib.optionals pkgs.stdenv.isDarwin [
|
||||
pkgs.libiconv
|
||||
pkgs.Foundation
|
||||
];
|
||||
|
||||
devInputs = [
|
||||
pkgs.cargo-make
|
||||
pkgs.rust-analyzer
|
||||
pkgs.nixpkgs-fmt
|
||||
# generates manpages
|
||||
pkgs.mandown
|
||||
# optimizes wasm binaries
|
||||
pkgs.binaryen
|
||||
];
|
||||
|
||||
in rec {
|
||||
|
||||
packages.zellij =
|
||||
(pkgs.makeRustPlatform { inherit cargo rustc; }).buildRustPackage {
|
||||
inherit src name cargoLock buildInputs nativeBuildInputs;
|
||||
|
||||
preCheck = ''
|
||||
HOME=$TMPDIR
|
||||
'';
|
||||
|
||||
postInstall = ''
|
||||
|
||||
# explicit behavior
|
||||
$out/bin/zellij setup --generate-completion bash > ./completions.bash
|
||||
installShellCompletion --bash --name ${pname}.bash ./completions.bash
|
||||
$out/bin/zellij setup --generate-completion fish > ./completions.fish
|
||||
installShellCompletion --fish --name ${pname}.fish ./completions.fish
|
||||
$out/bin/zellij setup --generate-completion zsh > ./completions.zsh
|
||||
installShellCompletion --zsh --name _${pname} ./completions.zsh
|
||||
|
||||
install -Dm644 ./assets/logo.png $out/share/icons/hicolor/scalable/apps/zellij.png
|
||||
|
||||
copyDesktopItems
|
||||
'';
|
||||
|
||||
desktopItems = [
|
||||
(pkgs.makeDesktopItem {
|
||||
type = "Application";
|
||||
inherit name;
|
||||
desktopName = "zellij";
|
||||
terminal = true;
|
||||
genericName = "Terminal multiplexer";
|
||||
comment = "Manage your terminal applications";
|
||||
exec = "zellij";
|
||||
icon = "zellij";
|
||||
categories = [ "ConsoleOnly;System" ];
|
||||
})
|
||||
];
|
||||
|
||||
meta = with pkgs.lib; {
|
||||
homepage = "https://github.com/zellij-org/zellij/";
|
||||
description = "A terminal workspace with batteries included";
|
||||
license = [ licenses.mit ];
|
||||
};
|
||||
};
|
||||
|
||||
defaultPackage = packages.zellij;
|
||||
|
||||
# nix run
|
||||
apps.zellij = flake-utils.lib.mkApp { drv = packages.zellij; };
|
||||
defaultApp = apps.zellij;
|
||||
|
||||
devShell = pkgs.mkShell {
|
||||
name = "zellij-dev";
|
||||
inherit buildInputs RUST_BACKTRACE;
|
||||
nativeBuildInputs = nativeBuildInputs ++ devInputs;
|
||||
};
|
||||
|
||||
});
|
||||
}
|
13
shell.nix
Normal file
13
shell.nix
Normal file
@ -0,0 +1,13 @@
|
||||
(import
|
||||
(
|
||||
let
|
||||
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
|
||||
in
|
||||
fetchTarball {
|
||||
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
|
||||
sha256 = lock.nodes.flake-compat.locked.narHash;
|
||||
}
|
||||
)
|
||||
{
|
||||
src = ./.;
|
||||
}).shellNix
|
Loading…
Reference in New Issue
Block a user