Skip to content

Commit

Permalink
czkawka-full: "init" (#339359)
Browse files Browse the repository at this point in the history
  • Loading branch information
0x4A6F authored Sep 13, 2024
2 parents eb6d5db + 9cc5c5e commit 252c937
Show file tree
Hide file tree
Showing 4 changed files with 133 additions and 79 deletions.
File renamed without changes.
175 changes: 96 additions & 79 deletions pkgs/by-name/cz/czkawka/package.nix
Original file line number Diff line number Diff line change
@@ -1,95 +1,112 @@
{ lib
, stdenv
, atk
, cairo
, czkawka
, darwin
, fetchFromGitHub
, gdk-pixbuf
, glib
, gobject-introspection
, gtk4
, pango
, overrideSDK
, pkg-config
, rustPlatform
, testers
, wrapGAppsHook4
, xvfb-run
{
lib,
atk,
cairo,
callPackage,
darwin,
fetchFromGitHub,
gdk-pixbuf,
glib,
gobject-introspection,
gtk4,
overrideSDK,
pango,
pkg-config,
rustPlatform,
stdenv,
testers,
wrapGAppsHook4,
xvfb-run,
}:

let
pname = "czkawka";
version = "7.0.0";

src = fetchFromGitHub {
owner = "qarmin";
repo = "czkawka";
rev = version;
hash = "sha256-SOWtLmehh1F8SoDQ+9d7Fyosgzya5ZztCv8IcJZ4J94=";
};
cargoPatches = [ ./time.patch ];
cargoHash = "sha256-cQv8C0P3xizsvnJODkTMJQA98P4nYSCHFT75isJE6es=";

buildRustPackage' = rustPlatform.buildRustPackage.override {
stdenv = if stdenv.isDarwin then overrideSDK stdenv "11.0" else stdenv;
};
in
buildRustPackage' {
inherit pname version src cargoPatches cargoHash;

nativeBuildInputs = [
gobject-introspection
pkg-config
wrapGAppsHook4
];
self = buildRustPackage' {
pname = "czkawka";
version = "7.0.0";

buildInputs = [
atk
cairo
gdk-pixbuf
glib
gtk4
pango
] ++ lib.optionals stdenv.hostPlatform.isDarwin (with darwin.apple_sdk.frameworks; [
Foundation
AppKit
]);
src = fetchFromGitHub {
owner = "qarmin";
repo = "czkawka";
rev = self.version;
hash = "sha256-SOWtLmehh1F8SoDQ+9d7Fyosgzya5ZztCv8IcJZ4J94=";
};

nativeCheckInputs = [
xvfb-run
];
cargoPatches = [
# Updates time and time-macros from Cargo.lock
./0000-time.diff
];

strictDeps = true;
cargoHash = "sha256-cQv8C0P3xizsvnJODkTMJQA98P4nYSCHFT75isJE6es=";

checkPhase = ''
runHook preCheck
xvfb-run cargo test
runHook postCheck
'';
nativeBuildInputs = [
gobject-introspection
pkg-config
wrapGAppsHook4
];

doCheck = stdenv.hostPlatform.isLinux
&& (stdenv.hostPlatform == stdenv.buildPlatform);
buildInputs =
[
atk
cairo
gdk-pixbuf
glib
gtk4
pango
]
++ lib.optionals stdenv.hostPlatform.isDarwin (
with darwin.apple_sdk.frameworks;
[
AppKit
Foundation
]
);

passthru.tests.version = testers.testVersion {
package = czkawka;
command = "czkawka_cli --version";
};
nativeCheckInputs = [ xvfb-run ];

# Desktop items, icons and metainfo are not installed automatically
postInstall = ''
install -Dm444 -t $out/share/applications data/com.github.qarmin.czkawka.desktop
install -Dm444 -t $out/share/icons/hicolor/scalable/apps data/icons/com.github.qarmin.czkawka.svg
install -Dm444 -t $out/share/icons/hicolor/scalable/apps data/icons/com.github.qarmin.czkawka-symbolic.svg
install -Dm444 -t $out/share/metainfo data/com.github.qarmin.czkawka.metainfo.xml
'';
strictDeps = true;

meta = {
changelog = "https://github.com/qarmin/czkawka/raw/${version}/Changelog.md";
description = "Simple, fast and easy to use app to remove unnecessary files from your computer";
homepage = "https://github.com/qarmin/czkawka";
license = with lib.licenses; [ mit ];
mainProgram = "czkawka_gui";
maintainers = with lib.maintainers; [ AndersonTorres yanganto _0x4A6F ];
doCheck = stdenv.hostPlatform.isLinux && (stdenv.hostPlatform == stdenv.buildPlatform);

checkPhase = ''
runHook preCheck
xvfb-run cargo test
runHook postCheck
'';

# Desktop items, icons and metainfo are not installed automatically
postInstall = ''
install -Dm444 -t $out/share/applications data/com.github.qarmin.czkawka.desktop
install -Dm444 -t $out/share/icons/hicolor/scalable/apps data/icons/com.github.qarmin.czkawka.svg
install -Dm444 -t $out/share/icons/hicolor/scalable/apps data/icons/com.github.qarmin.czkawka-symbolic.svg
install -Dm444 -t $out/share/metainfo data/com.github.qarmin.czkawka.metainfo.xml
'';

passthru = {
tests.version = testers.testVersion {
package = self;
command = "czkawka_cli --version";
};
wrapper = callPackage ./wrapper.nix {
czkawka = self;
};
};

meta = {
homepage = "https://github.com/qarmin/czkawka";
description = "Simple, fast and easy to use app to remove unnecessary files from your computer";
changelog = "https://github.com/qarmin/czkawka/raw/${self.version}/Changelog.md";
license = with lib.licenses; [ mit ];
mainProgram = "czkawka_gui";
maintainers = with lib.maintainers; [
AndersonTorres
yanganto
_0x4A6F
];
};
};
}
in
self
33 changes: 33 additions & 0 deletions pkgs/by-name/cz/czkawka/wrapper.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
{
lib,
czkawka,
makeWrapper,
symlinkJoin,
# configurable options
extraPackages ? [ ],
}:

symlinkJoin {
name = "czkawka-wrapped-${czkawka.version}";
inherit (czkawka) pname version outputs;

nativeBuildInputs = [ makeWrapper ];

paths = [ czkawka ];

postBuild = ''
${lib.concatMapStringsSep "\n" (
output: "ln --symbolic --no-target-directory ${czkawka.${output}} \$${output}"
) (lib.remove "out" czkawka.outputs)}
pushd $out/bin
for f in *; do
rm -v $f
makeWrapper ${lib.getBin czkawka}/bin/$f $out/bin/$f \
--prefix PATH ":" "${lib.makeBinPath extraPackages}"
done
popd
'';

meta = czkawka.meta;
}
4 changes: 4 additions & 0 deletions pkgs/top-level/all-packages.nix
Original file line number Diff line number Diff line change
Expand Up @@ -4463,6 +4463,10 @@ with pkgs;

cz-cli = callPackage ../applications/version-management/cz-cli { };

czkawka-full = czkawka.wrapper.override {
extraPackages = [ ffmpeg ];
};

comma = callPackage ../tools/package-management/comma { };

commitizen = with python3Packages; toPythonApplication commitizen;
Expand Down

0 comments on commit 252c937

Please sign in to comment.