init repo
This commit is contained in:
commit
1949a815ee
7 changed files with 4152 additions and 0 deletions
102
flake.nix
Normal file
102
flake.nix
Normal file
|
|
@ -0,0 +1,102 @@
|
|||
{
|
||||
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
|
||||
|
||||
libx11
|
||||
libxcursor
|
||||
libxi
|
||||
];
|
||||
|
||||
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 = "image-x-generic";
|
||||
exec = name;
|
||||
};
|
||||
in
|
||||
craneLib.buildPackage (
|
||||
commonArgs
|
||||
// {
|
||||
inherit cargoArtifacts;
|
||||
|
||||
nativeBuildInputs = commonArgs.nativeBuildInputs ++ [
|
||||
pkgs.autoPatchelfHook
|
||||
];
|
||||
|
||||
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 ];
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue