From 5d5a66a5d31ad7708b1d998228f2230febeba4b5 Mon Sep 17 00:00:00 2001 From: Asperatus Date: Sat, 22 Apr 2023 09:33:15 -0400 Subject: [PATCH 1/3] xdg-ninja: allow custom programs/ dir via XN_PROGRAMS_DIR In order to foresee the work on the unified packaging process, the programs/ directory (which should be located in /usr/share/xdg-ninja or /usr/local/share/xdg-ninja) is automatically found depending on where the xdg-ninja executable is located. This also allows for backwards compatibility as when the xdg-ninja script is located in a working directory (not in a bin/), xdg-ninja automatically picks the programs/ folder in the current working directory, just like previously. If the directory fails to find the programs/ dir, the user can override the variable XN_PROGRAMS_DIR through environment variables. This change is to prevent people from packaging xdg-ninja with the programs/ directory within /usr(/local)/bin or by modifying the script in place. --- README.md | 2 +- xdg-ninja.sh | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index d650c1fa..4e132016 100644 --- a/README.md +++ b/README.md @@ -43,7 +43,7 @@ To install xdg-ninja with [Homebrew](https://brew.sh), run `brew install xdg-nin ## Configuration -The configuration is done in the _programs/_ directory. +The configuration is done in the _programs/_ directory, which should be located in the same working directory as the xdg-ninja.sh script. This can be overriden with the `XN_PROGRAMS_DIR` environment variable. You define a program, and then a list of files and directories which this program ruthlessly puts into your _$HOME_ directory. diff --git a/xdg-ninja.sh b/xdg-ninja.sh index 8a0ff98c..8780de7a 100755 --- a/xdg-ninja.sh +++ b/xdg-ninja.sh @@ -218,7 +218,7 @@ do_check_programs() { " read -r name; read -r filename; read -r movable; read -r help; do check_file "$name" "$filename" "$movable" "$help" done < Date: Sat, 22 Apr 2023 09:46:07 -0400 Subject: [PATCH 2/3] Makefile: add basic make install/uninstall commands As to unify packaging process, the following changes adds install and uninstall commands of xdg-ninja to the system. --- Makefile | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 Makefile diff --git a/Makefile b/Makefile new file mode 100644 index 00000000..bde91740 --- /dev/null +++ b/Makefile @@ -0,0 +1,18 @@ +PREFIX ?= /usr/local + +all: + @echo "Usage: make (install|uninstall)" + +.PHONY: all install uninstall + +install: + install -Dm 0755 xdg-ninja.sh $(DESTDIR)$(PREFIX)/bin/xdg-ninja + install -d $(DESTDIR)$(PREFIX)/share/xdg-ninja/ + cp -r programs $(DESTDIR)$(PREFIX)/share/xdg-ninja/ + install -d $(DESTDIR)$(PREFIX)/share/doc/xdg-ninja/ + install -m 0644 LICENSE README.md $(DESTDIR)$(PREFIX)/share/doc/xdg-ninja/ + +uninstall: + rm -rf $(DESTDIR)$(PREFIX)/bin/xdg-ninja \ + $(DESTDIR)$(PREFIX)/share/xdg-ninja \ + $(DESTDIR)$(PREFIX)/share/doc/xdg-ninja From 3a7e2674e7f2fe1a33ad32db43b5a053f5332381 Mon Sep 17 00:00:00 2001 From: b3nj5m1n Date: Sun, 23 Apr 2023 08:00:13 +0200 Subject: [PATCH 3/3] Update flake --- flake.nix | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/flake.nix b/flake.nix index 91adf012..8f3a5bfc 100644 --- a/flake.nix +++ b/flake.nix @@ -26,7 +26,25 @@ in rec { packages = flake-utils.lib.flattenTree { # The shell script and configurations, uses derivation from offical nixpkgs - xdg-ninja = pkgs.xdg-ninja; + xdg-ninja = pkgs.stdenv.mkDerivation rec { + pname = "xdg-ninja"; + version = "0.1.0"; + + src = ./.; + + nativeBuildInputs = with pkgs; [ makeWrapper ]; + + installPhase = '' + runHook preInstall + + DESTDIR="$out" PREFIX="/usr" make install + + wrapProgram "$out/usr/bin/xdg-ninja" \ + --prefix PATH : "${pkgs.lib.makeBinPath [ pkgs.glow pkgs.jq ]}" + + runHook postInstall + ''; + }; # Pre-built binary of xdgnj tool downloaded from github xdgnj-bin = pkgs.stdenvNoCC.mkDerivation { name = "xdgnj-bin"; @@ -45,7 +63,7 @@ }; defaultPackage = packages.xdg-ninja; apps = { - xdg-ninja = flake-utils.lib.mkApp { drv = packages.xdg-ninja; }; + xdg-ninja = flake-utils.lib.mkApp { drv = packages.xdg-ninja; exePath = "/usr/bin/xdg-ninja"; }; xdgnj-bin = flake-utils.lib.mkApp { drv = packages.xdgnj-bin; exePath = "/bin/xdgnj"; }; }; defaultApp = apps.xdg-ninja;