bug#40710: WIP solution

2020-04-29 Thread goodoldpaul

Hello everybody,
I'm attempting to implement the discussed changes. I think these patches 
come pretty close but being my first contribution to Guix's core I would 
like to ask some feedback before submitting these patches with some 
trivial mistake. I tried to base my implementation on [0].


The first patch adds "globstar" support to (guix glob), namely the 
ability of recursively matching subdirectories in a glob pattern (i.e. 
"foo/**/bar.scm" matches both "foo/bar.scm" and "foo/baz/bar.scm").


The second patch adds (guix glob) to the imported modules of 
node-build-system and uses that to parse glob patterns in the "files" 
array of a package.json and then install all the matching files.


I tested the patches by verifying that

./pre-inst-env guix build -K node-semver node-util-deprecate 
node-statsd-parser node-stack-trace node-oop node-mersenne 
node-long-stack-traces node-far node-env-variable node-color-name


runs without error and by running make check TESTS="tests/glob.scm" .

Do you have any feedback/advice?

Thanks,

Giacomo

[0]: https://docs.npmjs.com/files/package.json#filesFrom 2aaed4af3f171fa0a5d1817d9e0902cf1088b1a7 Mon Sep 17 00:00:00 2001
From: Giacomo Leidi 
Date: Wed, 29 Apr 2020 15:59:48 +0200
Subject: [PATCH 1/2] guix: Add globstar support.

* guix/glob.scm (string->sglob)
(glob-match?): Add globstar support.
* tests/glob.scm: Update accordingly.
---
 guix/glob.scm  | 13 +
 tests/glob.scm |  8 ++--
 2 files changed, 19 insertions(+), 2 deletions(-)

diff --git a/guix/glob.scm b/guix/glob.scm
index a9fc744802..9b796ffd8f 100644
--- a/guix/glob.scm
+++ b/guix/glob.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2018 Ludovic Courtès 
+;;; Copyright © 2020 Giacomo Leidi 
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -61,6 +62,11 @@ STR, a glob pattern such as \"foo*\" or \"foo??bar\"."
(flatten (reverse (if (null? pending)
  result
  (cons-string pending result)
+  ((#\* #\* #\/ . rest)
+   (if (zero? brackets)
+   (loop rest '() 0
+ (cons* '**/ (cons-string pending result)))
+   (loop rest (cons '**/ pending) brackets result)))
   (((and chr (or #\? #\*)) . rest)
(let ((wildcard (match chr
  (#\? '?)
@@ -121,6 +127,13 @@ STR, a glob pattern such as \"foo*\" or \"foo??bar\"."
   (string-null? str))
  (('*)
   #t)
+ (('**/ suffix . rest)
+  (let ((rest (if (eq? '* suffix) (cdr rest) rest))
+  (suffix (if (eq? '* suffix) (car rest) suffix)))
+  (match (string-contains str suffix)
+(#f#f)
+(index (loop rest (string-drop str
+   (+ index (string-length suffix
  (('* suffix . rest)
   (match (string-contains str suffix)
 (#f#f)
diff --git a/tests/glob.scm b/tests/glob.scm
index 3134069789..2a5a40c3c6 100644
--- a/tests/glob.scm
+++ b/tests/glob.scm
@@ -1,5 +1,6 @@
 ;;; GNU Guix --- Functional package management for GNU
 ;;; Copyright © 2018 Ludovic Courtès 
+;;; Copyright © 2020 Giacomo Leidi 
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -53,7 +54,8 @@
  "foo[abc]bar" => '("foo" (set #\a #\b #\c) "bar")
  "foo[a[b]c]bar" => '("foo" (set #\a #\[ #\b #\] #\c) "bar")
  "[123]x" => '((set #\1 #\2 #\3) "x")
- "[a-z]" => '((range #\a #\z)))
+ "[a-z]" => '((range #\a #\z))
+ "**/*.scm" => '(**/ * ".scm"))
 
 (test-glob-match
  ("foo" matches "foo" (and not "foobar" "barfoo"))
@@ -64,6 +66,8 @@
  ("ab[0-9]c" matches "ab0c" "ab7c" "ab9c"
   (and not "ab-c" "ab00c" "ab3"))
  ("ab[cdefg]" matches "abc" "abd" "abg"
-  (and not "abh" "abcd" "ab[")))
+  (and not "abh" "abcd" "ab["))
+ ("foo/**/*.scm" matches "foo/bar/baz.scm" "foo/bar.scm" "foo/bar/baz/zab.scm"
+  (and not "foo/bar/baz.java" "foo/bar.smc")))
 
 (test-end "glob")
-- 
2.26.2

From 0a3f6a52fde940116112e348a86d76a9017de757 Mon Sep 17 00:00:00 2001
From: Giacomo Leidi 
Date: Wed, 29 Apr 2020 16:07:28 +0200
Subject: [PATCH 2/2] guix: Enforce package.json "files" directive.

* guix/build/node-build-system.scm (install): Enforce package.json "files" directive.
* guix/build-system/node.scm (%node-build-system-modules)
(node-build)[modules]: Add (guix glob).
---
 guix/build-system/node.scm   |  4 ++-
 guix/build/node-build-system.scm | 57 
 2 files changed, 47 insertions(+), 14 deletions(-)

diff --git a/guix/build-system/node.scm b/guix/build-system/node.scm
index 05c24c47d5..05bc9f2087 100644
--- a/guix/build-system/node.scm
+++ b/guix/build-system/node.scm
@@ -42,6 +42,7 @@ registry."
   `((guix build node-build-system)
 (guix build json)
 (guix build union)
+(guix glob)
 ,@%gnu-build-system-modules)) ;; TODO: Might be not needed
 
 (define (default-node)
@@ -90,7 +91,8 @@ registry."
  (modules '((guix build 

bug#40710: node-build-system should not install tests

2020-04-19 Thread goodoldpaul
As discussed here [0], node-build-system right now installs all the 
contents of a package's root node_modules directory, including i.e. 
tests.
We should investigate how exactly npm decides what to install and try to 
replicate that inside node-build-system. It seems likely that it uses 
the "files" array from the package.json file (see [1-2]).


[0]: https://debbugs.gnu.org/cgi/bugreport.cgi?bug=36599
[1]: https://github.com/colorjs/color-name/blob/master/package.json#L6
[2]: https://github.com/npm/node-semver/blob/master/package.json#L21





bug#36775: USB sticks can't be accessed on XFCE

2019-07-23 Thread goodoldpaul
No USB flash drive can be mounted on XFCE. Both lsusb and lsblk 
correctly show the device, showing that the device is not 
malfunctioning.


Fdisk can access and modify the partitions on the device but gparted 
will segfault right after it finishes to search for devices. You can 
find my config.scm as an attachment.


This is the output of `guix describe`:

Generation 201  Jul 23 2019 21:53:47(current)
  guix c42db89
repository URL: https://git.savannah.gnu.org/git/guix.git
branch: master
commit: c42db89ff992037841e7937059db952571af86fa
(use-modules (gnu))
(use-service-modules desktop nix networking ssh xorg)

(operating-system
  (locale "en_US.utf8")
  (timezone "Europe/Rome")
  (keyboard-layout
(keyboard-layout "it" "nodeadkeys"))
  (bootloader
(bootloader-configuration
  (bootloader grub-efi-bootloader)
  (target "/boot/efi")
  (keyboard-layout keyboard-layout)))
  (file-systems
(cons* (file-system
 (mount-point "/home")
 (device
   (uuid "4d4c4af6-28ef-49ae-b08b-211b5648ebfc"
 'ext4))
 (type "ext4"))
   (file-system
 (mount-point "/")
 (device
   (uuid "2125621a-4da2-42b7-88d7-2d0fa16157e1"
 'ext4))
 (type "ext4"))
   (file-system
 (mount-point "/boot/efi")
 (device (uuid "E7FB-57B4" 'fat32))
 (type "vfat"))
   %base-file-systems))
  (swap-devices '("/dev/sda3"))
  (host-name "frastanato")
  (users (cons* (user-account
  (name "orang3")
  (comment "Giacomo Leidi")
  (group "users")
  (home-directory "/home/orang3")
  (supplementary-groups
'("wheel" "netdev" "audio" "video" "kvm")))
%base-user-accounts))
  (packages
(append
 (list ;; Nix package manager
   (specification->package "nix")
   ;; HTTPS
   (specification->package "nss-certs")
   ;; User mounts
   (specification->package "gvfs")
   (specification->package "font-dejavu"))
  %base-packages))
  (services
   (append
(list (service xfce-desktop-service-type)
  (service tor-service-type)
  (service nix-service-type)
  (set-xorg-configuration
   (xorg-configuration
(keyboard-layout keyboard-layout)))
  (extra-special-file "/usr/bin/env"
  (file-append coreutils "/bin/env"))
  )
%desktop-services)))


bug#36667: crates-io.scm packages should build on master

2019-07-15 Thread goodoldpaul
Rust libraries contained in gnu/packages/crates-io.scm are not building 
anymore because cargo wants to download crate dependencies inside the 
store.


The attached patch sets the CARGO_HOME environment variable  to "." much 
earlier than it previously was, just after the configure phase. With the 
attached patch all packages in crates-io.scm build without errors.


I hope I did everything right,

Bye,

GiacomoFrom 867b8bd5fc43305b3dac3d9c8e7574344170d8aa Mon Sep 17 00:00:00 2001
From: Giacomo Leidi 
Date: Mon, 15 Jul 2019 16:07:00 +0200
Subject: [PATCH] guix: Fix cargo-build-system.

* guix/build/cargo-build-system.scm (install): Moved CARGO_HOME setting
to...
* guix/build/cargo-build-system.scm (configure): ... here.
---
 guix/build/cargo-build-system.scm | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/guix/build/cargo-build-system.scm b/guix/build/cargo-build-system.scm
index 1f36304b15..a34bd0632a 100644
--- a/guix/build/cargo-build-system.scm
+++ b/guix/build/cargo-build-system.scm
@@ -118,6 +118,9 @@ directory = '" port)
   ;; upgrading the compiler for example.
   (setenv "RUSTFLAGS" "--cap-lints allow")
   (setenv "CC" (string-append (assoc-ref inputs "gcc") "/bin/gcc"))
+  ;; Force cargo to honor our .cargo/config definitions
+  ;; https://github.com/rust-lang/cargo/issues/6397
+  (setenv "CARGO_HOME" ".")
   #t)
 
 (define* (build #:key
@@ -148,9 +151,6 @@ directory = '" port)
 ;; Make cargo reuse all the artifacts we just built instead
 ;; of defaulting to making a new temp directory
 (setenv "CARGO_TARGET_DIR" "./target")
-;; Force cargo to honor our .cargo/config definitions
-;; https://github.com/rust-lang/cargo/issues/6397
-(setenv "CARGO_HOME" ".")
 
 ;; Only install crates which include binary targets,
 ;; otherwise cargo will raise an error.
-- 
2.22.0