nix: add overlay, remove flake-parts, and other changes
Most of the changes are heavily inspired by the structure of Niri's flake.nix. - add overlay - add formatter for nix - remove flake-parts - use rust-overlay only for the dev shell. end users can set `inputs.rust-overlay.follows = ""` to skip downloading it. - add rust-analyzer and rust-src extensions in the dev shell - filter the source in order to reduce rebuilds - support all Linux systems that the nixpkgs flake exposes - override VERGEN_GIT_DESCRIBE to include the git rev as well - remove `clangStdenv` from the dev shell. I'm not sure what purpose it served. If the intention was faster linking with lld, then it's not needed anymore, now that lld has become the default linker in rust 1.90.0.
This commit is contained in:
parent
37ec78ee26
commit
1fa632c291
3 changed files with 136 additions and 120 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -1 +1,2 @@
|
|||
/target
|
||||
/result
|
||||
|
|
|
|||
34
flake.lock
generated
34
flake.lock
generated
|
|
@ -1,23 +1,5 @@
|
|||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1731533236,
|
||||
"narHash": "sha256-l0KFg5HjrsfsO/JpG+r7fRrqm12kzFHyUHqHCVpMMbI=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "11707dc2f618dd54ca8739b309ec4fc024de578b",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1764522689,
|
||||
|
|
@ -36,7 +18,6 @@
|
|||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"rust-overlay": "rust-overlay"
|
||||
}
|
||||
|
|
@ -60,21 +41,6 @@
|
|||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
|
|
|
|||
221
flake.nix
221
flake.nix
|
|
@ -1,106 +1,155 @@
|
|||
{
|
||||
description = "Xwayland outside your Wayland";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.11";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
|
||||
# NOTE: This is not necessary for end users
|
||||
# You can omit it with `inputs.rust-overlay.follows = ""`
|
||||
rust-overlay = {
|
||||
url = "github:oxalica/rust-overlay";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs, rust-overlay, flake-utils }:
|
||||
let systems = [ "x86_64-linux" "aarch64-linux" ];
|
||||
in flake-utils.lib.eachSystem systems (system:
|
||||
let
|
||||
overlays = [ (import rust-overlay) ];
|
||||
pkgs = import nixpkgs { inherit system overlays; };
|
||||
outputs =
|
||||
{
|
||||
self,
|
||||
nixpkgs,
|
||||
rust-overlay,
|
||||
}:
|
||||
let
|
||||
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
|
||||
cargoPackageVersion = cargoToml.package.version;
|
||||
commitHash = self.shortRev or self.dirtyShortRev or "unknown";
|
||||
|
||||
cargoToml = builtins.fromTOML (builtins.readFile ./Cargo.toml);
|
||||
cargoPackageVersion = cargoToml.package.version;
|
||||
xwayland-satellite-package =
|
||||
{
|
||||
lib,
|
||||
rustPlatform,
|
||||
pkg-config,
|
||||
makeBinaryWrapper,
|
||||
libxcb,
|
||||
xcb-util-cursor,
|
||||
xwayland,
|
||||
withSystemd ? true,
|
||||
}:
|
||||
rustPlatform.buildRustPackage (finalAttrs: {
|
||||
pname = "xwayland-satellite";
|
||||
version = "${cargoPackageVersion}-${commitHash}";
|
||||
|
||||
commitHash = self.shortRev or self.dirtyShortRev or "unknown";
|
||||
|
||||
version = "${cargoPackageVersion}-${commitHash}";
|
||||
|
||||
buildXwaylandSatellite =
|
||||
{ lib
|
||||
, rustPlatform
|
||||
, pkg-config
|
||||
, makeBinaryWrapper
|
||||
, libxcb
|
||||
, xcb-util-cursor
|
||||
, xwayland
|
||||
, withSystemd ? true
|
||||
}:
|
||||
|
||||
rustPlatform.buildRustPackage rec {
|
||||
pname = "xwayland-satellite";
|
||||
inherit version;
|
||||
|
||||
src = self;
|
||||
|
||||
cargoLock = {
|
||||
lockFile = "${src}/Cargo.lock";
|
||||
allowBuiltinFetchGit = true;
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
rustPlatform.bindgenHook
|
||||
pkg-config
|
||||
makeBinaryWrapper
|
||||
src = lib.fileset.toSource {
|
||||
root = ./.;
|
||||
fileset = lib.fileset.unions [
|
||||
./OpenSans-Regular.ttf
|
||||
./build.rs
|
||||
./macros
|
||||
./testwl
|
||||
./wl_drm
|
||||
./resources
|
||||
./src
|
||||
./Cargo.toml
|
||||
./Cargo.lock
|
||||
];
|
||||
|
||||
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;
|
||||
mainProgram = "xwayland-satellite";
|
||||
platforms = platforms.linux;
|
||||
};
|
||||
};
|
||||
|
||||
xwayland-satellite = pkgs.callPackage buildXwaylandSatellite { };
|
||||
in
|
||||
{
|
||||
devShell = (pkgs.mkShell.override { stdenv = pkgs.clangStdenv; }) {
|
||||
buildInputs = with pkgs; [
|
||||
cargoLock = {
|
||||
lockFile = ./Cargo.lock;
|
||||
allowBuiltinFetchGit = true;
|
||||
};
|
||||
|
||||
nativeBuildInputs = [
|
||||
rustPlatform.bindgenHook
|
||||
rust-bin.stable.latest.default
|
||||
pkg-config
|
||||
|
||||
xcb-util-cursor
|
||||
xorg.libxcb
|
||||
xwayland
|
||||
makeBinaryWrapper
|
||||
];
|
||||
};
|
||||
|
||||
packages = {
|
||||
xwayland-satellite = xwayland-satellite;
|
||||
buildInputs = [
|
||||
libxcb
|
||||
xcb-util-cursor
|
||||
];
|
||||
|
||||
buildNoDefaultFeatures = true;
|
||||
buildFeatures = lib.optional withSystemd "systemd";
|
||||
|
||||
doCheck = false;
|
||||
|
||||
env.VERGEN_GIT_DESCRIBE = finalAttrs.version;
|
||||
|
||||
postInstall = ''
|
||||
wrapProgram $out/bin/xwayland-satellite \
|
||||
--prefix PATH : "${lib.makeBinPath [ xwayland ]}"
|
||||
''
|
||||
+ lib.optionalString withSystemd ''
|
||||
install -Dm0644 resources/xwayland-satellite.service -t $out/lib/systemd/user
|
||||
'';
|
||||
|
||||
postFixup = lib.optionalString withSystemd ''
|
||||
substituteInPlace $out/lib/systemd/user/xwayland-satellite.service \
|
||||
--replace-fail /usr/local/bin $out/bin
|
||||
'';
|
||||
|
||||
meta = with lib; {
|
||||
description = "Xwayland outside your Wayland";
|
||||
homepage = "https://github.com/Supreeeme/xwayland-satellite";
|
||||
license = licenses.mpl20;
|
||||
mainProgram = "xwayland-satellite";
|
||||
platforms = platforms.linux;
|
||||
};
|
||||
});
|
||||
|
||||
inherit (nixpkgs) lib;
|
||||
|
||||
# Support all Linux systems that the nixpkgs flake exposes
|
||||
systems = lib.intersectLists lib.systems.flakeExposed lib.platforms.linux;
|
||||
|
||||
forAllSystems = lib.genAttrs systems;
|
||||
nixpkgsFor = forAllSystems (system: nixpkgs.legacyPackages.${system});
|
||||
in
|
||||
{
|
||||
devShells = forAllSystems (
|
||||
system:
|
||||
let
|
||||
pkgs = nixpkgsFor.${system};
|
||||
rust-bin = rust-overlay.lib.mkRustBin { } pkgs;
|
||||
inherit (self.packages.${system}) xwayland-satellite;
|
||||
in
|
||||
{
|
||||
default = pkgs.mkShell {
|
||||
packages = [
|
||||
(rust-bin.stable.latest.default.override {
|
||||
extensions = [
|
||||
"rust-analyzer"
|
||||
"rust-src"
|
||||
];
|
||||
})
|
||||
];
|
||||
|
||||
nativeBuildInputs = [
|
||||
pkgs.rustPlatform.bindgenHook
|
||||
pkgs.pkg-config
|
||||
pkgs.makeBinaryWrapper
|
||||
];
|
||||
buildInputs = xwayland-satellite.buildInputs ++ [ pkgs.xwayland ];
|
||||
};
|
||||
}
|
||||
);
|
||||
|
||||
formatter = forAllSystems (system: nixpkgsFor.${system}.nixfmt);
|
||||
|
||||
packages = forAllSystems (
|
||||
system:
|
||||
let
|
||||
xwayland-satellite = nixpkgsFor.${system}.callPackage xwayland-satellite-package { };
|
||||
in
|
||||
{
|
||||
inherit xwayland-satellite;
|
||||
default = xwayland-satellite;
|
||||
};
|
||||
});
|
||||
}
|
||||
);
|
||||
|
||||
overlays.default = final: _: {
|
||||
xwayland-satellite = final.callPackage xwayland-satellite-package { };
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue