1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143
|
{
description = "doxx - Expose the contents of .docx files without leaving your terminal";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
rust-overlay = {
url = "github:oxalica/rust-overlay";
inputs.nixpkgs.follows = "nixpkgs";
};
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, nixpkgs, rust-overlay, flake-utils }:
flake-utils.lib.eachDefaultSystem (system:
let
overlays = [ (import rust-overlay) ];
pkgs = import nixpkgs {
inherit system overlays;
};
# Use the latest stable Rust toolchain
rustToolchain = pkgs.rust-bin.stable.latest.default.override {
extensions = [ "rust-src" "clippy" "rustfmt" ];
};
# Define the package
doxx = pkgs.rustPlatform.buildRustPackage rec {
pname = "doxx";
version = "0.1.2";
src = ./.;
cargoLock = {
lockFile = ./Cargo.lock;
};
doCheck = true;
checkFlags = [
# FIXME: Fails for some reason
"--skip=terminal_image::tests::test_renderer_creation"
];
meta = with pkgs.lib; {
description = "Expose the contents of .docx files without leaving your terminal. Fast, safe, and smart — no Office required!";
homepage = "https://github.com/bgreenwell/doxx";
license = licenses.mit;
maintainers = [ ];
platforms = platforms.all;
};
};
in
{
# Default package
packages.default = doxx;
packages.doxx = doxx;
# Development shell
devShells.default = pkgs.mkShell {
buildInputs = with pkgs; [
# Rust toolchain
rustToolchain
# Development tools
cargo-watch
cargo-edit
cargo-audit
cargo-deny
cargo-outdated
cargo-expand # For macro expansion debugging
# Additional development tools
git
# LSP and formatting tools
rust-analyzer
# For testing .docx files and document creation
pandoc
# Debugging tools
gdb
];
# For better terminal support
TERM = "xterm-256color";
# Development shell hook
shellHook = ''
echo "❄️ Welcome to the doxx Nix development environment!"
echo ""
echo "📋 Dependencies loaded:"
echo " - Rust ${rustToolchain.version} with clippy, rustfmt, rust-src"
echo " - ratatui for terminal UI"
echo " - crossterm for cross-platform terminal"
echo " - arboard for clipboard support"
echo " - docx-rs for document parsing"
echo ""
echo "❄️ Nix commands:"
echo " nix build - Build the project"
echo " nix run - Run doxx"
echo " nix run . -- --help - Run with help flag"
echo " nix develop - Enter this dev shell"
echo " nix flake check - Run all checks (fmt, clippy, build)"
echo ""
echo "📄 Usage examples:"
echo " nix run . -- document.docx"
echo " nix run . -- document.docx --outline"
echo " nix run . -- document.docx --search 'keyword'"
echo " nix run . -- document.docx --export csv"
echo ""
echo "🔧 Development commands (if you need them):"
echo " cargo build - Direct build (uses Nix env)"
echo " cargo watch -x run - Live reload during development"
echo " cargo clippy - Run linter"
echo " cargo fmt - Format code"
echo ""
echo "💡 Pro tip: 'nix run github:bgreenwell/doxx -- file.docx' to run from anywhere!"
echo ""
'';
};
# Apps for easy running
apps.default = {
type = "app";
program = "${doxx}/bin/doxx";
};
# Checks
checks = {
build = doxx;
# Add format check
fmt-check = pkgs.runCommand "fmt-check" {
buildInputs = [ rustToolchain ];
} ''
cd ${self}
cargo fmt --all -- --check
touch $out
'';
};
});
}
|