fridge/flake.nix
electria 5fd8832b59
feat: new custom icon
I'm not satisfied with it
2026-07-01 09:12:05 -07:00

109 lines
2.6 KiB
Nix

{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
crane.url = "github:ipetkov/crane";
flake-utils.url = "github:numtide/flake-utils";
};
outputs =
inputs:
inputs.flake-utils.lib.eachDefaultSystem (
system:
let
pkgs = import inputs.nixpkgs { inherit system; };
lib = pkgs.lib;
craneLib = inputs.crane.mkLib pkgs;
cargoToml = fromTOML (builtins.readFile ./Cargo.toml);
name = cargoToml.package.name;
dlDeps = with pkgs; [
# needed for both x11 and wayland
libxkbcommon
libGL
vulkan-loader
wayland
libx11
libxcursor
libxi
libxcb
];
commonArgs = {
# all that's needed for artifacts and checks
nativeBuildInputs = with pkgs; [
];
buildInputs = with pkgs; [
];
src = craneLib.cleanCargoSource ./.;
};
LD_LIBRARY_PATH = lib.makeLibraryPath dlDeps;
# Build *just* the cargo dependencies,
# to reuse them for build and test derivations.
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
# Build the actual crate itself,
# reusing the dependency artifacts from above.
crate =
let
desktopItem = pkgs.makeDesktopItem {
inherit name;
desktopName = name;
icon = ./icon.png;
exec = name;
};
in
craneLib.buildPackage (
commonArgs
// {
inherit cargoArtifacts;
nativeBuildInputs = commonArgs.nativeBuildInputs ++ [
pkgs.autoPatchelfHook
];
buildInputs = commonArgs.buildInputs ++ [
pkgs.libgcc
];
runtimeDependencies = dlDeps;
doCheck = false;
postFixup = ''
mkdir -p "$out/share/applications"
ln -s "${desktopItem}"/share/applications/* "$out/share/applications/"
'';
}
);
in
{
packages.default = crate;
checks = {
crate-clippy = craneLib.cargoClippy (
commonArgs
// {
inherit cargoArtifacts;
cargoClippyExtraArgs = "-- --deny warnings";
}
);
};
devShells.default = craneLib.devShell {
inherit LD_LIBRARY_PATH;
inputsFrom = [ crate ];
packages = [ pkgs.rust-analyzer ];
};
}
);
}