[bug#77203,3/4] gnu: Add fscrypt.

Message ID 19f066863519516b9d67656a2cf29b4b1a45796e.1742726021.git.45mg.writes@gmail.com
State New
Headers
Series gnu: Add fscrypt. |

Commit Message

45mg March 23, 2025, 10:34 a.m. UTC
  * gnu/packages/golang-crypto.scm (fscrypt): New variable.

Change-Id: I7df45a9345726480518c598583a10b6e905e8a1f
---
 gnu/packages/golang-crypto.scm | 74 +++++++++++++++++++++++++++++++++-
 1 file changed, 73 insertions(+), 1 deletion(-)
  

Patch

diff --git a/gnu/packages/golang-crypto.scm b/gnu/packages/golang-crypto.scm
index 17567219e4..61a911a494 100644
--- a/gnu/packages/golang-crypto.scm
+++ b/gnu/packages/golang-crypto.scm
@@ -26,6 +26,7 @@ 
 ;;; Copyright © 2024 Superfly Johnson <superfly.johnson@yahoo.com>
 ;;; Copyright © 2025 Roman Scherer <roman@burningswell.com>
 ;;; Copyright © 2025 Sharlatan Hellseher <sharlatanus@gmail.com>
+;;; Copyright © 2025 45mg <45mg.writes@gmail.com>
 ;;;
 ;;; This file is part of GNU Guix.
 ;;;
@@ -50,6 +51,7 @@  (define-module (gnu packages golang-crypto)
   #:use-module (guix packages)
   #:use-module (guix utils)
   #:use-module (gnu packages)
+  #:use-module (gnu packages base)
   #:use-module (gnu packages gnupg)
   #:use-module (gnu packages golang)
   #:use-module (gnu packages golang-build)
@@ -57,8 +59,11 @@  (define-module (gnu packages golang-crypto)
   #:use-module (gnu packages golang-compression)
   #:use-module (gnu packages golang-web)
   #:use-module (gnu packages golang-xyz)
+  #:use-module (gnu packages linux)
+  #:use-module (gnu packages m4)
   #:use-module (gnu packages password-utils)
-  #:use-module (gnu packages specifications))
+  #:use-module (gnu packages specifications)
+  #:use-module (gnu packages version-control))
 
 ;;; Commentary:
 ;;;
@@ -2608,6 +2613,73 @@  (define-public age
 (define-public age-keygen
   (deprecated-package "age-keygen" age))
 
+(define-public fscrypt
+  (package
+    (name "fscrypt")
+    (version "0.3.5")
+    (source
+     (origin
+       (method git-fetch)
+       (uri (git-reference
+             (url "https://github.com/google/fscrypt")
+             (commit (string-append "v" version))))
+       (file-name (git-file-name name version))
+       (sha256
+        (base32 "15b89g7imv4691aq16xn9q6nh6fcdldkxmvysc7igm6a8p1n6bai"))))
+    (build-system go-build-system)
+    (arguments
+     (list
+      #:import-path "github.com/google/fscrypt"
+      #:install-source? #f
+      #:test-flags
+      #~(list "-skip"
+              (string-join (list
+                            ;; These tests expect to be able to find /home,
+                            ;; /mnt and /tmp.
+                            "TestLoadReadOnlyMount"
+                            "TestReadWriteMountIsPreferredOverReadOnlyMount"
+                            "TestLoadAmbiguousMounts"
+                            "TestRootSubtreeIsPreferred") "|"))
+      #:phases
+      #~(modify-phases %standard-phases
+          (add-before 'build 'fix-version-detection
+            ;; We don't have .git in the build directory.
+            (lambda _
+              (substitute* "src/github.com/google/fscrypt/Makefile"
+                (("\\$\\(shell git describe --tags\\)")
+                 (string-append "v" #$version)))))
+          (replace 'build
+            (lambda* (#:key parallel-build? #:allow-other-keys)
+              (with-directory-excursion "src/github.com/google/fscrypt"
+                (invoke "make"
+                        "-j" (if parallel-build?
+                                 (number->string (parallel-job-count))
+                                 "1")
+                        (string-append "CC=" #$(cc-for-target))))))
+          (replace 'install
+            (lambda _
+              (with-directory-excursion "src/github.com/google/fscrypt"
+                (invoke "make" "install"
+                        (string-append "PREFIX=" #$output))))))))
+    (propagated-inputs (list go-github-com-client9-misspell
+                             go-github-com-pkg-errors
+                             go-github-com-urfave-cli
+                             go-github-com-wadey-gocovmerge
+                             go-golang-org-x-crypto
+                             go-golang-org-x-sys
+                             go-golang-org-x-term
+                             go-golang-org-x-tools
+                             go-google-golang-org-protobuf
+                             go-honnef-co-go-tools))
+    (native-inputs (list gnu-make linux-pam m4))
+    (home-page "https://github.com/google/fscrypt")
+    (synopsis "Go tool for managing Linux filesystem encryption")
+    (description "@command{fscrypt} is a high-level tool for the management of
+Linux native filesystem encryption.  It manages metadata, key generation, key
+wrapping, PAM integration, and provides a uniform interface for creating and
+modifying encrypted directories.")
+    (license license:asl2.0)))
+
 (define-public go-jwker
   (package/inherit go-github-com-jphastings-jwker
     (name "go-jwker")