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
3 changes: 3 additions & 0 deletions .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,9 @@ insert_final_newline = true
indent_style = space
indent_size = 4

[*.nix]
indent_size = 2

[*.scd]
indent_style = tab
indent_size = 4
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
# required by nix
.direnv/
result/
/result

target/
.DS_Store
Expand Down
3 changes: 3 additions & 0 deletions .helix/languages.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
[[language]]
name = "nix"
formatter = { command = "alejandra" }
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ keywords = ["graphics", "terminal", "application"]
# Minimal stable rust version (MSRV)
rust-version = "1.90.0"
repository = "https://github.com/raphamorim/rio"
homepage = "https://raphamorim.io/rio"
homepage = "https://rioterm.com"
documentation = "https://github.com/raphamorim/rio#readme"
readme = "README.md"

Expand Down
39 changes: 12 additions & 27 deletions flake.lock

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

68 changes: 32 additions & 36 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -5,68 +5,64 @@
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
rust-overlay.url = "github:oxalica/rust-overlay";
systems = {
url = "github:nix-systems/default";
flake = false;
};
rust-overlay.inputs.nixpkgs.follows = "nixpkgs";
systems.url = "github:nix-systems/default";
};

outputs = inputs @ {flake-parts, ...}:
flake-parts.lib.mkFlake {inherit inputs;} {
imports = [];
imports = [flake-parts.flakeModules.easyOverlay];

systems = import inputs.systems;

perSystem = {
config,
self',
inputs',
pkgs,
system,
lib,
...
}: let
mkRio = import ./pkgRio.nix;

# Defines a devshell using the `rust-toolchain`, allowing for
# different versions of rust to be used.
mkDevShell = rust-toolchain: let
runtimeDeps = self'.packages.rio.runtimeDependencies;
tools = self'.packages.rio.nativeBuildInputs ++ self'.packages.rio.buildInputs ++ [rust-toolchain];
tools =
self'.packages.rio.nativeBuildInputs ++ self'.packages.rio.buildInputs ++ [rust-toolchain];
in
pkgs.mkShell {
packages =
[
# Derivations in `rust-toolchain` provide the toolchain,
# which must be listed first to take precedence over nightly.
rust-toolchain

# Use rustfmt, and other tools that require nightly features.
(pkgs.rust-bin.selectLatestNightlyWith (toolchain:
toolchain.minimal.override {
extensions = ["rustfmt" "rust-analyzer"];
}))
]
++ tools;
LD_LIBRARY_PATH = "${pkgs.lib.makeLibraryPath runtimeDeps}";
packages = [self'.formatter] ++ tools;
LD_LIBRARY_PATH = "${lib.makeLibraryPath runtimeDeps}";
};
toolchains = rec {
msrv = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml;
stable = pkgs.rust-bin.stable.latest.minimal;
nightly = pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.minimal);
rio = msrv;
default = rio;
};
in {
formatter = pkgs.alejandra;
_module.args.pkgs = import inputs.nixpkgs {
inherit system;
overlays = [(import inputs.rust-overlay)];
};

formatter = pkgs.alejandra;
packages.default = self'.packages.rio;
devShells.default = self'.devShells.msrv;

apps.default = {
type = "app";
program = self'.packages.default;
};
packages.rio = pkgs.callPackage mkRio {rust-toolchain = pkgs.rust-bin.stable.latest.minimal;};

devShells.msrv = mkDevShell (pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml);
devShells.stable = mkDevShell pkgs.rust-bin.stable.latest.minimal;
devShells.nightly = mkDevShell (pkgs.rust-bin.selectLatestNightlyWith (toolchain: toolchain.minimal));
# Create overlay to override `rio` with this flake's default
overlayAttrs = {inherit (self'.packages) rio;};
packages =
lib.mapAttrs' (
k: v: {
name =
if builtins.elem k ["rio" "default"]
then k
else "rio-${k}";
value = pkgs.callPackage ./pkgRio.nix {rust-toolchain = v;};
}
)
toolchains;
# Different devshells for different rust versions
devShells = lib.mapAttrs (_: v: mkDevShell v) toolchains;
};
};
}
131 changes: 74 additions & 57 deletions pkgRio.nix
Original file line number Diff line number Diff line change
@@ -1,103 +1,120 @@
{
# rust-overlay deps
rust-toolchain,
makeRustPlatform,
stdenv,
# Normal deps
lib,
fontconfig,
stdenv,
darwin,
autoPatchelfHook,
cmake,
ncurses,
pkg-config,
gcc-unwrapped,
fontconfig,
libGL,
libxkbcommon,
vulkan-loader,
libxkbcommon,
withX11 ? !stdenv.isDarwin,
libX11,
libXcursor,
libXi,
libXrandr,
libxcb,
wayland,
ncurses,
pkg-config,
cmake,
autoPatchelfHook,
withX11 ? !stdenv.isDarwin,
withWayland ? !stdenv.isDarwin,
wayland,
...
}: let
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
readTOML = f: builtins.fromTOML (builtins.readFile f);
cargoToml = readTOML ./Cargo.toml;
rioToml = readTOML ./frontends/rioterm/Cargo.toml;
rustPlatform = makeRustPlatform {
cargo = rust-toolchain;
rustc = rust-toolchain;
};
rlinkLibs =
if stdenv.isDarwin
then [
darwin.libobjc
darwin.apple_sdk_11_0.frameworks.AppKit
darwin.apple_sdk_11_0.frameworks.AVFoundation
darwin.apple_sdk_11_0.frameworks.MetalKit
darwin.apple_sdk_11_0.frameworks.Vision
lib.optionals stdenv.isLinux [
(lib.getLib gcc-unwrapped)
fontconfig
libGL
libxkbcommon
vulkan-loader
]
else
[
(lib.getLib gcc-unwrapped)
fontconfig
libGL
libxkbcommon
vulkan-loader
]
++ lib.optionals withX11 [
libX11
libXcursor
libXi
libXrandr
libxcb
]
++ lib.optionals withWayland [
wayland
];
++ lib.optionals withX11 [
libX11
libXcursor
libXi
libXrandr
libxcb
]
++ lib.optionals withWayland [
wayland
];

inherit (lib.fileset) unions toSource;
in
rustPlatform.buildRustPackage {
inherit (cargoToml.workspace.package) version;
name = "rio";
src = ./.;
src = toSource {
root = ./.;
fileset = unions ([
./Cargo.lock
./Cargo.toml
./misc # Extra desktop/terminfo files
]
++ (map (x: ./. + "/${x}") cargoToml.workspace.members));
};
cargoLock.lockFile = ./Cargo.lock;

cargoBuildFlags = "-p rioterm";

buildInputs = rlinkLibs;
buildInputs = rlinkLibs ++ (lib.optionals stdenv.isDarwin [darwin.libutil]);
runtimeDependencies = rlinkLibs;

nativeBuildInputs =
[
rustPlatform.bindgenHook
ncurses
]
++ lib.optionals stdenv.isLinux [
pkg-config
cmake
pkg-config
autoPatchelfHook
];

postInstall = ''
install -D -m 644 misc/rio.desktop -t $out/share/applications
install -D -m 644 misc/logo.svg \
$out/share/icons/hicolor/scalable/apps/rio.svg

# Install terminfo files
install -dm 755 "$out/share/terminfo/r/"
tic -xe xterm-rio,rio,rio-direct -o "$out/share/terminfo" misc/rio.terminfo
'' + lib.optionalString stdenv.hostPlatform.isDarwin ''
mkdir $out/Applications/
mv misc/osx/Rio.app/ $out/Applications/
mkdir $out/Applications/Rio.app/Contents/MacOS/
ln -s $out/bin/rio $out/Applications/Rio.app/Contents/MacOS/
'';


outputs = [
"out"
"terminfo"
];

postInstall =
''
install -D -m 644 misc/rio.desktop -t \
$out/share/applications
install -D -m 644 misc/logo.svg \
$out/share/icons/hicolor/scalable/apps/rio.svg

# Install terminfo files
install -dm 755 "$terminfo/share/terminfo/r/"
tic -xe xterm-rio,rio,rio-direct -o "$terminfo/share/terminfo" misc/rio.terminfo
mkdir -p $out/nix-support
echo "$terminfo" >> $out/nix-support/propagated-user-env-packages
''
+ lib.optionalString stdenv.hostPlatform.isDarwin ''
mkdir $out/Applications/
mv misc/osx/Rio.app/ $out/Applications/
mkdir $out/Applications/Rio.app/Contents/MacOS/
ln -s $out/bin/rio $out/Applications/Rio.app/Contents/MacOS/
'';

buildNoDefaultFeatures = true;
buildFeatures = ["x11" "wayland"];
buildFeatures = (lib.optionals withX11 ["x11"]) ++ (lib.optionals withWayland ["wayland"]);
checkType = "debug";
meta = {
description = "A hardware-accelerated GPU terminal emulator focusing to run in desktops and browsers";
homepage = "https://rioterm.com";
description = rioToml.package.description;
longDescription = rioToml.package.extended-description;
homepage = cargoToml.workspace.package.homepage;
license = lib.licenses.mit;
platforms = lib.platforms.unix;
changelog = "https://github.com/raphamorim/rio/blob/master/CHANGELOG.md";
Expand Down
Loading