mirror of
https://github.com/yshui/picom.git
synced 2024-12-02 14:15:41 -05:00
flake: import package.nix from nixpkgs
So we can have more control of the build process compared to overriding the picom derivation. Also add expressions to cross-compile picom for arm32, arm64, and x86. Signed-off-by: Yuxuan Shui <yshuiv7@gmail.com>
This commit is contained in:
parent
a44f6a2ebe
commit
1175487718
2 changed files with 143 additions and 49 deletions
77
flake.nix
77
flake.nix
|
@ -7,41 +7,22 @@
|
||||||
inputs.nixpkgs.follows = "nixpkgs";
|
inputs.nixpkgs.follows = "nixpkgs";
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
outputs = {
|
outputs =
|
||||||
self,
|
{ self
|
||||||
flake-utils,
|
, flake-utils
|
||||||
nixpkgs,
|
, nixpkgs
|
||||||
git-ignore-nix,
|
, git-ignore-nix
|
||||||
...
|
, ...
|
||||||
}:
|
}:
|
||||||
flake-utils.lib.eachDefaultSystem (system: let
|
flake-utils.lib.eachDefaultSystem (system:
|
||||||
|
let
|
||||||
# like lib.lists.remove, but takes a list of elements to remove
|
# like lib.lists.remove, but takes a list of elements to remove
|
||||||
removeFromList = toRemove: list: pkgs.lib.foldl (l: e: pkgs.lib.remove e l) list toRemove;
|
removeFromList = toRemove: list: pkgs.lib.foldl (l: e: pkgs.lib.remove e l) list toRemove;
|
||||||
overlay = self: super: {
|
picomOverlay = final: prev: { picom = prev.callPackage ./package.nix { }; };
|
||||||
picom = super.picom.overrideAttrs (oldAttrs: rec {
|
overlays = [
|
||||||
version = "11";
|
(final: prev: { inherit git-ignore-nix; })
|
||||||
pname = "picom";
|
picomOverlay
|
||||||
nativeBuildInputs = (removeFromList [ self.asciidoc ] oldAttrs.nativeBuildInputs) ++
|
|
||||||
[
|
|
||||||
self.asciidoctor
|
|
||||||
];
|
];
|
||||||
buildInputs =
|
|
||||||
[
|
|
||||||
self.pcre2
|
|
||||||
self.xorg.xcbutil
|
|
||||||
self.libepoxy
|
|
||||||
] ++ (removeFromList [
|
|
||||||
self.xorg.libXinerama
|
|
||||||
self.xorg.libXext
|
|
||||||
self.pcre
|
|
||||||
] oldAttrs.buildInputs);
|
|
||||||
src = git-ignore-nix.lib.gitignoreSource ./.;
|
|
||||||
});
|
|
||||||
};
|
|
||||||
python = pkgs.python3.withPackages (ps: with ps; [
|
|
||||||
xcffib pip dbus-next
|
|
||||||
]);
|
|
||||||
|
|
||||||
pkgs = import nixpkgs {
|
pkgs = import nixpkgs {
|
||||||
inherit system overlays;
|
inherit system overlays;
|
||||||
config.allowBroken = true;
|
config.allowBroken = true;
|
||||||
|
@ -60,15 +41,8 @@
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
|
|
||||||
overlays = [overlay];
|
|
||||||
mkDevShell = p: p.overrideAttrs (o: {
|
mkDevShell = p: p.overrideAttrs (o: {
|
||||||
nativeBuildInputs = o.nativeBuildInputs ++ (with pkgs; [
|
hardeningDisable = [ "fortify" ];
|
||||||
clang-tools_18
|
|
||||||
llvmPackages_18.clang-unwrapped.python
|
|
||||||
llvmPackages_18.libllvm
|
|
||||||
python
|
|
||||||
]);
|
|
||||||
hardeningDisable = ["fortify"];
|
|
||||||
shellHook = ''
|
shellHook = ''
|
||||||
# Workaround a NixOS limitation on sanitizers:
|
# Workaround a NixOS limitation on sanitizers:
|
||||||
# See: https://github.com/NixOS/nixpkgs/issues/287763
|
# See: https://github.com/NixOS/nixpkgs/issues/287763
|
||||||
|
@ -77,21 +51,32 @@
|
||||||
export ASAN_OPTIONS="disable_coredump=0:unmap_shadow_on_exit=1:abort_on_error=1"
|
export ASAN_OPTIONS="disable_coredump=0:unmap_shadow_on_exit=1:abort_on_error=1"
|
||||||
'';
|
'';
|
||||||
});
|
});
|
||||||
in rec {
|
in
|
||||||
inherit
|
rec {
|
||||||
overlay
|
overlay = picomOverlay;
|
||||||
overlays
|
|
||||||
;
|
|
||||||
packages = {
|
packages = {
|
||||||
|
picom = pkgs.picom;
|
||||||
default = pkgs.picom;
|
default = pkgs.picom;
|
||||||
|
} // (nixpkgs.lib.optionalAttrs (system == "x86_64-linux") rec {
|
||||||
|
picom-cross = {
|
||||||
|
armv7l = pkgs.pkgsCross.armv7l-hf-multiplatform.picom;
|
||||||
|
aarch64 = pkgs.pkgsCross.aarch64-multiplatform.picom;
|
||||||
|
i686 = pkgs.pkgsi686Linux.picom;
|
||||||
|
merged = pkgs.runCommand "picom-merged" {} ''
|
||||||
|
mkdir $out
|
||||||
|
ln -s ${picom-cross.armv7l} $out/armv7l
|
||||||
|
ln -s ${picom-cross.aarch64} $out/aarch64
|
||||||
|
ln -s ${picom-cross.i686} $out/i686
|
||||||
|
'';
|
||||||
};
|
};
|
||||||
devShells.default = mkDevShell packages.default;
|
});
|
||||||
|
devShells.default = mkDevShell (packages.default.override { devShell = true; });
|
||||||
devShells.useClang = devShells.default.override {
|
devShells.useClang = devShells.default.override {
|
||||||
inherit (pkgs.llvmPackages_18) stdenv;
|
inherit (pkgs.llvmPackages_18) stdenv;
|
||||||
};
|
};
|
||||||
# build picom and all dependencies with frame pointer, making profiling/debugging easier.
|
# build picom and all dependencies with frame pointer, making profiling/debugging easier.
|
||||||
# WARNING! many many rebuilds
|
# WARNING! many many rebuilds
|
||||||
devShells.useClangProfile = (mkDevShell profilePkgs.picom).override {
|
devShells.useClangProfile = (mkDevShell (profilePkgs.picom.override { devShell = true; })).override {
|
||||||
stdenv = profilePkgs.withCFlags "-fno-omit-frame-pointer" profilePkgs.llvmPackages_18.stdenv;
|
stdenv = profilePkgs.withCFlags "-fno-omit-frame-pointer" profilePkgs.llvmPackages_18.stdenv;
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|
109
package.nix
Normal file
109
package.nix
Normal file
|
@ -0,0 +1,109 @@
|
||||||
|
{ asciidoctor
|
||||||
|
, dbus
|
||||||
|
, docbook_xml_dtd_45
|
||||||
|
, docbook_xsl
|
||||||
|
, fetchFromGitHub
|
||||||
|
, clang-tools_18
|
||||||
|
, llvmPackages_18
|
||||||
|
, lib
|
||||||
|
, libconfig
|
||||||
|
, libdrm
|
||||||
|
, libev
|
||||||
|
, libGL
|
||||||
|
, libepoxy
|
||||||
|
, libX11
|
||||||
|
, libxcb
|
||||||
|
, libxdg_basedir
|
||||||
|
, libXext
|
||||||
|
, libxml2
|
||||||
|
, libxslt
|
||||||
|
, makeWrapper
|
||||||
|
, meson
|
||||||
|
, ninja
|
||||||
|
, pcre2
|
||||||
|
, pixman
|
||||||
|
, pkg-config
|
||||||
|
, python3
|
||||||
|
, stdenv
|
||||||
|
, uthash
|
||||||
|
, xcbutil
|
||||||
|
, xcbutilimage
|
||||||
|
, xcbutilrenderutil
|
||||||
|
, xorgproto
|
||||||
|
, xwininfo
|
||||||
|
, withDebug ? false
|
||||||
|
, git-ignore-nix
|
||||||
|
, devShell ? false
|
||||||
|
}:
|
||||||
|
|
||||||
|
let
|
||||||
|
versionFromMeson = s: builtins.head (builtins.match "project\\('picom',.*version: *'([0-9.]*)'.*" s);
|
||||||
|
in
|
||||||
|
stdenv.mkDerivation (finalAttrs: {
|
||||||
|
pname = "picom";
|
||||||
|
version = versionFromMeson (builtins.readFile ./meson.build);
|
||||||
|
|
||||||
|
src = git-ignore-nix.lib.gitignoreSource ./.;
|
||||||
|
|
||||||
|
strictDeps = true;
|
||||||
|
|
||||||
|
|
||||||
|
nativeBuildInputs = [
|
||||||
|
asciidoctor
|
||||||
|
docbook_xml_dtd_45
|
||||||
|
docbook_xsl
|
||||||
|
makeWrapper
|
||||||
|
meson
|
||||||
|
ninja
|
||||||
|
pkg-config
|
||||||
|
] ++ (lib.optional devShell [
|
||||||
|
clang-tools_18
|
||||||
|
llvmPackages_18.clang-unwrapped.python
|
||||||
|
llvmPackages_18.libllvm
|
||||||
|
(python3.withPackages (ps: with ps; [
|
||||||
|
xcffib pip dbus-next
|
||||||
|
]))
|
||||||
|
]);
|
||||||
|
|
||||||
|
buildInputs = [
|
||||||
|
dbus
|
||||||
|
libconfig
|
||||||
|
libdrm
|
||||||
|
libev
|
||||||
|
libGL
|
||||||
|
libepoxy
|
||||||
|
libX11
|
||||||
|
libxcb
|
||||||
|
libxdg_basedir
|
||||||
|
libXext
|
||||||
|
libxml2
|
||||||
|
libxslt
|
||||||
|
pcre2
|
||||||
|
pixman
|
||||||
|
uthash
|
||||||
|
xcbutil
|
||||||
|
xcbutilimage
|
||||||
|
xcbutilrenderutil
|
||||||
|
xorgproto
|
||||||
|
];
|
||||||
|
|
||||||
|
# Use "debugoptimized" instead of "debug" so perhaps picom works better in
|
||||||
|
# normal usage too, not just temporary debugging.
|
||||||
|
mesonBuildType = if withDebug then "debugoptimized" else "release";
|
||||||
|
dontStrip = withDebug;
|
||||||
|
|
||||||
|
mesonFlags = [
|
||||||
|
"-Dwith_docs=true"
|
||||||
|
];
|
||||||
|
|
||||||
|
installFlags = [ "PREFIX=$(out)" ];
|
||||||
|
|
||||||
|
# In debug mode, also copy src directory to store. If you then run `gdb picom`
|
||||||
|
# in the bin directory of picom store path, gdb finds the source files.
|
||||||
|
postInstall = ''
|
||||||
|
wrapProgram $out/bin/picom-trans \
|
||||||
|
--prefix PATH : ${lib.makeBinPath [ xwininfo ]}
|
||||||
|
'' + lib.optionalString withDebug ''
|
||||||
|
cp -r ../src $out/
|
||||||
|
'';
|
||||||
|
})
|
Loading…
Reference in a new issue