Subject: [PATCH] gnu: Add ncdu-ng.
From: phodina <[email-masked]>
To: Guix Patches <[email-masked]>
Date: Thu, 27 Jan 2022 14:22:58 +0000
List-Id: <debbugs-submit.debbugs.gnu.org>

Hello,

here is a patch for the ncdu. As version 2.0.* are based on Zig I decided to create a new variable instead of updating the old one.

FIY this is my first encounter with Zig and I just briefly swept through the documentation and I don't know if cross-compilation won't be an issue since the previous versions are just plain C.

If you think there is no need to do this and we can just simply update let me know and I'll send updated patch.

----
Petr

From 3e6ad4ef4f928314bd69cae18a05be317e1b26ab Mon Sep 17 00:00:00 2001
From: Petr Hodina <[email-masked]>
Date: Thu, 27 Jan 2022 14:56:39 +0100
Subject: [PATCH] gnu: Add ncdu-ng.

* gnu/packages/ncdu.scm (ncdu-ng): New variable.

diff --git a/gnu/packages/ncdu.scm b/gnu/packages/ncdu.scm
index d6e4522bf0..01084976f0 100644
--- a/gnu/packages/ncdu.scm
+++ b/gnu/packages/ncdu.scm
@@ -1,6 +1,7 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2014 John Darrington <[email-masked]>
 ;;; Copyright © 2018–2021 Tobias Geerinckx-Rice <[email-masked]>
+;;; Copyright © 2022 Petr Hodina <[email-masked]>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -20,8 +21,10 @@
 (define-module (gnu packages ncdu)
   #:use-module (gnu packages)
   #:use-module (gnu packages ncurses)
+  #:use-module (gnu packages zig)
   #:use-module (guix licenses)
   #:use-module (guix packages)
+  #:use-module (guix utils)
   #:use-module (guix download)
   #:use-module (guix build-system gnu))
 
@@ -49,3 +52,32 @@ (define-public ncdu
               (string-append "https://g.blicky.net/ncdu.git/plain/COPYING?id=v"
                              version)))
     (home-page "https://dev.yorhel.nl/ncdu")))
+
+(define-public ncdu-ng
+  (package
+    (inherit ncdu)
+    (name "ncdu-ng")
+    (version "2.0.1")
+    (source (origin
+              (method url-fetch)
+              (uri (string-append "https://dev.yorhel.nl/download/ncdu-"
+                                  version ".tar.gz"))
+              (sha256
+               (base32
+                "0j3w8xixz1zkzcpk0xrh6y3r7sii3h3y31lbvs5iqc5q7q6day9g"))))
+    (arguments
+     `(#:tests? #f
+       #:make-flags
+       (list (string-append "PREFIX="
+                            (assoc-ref %outputs "out"))
+             ,(string-append "CC="
+                             (cc-for-target)))
+       #:phases
+       (modify-phases %standard-phases
+         (add-after 'unpack 'set-home-dir
+           (lambda* _
+             ;; Zig caches build
+             (setenv "HOME" "/tmp")))
+         (delete 'configure))))
+    (native-inputs (list zig))
+    (inputs (list ncurses))))
-- 
2.34.0