]> glassweightruler.freedombox.rocks Git - xdg-ninja.git/commitdiff
Merge pull request #252 from fourchettes/unified_packaging_process
authorb3nj5m1n <47924309+b3nj5m1n@users.noreply.github.com>
Sun, 23 Apr 2023 16:18:41 +0000 (18:18 +0200)
committerGitHub <noreply@github.com>
Sun, 23 Apr 2023 16:18:41 +0000 (18:18 +0200)
Makefile [new file with mode: 0644]
README.md
flake.nix
xdg-ninja.sh

diff --git a/Makefile b/Makefile
new file mode 100644 (file)
index 0000000..bde9174
--- /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
index d650c1faac70f85e1a8b994b0e07c1210cdc4242..4e132016b884306eb58341bac3f52aebc5ef2ec0 100644 (file)
--- 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.
 
index 91adf012dd5edefabe99512a2dee9197932df998..8f3a5bfc2d03554273839c201236510173a28de8 100644 (file)
--- a/flake.nix
+++ b/flake.nix
       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;
index 8a0ff98ca6c48af2a5c02d4de6cb34cc0fbfe9b1..8780de7a2e26f4880ac30e4d15749b7e3a2f4c43 100755 (executable)
@@ -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 <<EOF
-$(jq 'inputs as $input | $input.files[] as $file | $input.name, $file.path, $file.movable, $file.help' "$(realpath "$0" | xargs dirname)"/programs/* | sed -e 's/^"//' -e 's/"$//')
+$(jq 'inputs as $input | $input.files[] as $file | $input.name, $file.path, $file.movable, $file.help' "$XN_PROGRAMS_DIR"/* | sed -e 's/^"//' -e 's/"$//')
 EOF
 # sed is to trim quotes
 }
@@ -233,6 +233,9 @@ check_programs() {
     printf "\n"
 }
 
+[ "$XN_PROGRAMS_DIR" ] ||
+    XN_PROGRAMS_DIR="$(realpath "$0" | xargs dirname | sed 's:/bin$:/share/xdg-ninja:g')/programs"
+
 check_programs
 if [ $FIXABLE -gt 100 ]; then
     exit 101