From 2d46def90dfcece08700bbbfac3f282eaf185aa5 Mon Sep 17 00:00:00 2001 From: "O. El Hosami" Date: Thu, 29 May 2025 16:20:01 +0200 Subject: [PATCH] feat: Add make install support and nix build - Add install/uninstall targets to Makefile with configurable paths - Update flake.nix to use make install in derivation - Configure proper installation directories in nix build - Use stdenvNoCC for LaTeX-only package - Add meta information for nix package The changes allow installing the package both via make and nix build, while maintaining consistent paths and permissions. --- .gitignore | 1 + Makefile | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ flake.nix | 30 ++++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+) diff --git a/.gitignore b/.gitignore index 21b2fed..8e3aae1 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ /.direnv /outputs +/result ### TeX ### ## Core latex/pdflatex auxiliary files: diff --git a/Makefile b/Makefile index e5066e6..7745a3b 100644 --- a/Makefile +++ b/Makefile @@ -12,6 +12,12 @@ FORCE ?= 0 LANG ?= C.UTF-8 XETEX ?= xelatex +### Installation paths +PREFIX ?= usr/local +DOCDIR ?= share/doc/awesome-cv +EXAMPLEDIR ?= $(addsuffix /examples,$(DOCDIR)) +DESTDIR ?= $(PREFIX)/ + ## Commandline overridable (internal) variables src = $(SRC) @@ -41,6 +47,10 @@ $(resume_deps) \ $(cv_deps) \ )) +install_dest_dir = $(DESTDIR) +install_doc_dir = $(install_dest_dir)$(DOCDIR) +install_example_dir = $(install_dest_dir)$(EXAMPLEDIR) + force = ifneq ($(strip $(filter-out 0,$(FORCE))),) force = .force_non_existing @@ -54,6 +64,9 @@ endif ## Resolve lazy variables force := $(force) silent := $(silent) +install_dest_dir := $(install_dest_dir) +install_doc_dir := $(install_doc_dir) +install_example_dir := $(install_example_dir) src := $(src) out := $(out) out_dirs := $(out_dirs) @@ -118,3 +131,42 @@ clean: println-%: @printf -- '%s\n' "$*" 1>&2 @printf -- '%s\n' $(foreach v,$($*),"$(v)") + +.PHONY: install +install: all + $(silent)install -d "$(install_doc_dir)" + $(silent)install -d "$(install_example_dir)" + $(silent)install -m 644 $(out)/examples/*.pdf "$(install_example_dir)/" + $(silent)install -m 644 README.md "$(install_doc_dir)/" + $(silent)install -m 644 awesome-cv.cls "$(install_doc_dir)/" + +.PHONY: uninstall +uninstall: + $(silent)rm -rf "$(install_doc_dir)" "$(install_example_dir)" + +.PHONY: help +help: + @{ \ + echo "Usage: make [target] [VARIABLE=value]"; \ + echo "Available targets:"; \ + echo " all - Build all examples (default)"; \ + echo " pdf - Build PDF files"; \ + echo " examples - Build all example PDFs"; \ + echo " clean - Clean output directory"; \ + echo " install - Install the documentation and examples"; \ + echo " uninstall - Uninstall the documentation and examples"; \ + echo " help - Show this help message"; \ + echo ""; \ + echo "Overridable variables:"; \ + echo " OUT - Output directory (default: outputs)"; \ + echo " SRC - Source directory (default: current directory)"; \ + echo " VERBOSE - Verbosity level (0 for silent, default: 1)"; \ + echo " FORCE - Force rebuild (0 for no, default: 0)"; \ + echo " LANG - Language setting for LaTeX (default: C.UTF-8)"; \ + echo " XETEX - LaTeX engine to use (default: xelatex)"; \ + echo ""; \ + echo "Example usage:"; \ + echo " make pdf OUT=outputs SRC=src VERBOSE=1 FORCE=1"; \ + echo " make install DESTDIR=/usr/local"; \ + echo " make uninstall DESTDIR=/usr/local"; \ + } diff --git a/flake.nix b/flake.nix index f1c38ea..b6c0b81 100644 --- a/flake.nix +++ b/flake.nix @@ -14,6 +14,7 @@ flake-utils.lib.eachDefaultSystem (system: let pkgs = import nixpkgs { inherit system; }; + pname = "awesome-cv"; tex = pkgs.texlive.combine { inherit (pkgs.texlive.pkgs) @@ -88,6 +89,35 @@ devShells.default = pkgs.mkShellNoCC { inherit buildInputs nativeBuildInputs FONTCONFIG_FILE; }; + + packages.default = pkgs.stdenvNoCC.mkDerivation { + inherit pname; + version = "1.0.0"; + inherit src nativeBuildInputs buildInputs FONTCONFIG_FILE; + + buildPhase = '' + make all OUT=$out/build SRC=$src VERBOSE=1 + ''; + + installPhase = '' + make install \ + DESTDIR=$out \ + PREFIX="" \ + DOCDIR="share/doc/${pname}" \ + EXAMPLEDIR="share/doc/${pname}/examples" \ + OUT=$out/build \ + SRC=$src \ + VERBOSE=1 + ''; + + meta = with pkgs.lib; { + description = "Awesome LaTeX CV and resume class"; + homepage = "https://github.com/posquit0/Awesome-CV"; + license = licenses.lppl13c; + platforms = platforms.all; + maintainers = []; + }; + }; } ); }