diff --git a/README.md b/README.md index 51a8675..2692f7c 100644 --- a/README.md +++ b/README.md @@ -25,13 +25,18 @@ compile with the latest stable Rust, I haven't tested older versions. In addition, you'll need development libraries for the following, which can probably be installed via your system package manager: +- clang - glib -- gdk-pixbuf +- gdk-pixbuf (optional, provides support for non-PNG image formats) - pam - cairo -- pango +- pango (optional, provides support for system font loading) - xkbcommon +gdk-pixbuf and pango are both optional, and are enabled with the features +`gdk-pixbuf` and `pango` respectively. These features are enabled by default, +you will need to disable them if you do not plan on using these libraries. + With all of that, you should just be able to clone this repository, and run: ```sh diff --git a/build.rs b/build.rs index 0c9d602..ce6ea70 100644 --- a/build.rs +++ b/build.rs @@ -21,6 +21,19 @@ fn main() { long_version.push(')'); } + let mut features = Vec::new(); + if cfg!(feature = "gdk-pixbuf") { + features.push("gdk-pixbuf"); + } + if cfg!(feature = "pango") { + features.push("pango"); + } + if !features.is_empty() { + long_version.push_str(" ("); + long_version.push_str(features.join(" ").trim()); + long_version.push(')'); + } + println!("cargo:rustc-env=NLOCK_VERSION={version}"); println!("cargo:rustc-env=NLOCK_LONG_VERSION={long_version}"); diff --git a/nix/default.nix b/nix/default.nix index e0bc0fa..dd504d3 100644 --- a/nix/default.nix +++ b/nix/default.nix @@ -12,6 +12,8 @@ pkg-config, version ? "git", shortRev ? "unknown", + gdkPixbufSupport ? true, + pangoSupport ? true, }: rustPlatform.buildRustPackage { @@ -24,6 +26,10 @@ rustPlatform.buildRustPackage { lockFile = ../Cargo.lock; }; + buildNoDefaultFeatures = true; + buildFeatures = + [ ] ++ (lib.optional gdkPixbufSupport "gdk-pixbuf") ++ (lib.optional pangoSupport "pango"); + nativeBuildInputs = [ installShellFiles clang @@ -32,12 +38,12 @@ rustPlatform.buildRustPackage { buildInputs = [ cairo - gdk-pixbuf glib libxkbcommon pam - pango - ]; + ] + ++ (lib.optional gdkPixbufSupport gdk-pixbuf) + ++ (lib.optional pangoSupport pango); postInstall = '' installShellCompletion --cmd nlock \