mirror of
https://github.com/feschber/lan-mouse.git
synced 2026-09-08 21:41:07 +03:00
112 lines
3.3 KiB
Nix
112 lines
3.3 KiB
Nix
{
|
|
description = "Nix Flake for lan-mouse";
|
|
inputs = {
|
|
# 26.05 used here to keep allowing builds on x86_64-darwin, bump this to unstable once they deprecate 26.05
|
|
nixpkgs.url = "github:nixos/nixpkgs/nixos-26.05";
|
|
rust-overlay = {
|
|
url = "github:oxalica/rust-overlay";
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
};
|
|
};
|
|
outputs =
|
|
{
|
|
nixpkgs,
|
|
rust-overlay,
|
|
self,
|
|
...
|
|
}:
|
|
let
|
|
inherit (nixpkgs) lib;
|
|
forEachPkgs =
|
|
f:
|
|
lib.genAttrs
|
|
[
|
|
"aarch64-darwin"
|
|
"aarch64-linux"
|
|
"x86_64-darwin"
|
|
"x86_64-linux"
|
|
]
|
|
(
|
|
system:
|
|
let
|
|
pkgs = import nixpkgs {
|
|
inherit system;
|
|
overlays = [
|
|
rust-overlay.overlays.default
|
|
|
|
#NOTE: appstream's meson build injects the literal string
|
|
# "none required" into linker flags on 'aarch64-darwin', causing clang to fail.
|
|
# remove this overlay once we bump nixpkgs to unstable branch
|
|
(
|
|
final: prev:
|
|
lib.optionalAttrs prev.stdenv.hostPlatform.isDarwin {
|
|
appstream = prev.appstream.overrideAttrs (old: {
|
|
postConfigure = (old.postConfigure or "") + ''
|
|
substituteInPlace build.ninja \
|
|
--replace-fail "none required" ""
|
|
'';
|
|
});
|
|
}
|
|
)
|
|
];
|
|
};
|
|
# Default toolchain for devshell
|
|
rustToolchain = pkgs.rust-bin.stable.latest.default.override {
|
|
extensions = [
|
|
# includes already:
|
|
# rustc
|
|
# cargo
|
|
# rust-std
|
|
# rust-docs
|
|
# rustfmt-preview
|
|
# clippy-preview
|
|
"rust-analyzer"
|
|
"rust-src"
|
|
];
|
|
};
|
|
# Minimal toolchain for builds (rustc + cargo + rust-std only)
|
|
rustToolchainForBuild = pkgs.rust-bin.stable.latest.minimal;
|
|
in
|
|
f { inherit pkgs rustToolchain rustToolchainForBuild; }
|
|
);
|
|
in
|
|
{
|
|
packages = forEachPkgs (
|
|
{ pkgs, rustToolchainForBuild, ... }:
|
|
let
|
|
customRustPlatform = pkgs.makeRustPlatform {
|
|
cargo = rustToolchainForBuild;
|
|
rustc = rustToolchainForBuild;
|
|
};
|
|
lan-mouse = pkgs.callPackage ./nix { rustPlatform = customRustPlatform; };
|
|
in
|
|
{
|
|
default = lan-mouse;
|
|
inherit lan-mouse;
|
|
}
|
|
);
|
|
devShells = forEachPkgs (
|
|
{ pkgs, rustToolchain, ... }:
|
|
{
|
|
default = pkgs.mkShell {
|
|
packages =
|
|
with pkgs;
|
|
[
|
|
rustToolchain
|
|
pkg-config
|
|
gtk4
|
|
libadwaita
|
|
librsvg
|
|
]
|
|
++ lib.optionals pkgs.stdenv.hostPlatform.isLinux [
|
|
libX11
|
|
libXtst
|
|
];
|
|
env.RUST_SRC_PATH = "${rustToolchain}/lib/rustlib/src/rust/library";
|
|
};
|
|
}
|
|
);
|
|
homeManagerModules.default = import ./nix/hm-module.nix self;
|
|
};
|
|
}
|