-
-
Notifications
You must be signed in to change notification settings - Fork 588
/
flake.nix
82 lines (81 loc) · 2.9 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
{
inputs = {
flake-utils.url = "github:numtide/flake-utils";
nixpkgs.url = "github:nixos/nixpkgs";
git-ignore-nix = {
url = "github:hercules-ci/gitignore.nix/master";
inputs.nixpkgs.follows = "nixpkgs";
};
};
outputs =
{ self
, flake-utils
, nixpkgs
, git-ignore-nix
, ...
}:
flake-utils.lib.eachDefaultSystem (system:
let
# 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;
picomOverlay = final: prev: { picom = prev.callPackage ./package.nix { inherit git-ignore-nix; }; };
overlays = [
picomOverlay
];
pkgs = import nixpkgs {
inherit system overlays;
config.allowBroken = true;
};
profilePkgs = import nixpkgs {
inherit system;
overlays = overlays ++ [
(final: prev: {
stdenv = prev.withCFlags "-fno-omit-frame-pointer" prev.stdenv;
})
(final: prev: {
llvmPackages_18 = prev.llvmPackages_18 // {
stdenv = final.withCFlags "-fno-omit-frame-pointer" prev.llvmPackages_18.stdenv;
};
})
];
};
mkDevShell = p: p.overrideAttrs (o: {
hardeningDisable = [ "fortify" ];
shellHook = ''
# Workaround a NixOS limitation on sanitizers:
# See: https://github.com/NixOS/nixpkgs/issues/287763
export LD_LIBRARY_PATH+=":/run/opengl-driver/lib"
export UBSAN_OPTIONS="disable_coredump=0:unmap_shadow_on_exit=1:print_stacktrace=1"
export ASAN_OPTIONS="disable_coredump=0:unmap_shadow_on_exit=1:abort_on_error=1"
'';
});
in
rec {
overlay = picomOverlay;
packages = {
picom = 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.override { devShell = true; });
devShells.useClang = devShells.default.override {
inherit (pkgs.llvmPackages_18) stdenv;
};
# build picom and all dependencies with frame pointer, making profiling/debugging easier.
# WARNING! many many rebuilds
devShells.useClangProfile = (mkDevShell (profilePkgs.picom.override { devShell = true; })).override {
stdenv = profilePkgs.withCFlags "-fno-omit-frame-pointer" profilePkgs.llvmPackages_18.stdenv;
};
});
}