From 9a3b0e8d6fe26ae6631512afa88247abc93205f8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gabriel=20N=C3=BCtzi?= Date: Thu, 27 Jun 2024 07:28:39 +0200 Subject: [PATCH] feat: WIP pacakge with Nix --- tools/nix/flake.nix | 18 +++++++++++- tools/nix/pkgs/rdf-protect.nix | 54 ++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+), 1 deletion(-) create mode 100644 tools/nix/pkgs/rdf-protect.nix diff --git a/tools/nix/flake.nix b/tools/nix/flake.nix index c8158e8..cab80f2 100644 --- a/tools/nix/flake.nix +++ b/tools/nix/flake.nix @@ -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 = { @@ -42,8 +50,11 @@ nixpkgsStable, flake-utils, rust-overlay, + crane, ... - } @ inputs: + } @ inputs: let + rootDir = "./" + "../../"; + in flake-utils.lib.eachDefaultSystem # Creates an attribute map `{ devShells..default = ...}` # by calling this function: @@ -93,6 +104,11 @@ }; packages = { + rdf-protect = (import pkgs/rdf-protect) { + inherit crane; + inherit rootDir; + }; + images = { ci = (import ./images/ci.nix) { inherit pkgs; diff --git a/tools/nix/pkgs/rdf-protect.nix b/tools/nix/pkgs/rdf-protect.nix new file mode 100644 index 0000000..6e5ca2a --- /dev/null +++ b/tools/nix/pkgs/rdf-protect.nix @@ -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 + ''; + }; + };