Skip to content

Commit

Permalink
feat: WIP pacakge with Nix
Browse files Browse the repository at this point in the history
  • Loading branch information
gabyx committed Jun 27, 2024
1 parent 97786b4 commit 9a3b0e8
Show file tree
Hide file tree
Showing 2 changed files with 71 additions and 1 deletion.
18 changes: 17 additions & 1 deletion tools/nix/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,14 @@
flake-utils.follows = "flake-utils";
};
};

# The library to build the rust package.
crane = {
url = "https://github.com/ipetkov/crane";
inputs = {
nixpkgs.follows = "nixpkgs";
};
};
};

outputs = {
Expand All @@ -42,8 +50,11 @@
nixpkgsStable,
flake-utils,
rust-overlay,
crane,
...
} @ inputs:
} @ inputs: let
rootDir = "./" + "../../";
in
flake-utils.lib.eachDefaultSystem
# Creates an attribute map `{ devShells.<system>.default = ...}`
# by calling this function:
Expand Down Expand Up @@ -93,6 +104,11 @@
};

packages = {
rdf-protect = (import pkgs/rdf-protect) {
inherit crane;
inherit rootDir;
};

images = {
ci = (import ./images/ci.nix) {
inherit pkgs;
Expand Down
54 changes: 54 additions & 0 deletions tools/nix/pkgs/rdf-protect.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
{pkgs, lib, rustPlatform, rootDir}:
rustPlatform.buildRustPackage rec {
inherit buildInputs nativeBuildInputs;

name = "rdf-protect";
src = rootDir;
version = "1.0.0";

cargoLock = {
lockFile = "${rootDir}/Cargo.lock";
allowBuiltinFetchGit = true;
};

preConfigure = ''
'';

postPatch = ''
'';

preFixup = lib.optionalString stdenv.isLinux ''
patchelf \
--add-needed "${pkgs.libGL}/lib/libEGL.so.1" \
--add-needed "${pkgs.vulkan-loader}/lib/libvulkan.so.1" \
$out/bin/wezterm-gui
'';

postInstall = ''
mkdir -p $out/nix-support
echo "${passthru.terminfo}" >> $out/nix-support/propagated-user-env-packages
install -Dm644 assets/icon/terminal.png $out/share/icons/hicolor/128x128/apps/org.wezfurlong.wezterm.png
install -Dm644 assets/wezterm.desktop $out/share/applications/org.wezfurlong.wezterm.desktop
install -Dm644 assets/wezterm.appdata.xml $out/share/metainfo/org.wezfurlong.wezterm.appdata.xml
install -Dm644 assets/shell-integration/wezterm.sh -t $out/etc/profile.d
installShellCompletion --cmd wezterm \
--bash assets/shell-completion/bash \
--fish assets/shell-completion/fish \
--zsh assets/shell-completion/zsh
install -Dm644 assets/wezterm-nautilus.py -t $out/share/nautilus-python/extensions
'';

passthru = {
terminfo =
pkgs.runCommand "wezterm-terminfo"
{
nativeBuildInputs = [pkgs.ncurses];
} ''
mkdir -p $out/share/terminfo $out/nix-support
tic -x -o $out/share/terminfo ${src}/termwiz/data/wezterm.terminfo
'';
};
};

0 comments on commit 9a3b0e8

Please sign in to comment.