fridge/flake.nix
electria 26af92df96
feat: use only software rendering
this reduces the memory usage from 85.5MB to 25MB
2026-06-26 20:01:36 -07:00

103 lines
2.5 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
wayland
];
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;
# from candy-icons caja-dropbox.svg
icon = ./icon.svg;
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 ];
};
}
);
}