From 5d430d7e8a3b3677c3d551141803fb948da763a9 Mon Sep 17 00:00:00 2001 From: Eduardo Quiros Date: Thu, 5 Oct 2023 11:25:23 -0600 Subject: [PATCH] add nix build from flake --- flake.nix | 2 ++ nix/optisize.nix | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 nix/optisize.nix diff --git a/flake.nix b/flake.nix index 639fbf1..4e97ae7 100644 --- a/flake.nix +++ b/flake.nix @@ -14,6 +14,7 @@ pkgs = import nixpkgs { inherit system overlays; }; + optisize = pkgs.callPackage ./nix/optisize.nix { }; in with pkgs; { @@ -28,6 +29,7 @@ shellHook = '' ''; }; + packages.default = optisize; } ); } diff --git a/nix/optisize.nix b/nix/optisize.nix new file mode 100644 index 0000000..d76aca5 --- /dev/null +++ b/nix/optisize.nix @@ -0,0 +1,32 @@ +{ rustPlatform +, version ? "git" +, lib +, makeWrapper +, withHandbrake ? true +, handbrake +}: +rustPlatform.buildRustPackage { + pname = "optisize"; + inherit version; + src = ../.; + cargoLock.lockFile = ../Cargo.lock; + + nativeBuildInputs = [ makeWrapper ]; + postInstall = with lib; + let + runtimePaths = [ ] + ++ optional withHandbrake handbrake; + in + '' + wrapProgram $out/bin/optisize \ + --prefix PATH : "${makeBinPath runtimePaths}" + ''; + + meta = { + description = "CLI utility to optimize file sizes by matching appropriate optimization scripts"; + homepage = "https://github.com/equirosa/optisize"; + license = lib.licenses.agpl3; + maintainers = with lib.maintainers; [ equirosa ]; + }; +} +