Skip to content
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
117 changes: 74 additions & 43 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
{
description = "Git repository summary on your terminal";
description = ''
Git repository summary on your terminal
'';

inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";

crane.url = "github:ipetkov/crane";

flake-utils.url = "github:numtide/flake-utils";

advisory-db = {
Expand All @@ -14,8 +14,17 @@
};
};

outputs = { self, nixpkgs, crane, flake-utils, advisory-db, ... }:
flake-utils.lib.eachDefaultSystem (system:
outputs =
{
self,
nixpkgs,
crane,
flake-utils,
advisory-db,
...
}:
flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = nixpkgs.legacyPackages.${system};

Expand All @@ -25,92 +34,111 @@
src = ./.;

# Common arguments can be set here to avoid repeating them later
commonArgs = {
common = {
inherit src;
strictDeps = true;

buildInputs = with pkgs;
# Bunch of libraries required for package proper work
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
# Bunch of libraries required for package proper work
# Bunch of libraries required for package to properly work

buildInputs =
with pkgs;
[
# package dependencies
zstd
] ++ lib.optionals pkgs.stdenv.isDarwin (with pkgs; [
]
++ lib.optionals pkgs.stdenv.isDarwin (
with pkgs;
[
# additional dependencies on Darwin systems
CoreFoundation
libresolv
Security
]);
nativeBuildInputs = with pkgs; [ cmake pkg-config ];
]
);
# Software required for project build
nativeBuildInputs = with pkgs; [
cmake
pkg-config
];
# Tools required for checks
nativeCheckInputs = with pkgs; [ git ];

# Additional environment variables can be set directly
# MY_CUSTOM_VAR = "some value";
};

# Build *just* the cargo dependencies, so we can reuse
# all of that work (e.g. via cachix) when running in CI
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
# Build dependencies only, so we will be able to reuse them further
cargoArtifacts = craneLib.buildDepsOnly common;

# Build the actual crate itself, reusing the dependency
# artifacts from above.
onefetch =
craneLib.buildPackage (commonArgs // { inherit cargoArtifacts; });
in {
build = craneLib.buildPackage (common // { inherit cargoArtifacts; });
in
{
checks = {
# Build the crate as part of `nix flake check` for convenience
inherit onefetch;
inherit build;

# Run clippy (and deny all warnings) on the crate source,
# again, reusing the dependency artifacts from above.
#
# Note that this is done as a separate derivation so that
# we can block the CI if there are issues here, but not
# prevent downstream consumers from building our crate by itself.
onefetch-clippy = craneLib.cargoClippy (commonArgs // {
clippy = craneLib.cargoClippy (
common
// {
inherit cargoArtifacts;
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
});
}
);

onefetch-doc =
craneLib.cargoDoc (commonArgs // { inherit cargoArtifacts; });
doc = craneLib.cargoDoc (common // { inherit cargoArtifacts; });

# Check formatting
onefetch-fmt = craneLib.cargoFmt { inherit src; };
fmt = craneLib.cargoFmt { inherit src; };

onefetch-toml-fmt = craneLib.taploFmt {
tomlFmt = craneLib.taploFmt {
src = pkgs.lib.sources.sourceFilesBySuffices src [ ".toml" ];
# taplo arguments can be further customized below as needed
# taploExtraArgs = "--config ./taplo.toml";
Copy link
Preview

Copilot AI Jul 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The commented taplo configuration line references './taplo.toml' but the actual taplo.toml file exists at the project root. This should be uncommented and the path corrected to just 'taplo.toml' or removed if not needed.

Suggested change
# taploExtraArgs = "--config ./taplo.toml";
taploExtraArgs = "--config taplo.toml";

Copilot uses AI. Check for mistakes.

};

# Audit dependencies
onefetch-audit = craneLib.cargoAudit { inherit src advisory-db; };
audit = craneLib.cargoAudit { inherit src advisory-db; };

# Audit licenses
onefetch-deny = craneLib.cargoDeny { inherit src; };
deny = craneLib.cargoDeny { inherit src; };

# Run tests with cargo-nextest
# Consider setting `doCheck = false` on `my-crate` if you do not want
# the tests to run twice
onefetch-nextest = craneLib.cargoNextest (commonArgs // {
nextest = craneLib.cargoNextest (
common
// {
inherit cargoArtifacts;
partitions = 1;
partitionType = "count";
cargoNextestPartitionsExtraArgs = "--no-tests=pass";
});
}
);
};

packages = rec {
onefetch-debug = onefetch // {
cargoExtraArgs = lib.concatStringsSep " " [
# Just to get more human-readable look
"--profile dev"
];
};
inherit onefetch;
onefetch-debug = craneLib.buildPackage (
common
// {
inherit cargoArtifacts;
doCheck = false;
CARGO_PROFILE = "dev";
}
);
onefetch = craneLib.buildPackage (
common
// {
inherit cargoArtifacts;
doCheck = false;
}
);
default = onefetch-debug;
};

apps.default = flake-utils.lib.mkApp { drv = onefetch; };
apps.default = flake-utils.lib.mkApp { drv = build; };

devShells.default = craneLib.devShell {
# Inherit inputs from checks.
Expand All @@ -123,14 +151,17 @@
packages = with pkgs; [
# pkgs.ripgrep
nixd
nixfmt
nixfmt-rfc-style
];
};
});
}
);
# Sets substituters to avoid locally building something already built
nixConfig = {
extra-substituters =
[ "https://crane.cachix.org" "https://cache.garnix.io" ];
extra-substituters = [
"https://crane.cachix.org"
"https://cache.garnix.io"
];
extra-trusted-public-keys = [
"crane.cachix.org-1:8Scfpmn9w+hGdXH/Q9tTLiYAE/2dnJYRJP7kl80GuRk="
"cache.garnix.io:CTFPyKSLcx5RMJKfLo5EEPUObbA78b0YQ2DTCJXqr9g="
Expand Down
6 changes: 1 addition & 5 deletions image/src/kitty.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,7 @@ impl KittyBackend {

// generate red rgba test image
let mut test_image = Vec::<u8>::with_capacity(32 * 32 * 4);
test_image.extend(
std::iter::repeat([255, 0, 0, 255].iter())
.take(32 * 32)
.flatten(),
);
test_image.extend(std::iter::repeat_n([255, 0, 0, 255].iter(), 32 * 32).flatten());

// print the test image with the action set to query
print!(
Expand Down