Refactor flake for overridability, conditional service install, version formatting (#65)
* Refactor flake for overridability, conditional service install, version formatting * Disable default cargo features for the flake package Co-authored-by: sodiboo <37938646+sodiboo@users.noreply.github.com> * Replace deprecated `--replace` with `--replace-fail` in the flake package Co-authored-by: sodiboo <37938646+sodiboo@users.noreply.github.com> * Remove `unstable` from flake package version Co-authored-by: sodiboo <37938646+sodiboo@users.noreply.github.com> * Refactor flake to enable dependency overridability * Pass lib explicitly in flake package * Fix incorrect package path in flake package dependency * Replace makeWrapper with makeBinaryWrapper * Enhance build by separating substitution, service install, and wrapping * Remove redundant arguments from package call --------- Co-authored-by: sodiboo <37938646+sodiboo@users.noreply.github.com>
This commit is contained in:
parent
67efa2c559
commit
4e85e8c69e
1 changed files with 63 additions and 29 deletions
92
flake.nix
92
flake.nix
|
|
@ -6,46 +6,83 @@
|
||||||
url = "github:oxalica/rust-overlay";
|
url = "github:oxalica/rust-overlay";
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
naersk.url = "github:nix-community/naersk";
|
|
||||||
};
|
};
|
||||||
|
|
||||||
outputs = { self, nixpkgs, rust-overlay, naersk, flake-utils }:
|
outputs = { self, nixpkgs, rust-overlay, flake-utils }:
|
||||||
let systems = [ "x86_64-linux" "aarch64-linux" ];
|
let systems = [ "x86_64-linux" "aarch64-linux" ];
|
||||||
in flake-utils.lib.eachSystem systems (system:
|
in flake-utils.lib.eachSystem systems (system:
|
||||||
let
|
let
|
||||||
overlays = [ (import rust-overlay) ];
|
overlays = [ (import rust-overlay) ];
|
||||||
pkgs = import nixpkgs { inherit system overlays; };
|
pkgs = import nixpkgs { inherit system overlays; };
|
||||||
lib = pkgs.lib;
|
|
||||||
|
|
||||||
naersk' = pkgs.callPackage naersk {
|
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
|
||||||
cargo = pkgs.rust-bin.stable.latest.default;
|
cargoPackageVersion = cargoToml.package.version;
|
||||||
rustc = pkgs.rust-bin.stable.latest.default;
|
|
||||||
};
|
|
||||||
|
|
||||||
buildXwaylandSatellite = { withSystemd ? false }: naersk'.buildPackage {
|
commitHash = self.shortRev or self.dirtyShortRev or "unknown";
|
||||||
src = ./.;
|
|
||||||
|
|
||||||
nativeBuildInputs = with pkgs; [
|
version = "${cargoPackageVersion}-${commitHash}";
|
||||||
rustPlatform.bindgenHook
|
|
||||||
rust-bin.stable.latest.default
|
|
||||||
pkg-config
|
|
||||||
|
|
||||||
xcb-util-cursor
|
buildXwaylandSatellite =
|
||||||
xorg.libxcb
|
{ lib
|
||||||
|
, rustPlatform
|
||||||
|
, pkg-config
|
||||||
|
, makeBinaryWrapper
|
||||||
|
, libxcb
|
||||||
|
, xcb-util-cursor
|
||||||
|
, xwayland
|
||||||
|
, withSystemd ? true
|
||||||
|
}:
|
||||||
|
|
||||||
makeWrapper
|
rustPlatform.buildRustPackage rec {
|
||||||
] ++ lib.optional withSystemd pkgs.systemd;
|
pname = "xwayland-satellite";
|
||||||
|
inherit version;
|
||||||
|
|
||||||
buildInputs = [ pkgs.xwayland ];
|
src = self;
|
||||||
|
|
||||||
cargoBuildOptions = opts: opts ++ lib.optional withSystemd "--features systemd";
|
cargoLock = {
|
||||||
|
lockFile = "${src}/Cargo.lock";
|
||||||
|
allowBuiltinFetchGit = true;
|
||||||
|
};
|
||||||
|
|
||||||
postInstall = ''
|
nativeBuildInputs = [
|
||||||
wrapProgram $out/bin/xwayland-satellite \
|
rustPlatform.bindgenHook
|
||||||
--prefix PATH : ${pkgs.xwayland}/bin
|
pkg-config
|
||||||
'';
|
makeBinaryWrapper
|
||||||
};
|
];
|
||||||
|
|
||||||
|
buildInputs = [
|
||||||
|
libxcb
|
||||||
|
xcb-util-cursor
|
||||||
|
];
|
||||||
|
|
||||||
|
buildNoDefaultFeatures = true;
|
||||||
|
buildFeatures = lib.optionals withSystemd [ "systemd" ];
|
||||||
|
|
||||||
|
postPatch = ''
|
||||||
|
substituteInPlace resources/xwayland-satellite.service \
|
||||||
|
--replace-fail '/usr/local/bin' "$out/bin"
|
||||||
|
'';
|
||||||
|
|
||||||
|
postInstall = lib.optionalString withSystemd ''
|
||||||
|
install -Dm0644 resources/xwayland-satellite.service -t $out/lib/systemd/user
|
||||||
|
'';
|
||||||
|
|
||||||
|
postFixup = ''
|
||||||
|
wrapProgram $out/bin/xwayland-satellite \
|
||||||
|
--prefix PATH : "${lib.makeBinPath [ xwayland ]}"
|
||||||
|
'';
|
||||||
|
|
||||||
|
doCheck = false;
|
||||||
|
|
||||||
|
meta = with lib; {
|
||||||
|
description = "Xwayland outside your Wayland";
|
||||||
|
homepage = "https://github.com/Supreeeme/xwayland-satellite";
|
||||||
|
license = licenses.mpl20;
|
||||||
|
platforms = platforms.linux;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
xwayland-satellite = pkgs.callPackage buildXwaylandSatellite { };
|
||||||
in
|
in
|
||||||
{
|
{
|
||||||
devShell = (pkgs.mkShell.override { stdenv = pkgs.clangStdenv; }) {
|
devShell = (pkgs.mkShell.override { stdenv = pkgs.clangStdenv; }) {
|
||||||
|
|
@ -60,11 +97,8 @@
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
packages = rec {
|
packages = {
|
||||||
xwayland-satellite-nosd = buildXwaylandSatellite { withSystemd = false; };
|
xwayland-satellite = xwayland-satellite;
|
||||||
|
|
||||||
xwayland-satellite = buildXwaylandSatellite { withSystemd = true; };
|
|
||||||
|
|
||||||
default = xwayland-satellite;
|
default = xwayland-satellite;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue