- Joined
- Mar 23, 2020
Surprisingly enough, Niri, despite being only about ~2 years old, actually has a full section in the official Guix cookbook dedicated to using cargo workspaces. Pretty neat.niggerbabble
2.2.1.2 Cargo Workspaces and Development Snapshots
In this example, we’ll package niri, which depends on development snapshots (also Cargo
workspaces here).
As we can’t ensure compatibility of a development snapshot, before executing cargo
generate-lockfile, we should modify Cargo.toml to pin it to a known working revision.
To use our packaged development snapshots, it’s also necessary to modify Cargo.toml
in a build phase, with a package-specific substitution pattern.
(define-public niri
(package
(name "niri")
(version "25.02")
(source (origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/YaLTeR/niri")
(commit (string-append "v" version))))
(file-name (git-file-name name version))
(sha256
(base32
"0vzskaalcz6pcml687n54adjddzgf5r07gggc4fhfsa08h1wfd4r"))))
(build-system cargo-build-system)
(arguments
(list #:install-source? #f
#:phases
#~(modify-phases %standard-phases
(add-after 'unpack 'use-guix-vendored-dependencies
(lambda _
(substitute* "Cargo.toml"
(("# version =.*")
"version = \"*\"")
(("git.*optional")
"version = \"*\", optional")
(("^git = .*")
"")))))))
(native-inputs
(list pkg-config))
(inputs
(cons* clang
libdisplay-info
libinput-minimal
libseat
libxkbcommon
mesa
pango
pipewire
wayland
(cargo-inputs 'niri)))
(home-page "https://github.com/YaLTeR/niri")
(synopsis "Scrollable-tiling Wayland compositor")
(description
"Niri is a scrollable-tiling Wayland compositor which arranges windows in a
scrollable format. It is considered stable for daily use and performs most
functions expected of a Wayland compositor.")
(license license:gpl3+)))
niri has Cargo workspace dependencies. When packaging a Cargo workspace depen-
dency, parameter #
argo-package-crates is required.
(define-public rust-pipewire-0.8.0.fd3d8f7
(let ((commit "fd3d8f7861a29c2eeaa4c393402e013578bb36d9")
(revision "0"))
(package
(name "rust-pipewire")
(version (git-version "0.8.0" revision commit))
(source
(origin
(method git-fetch)
(uri (git-reference
(url "https://gitlab.freedesktop.org/pipewire/pipewire-rs.git")
(commit commit)))
(file-name (git-file-name name version))
(sha256
(base32 "1hzyhz7xg0mz8a5y9j6yil513p1m610q3j9pzf6q55vdh5mcn79v"))))
(build-system cargo-build-system)
(arguments
(list #:skip-build? #t
#
argo-package-crates
''("libspa-sys" "libspa" "pipewire-sys" "pipewire")))
(inputs (cargo-inputs 'rust-pipewire-0.8.0.fd3d8f7))
(home-page "https://pipewire.org/")
(synopsis "Rust bindings for PipeWire")
(description "This package provides Rust bindings for PipeWire.")
(license license:expat))))
Don’t forget to modify all workspace members in (gnu packages rust-crates):
(define rust-pipewire-0.8.0.fd3d8f7 rust-pipewire-0.8.0.fd3d8f7)
(define rust-pipewire-sys-0.8.0.fd3d8f7 rust-pipewire-0.8.0.fd3d8f7)
...
(define rust-libspa-0.8.0.fd3d8f7 rust-pipewire-0.8.0.fd3d8f7)
(define rust-libspa-sys-0.8.0.fd3d8f7 rust-pipewire-0.8.0.fd3d8
In this example, we’ll package niri, which depends on development snapshots (also Cargo
workspaces here).
As we can’t ensure compatibility of a development snapshot, before executing cargo
generate-lockfile, we should modify Cargo.toml to pin it to a known working revision.
To use our packaged development snapshots, it’s also necessary to modify Cargo.toml
in a build phase, with a package-specific substitution pattern.
(define-public niri
(package
(name "niri")
(version "25.02")
(source (origin
(method git-fetch)
(uri (git-reference
(url "https://github.com/YaLTeR/niri")
(commit (string-append "v" version))))
(file-name (git-file-name name version))
(sha256
(base32
"0vzskaalcz6pcml687n54adjddzgf5r07gggc4fhfsa08h1wfd4r"))))
(build-system cargo-build-system)
(arguments
(list #:install-source? #f
#:phases
#~(modify-phases %standard-phases
(add-after 'unpack 'use-guix-vendored-dependencies
(lambda _
(substitute* "Cargo.toml"
(("# version =.*")
"version = \"*\"")
(("git.*optional")
"version = \"*\", optional")
(("^git = .*")
"")))))))
(native-inputs
(list pkg-config))
(inputs
(cons* clang
libdisplay-info
libinput-minimal
libseat
libxkbcommon
mesa
pango
pipewire
wayland
(cargo-inputs 'niri)))
(home-page "https://github.com/YaLTeR/niri")
(synopsis "Scrollable-tiling Wayland compositor")
(description
"Niri is a scrollable-tiling Wayland compositor which arranges windows in a
scrollable format. It is considered stable for daily use and performs most
functions expected of a Wayland compositor.")
(license license:gpl3+)))
niri has Cargo workspace dependencies. When packaging a Cargo workspace depen-
dency, parameter #
(define-public rust-pipewire-0.8.0.fd3d8f7
(let ((commit "fd3d8f7861a29c2eeaa4c393402e013578bb36d9")
(revision "0"))
(package
(name "rust-pipewire")
(version (git-version "0.8.0" revision commit))
(source
(origin
(method git-fetch)
(uri (git-reference
(url "https://gitlab.freedesktop.org/pipewire/pipewire-rs.git")
(commit commit)))
(file-name (git-file-name name version))
(sha256
(base32 "1hzyhz7xg0mz8a5y9j6yil513p1m610q3j9pzf6q55vdh5mcn79v"))))
(build-system cargo-build-system)
(arguments
(list #:skip-build? #t
#
''("libspa-sys" "libspa" "pipewire-sys" "pipewire")))
(inputs (cargo-inputs 'rust-pipewire-0.8.0.fd3d8f7))
(home-page "https://pipewire.org/")
(synopsis "Rust bindings for PipeWire")
(description "This package provides Rust bindings for PipeWire.")
(license license:expat))))
Don’t forget to modify all workspace members in (gnu packages rust-crates):
(define rust-pipewire-0.8.0.fd3d8f7 rust-pipewire-0.8.0.fd3d8f7)
(define rust-pipewire-sys-0.8.0.fd3d8f7 rust-pipewire-0.8.0.fd3d8f7)
...
(define rust-libspa-0.8.0.fd3d8f7 rust-pipewire-0.8.0.fd3d8f7)
(define rust-libspa-sys-0.8.0.fd3d8f7 rust-pipewire-0.8.0.fd3d8