-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathflake.nix
86 lines (77 loc) · 2.58 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
83
84
85
86
{
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.05";
systems.url = "github:nix-systems/default";
devenv.url = "github:cachix/devenv";
};
outputs = {
self,
nixpkgs,
devenv,
systems,
...
} @ inputs: let
forEachSystem = nixpkgs.lib.genAttrs (import systems);
in {
devShells =
forEachSystem
(system: let
pkgs = nixpkgs.legacyPackages.${system};
# TODO: upstream?
vcpkgDeps = with pkgs; [
pkg-config
autoconf
automake
zip
libtool
];
nativePackages = [
"qtbase"
"qttools"
];
in {
default = pkgs.mkShell {
nativeBuildInputs = with pkgs;
[
cmake
makeWrapper
ninja
gcc14
vcpkg
# profiling
linuxPackages_latest.perf
qt6.qtbase
qt6.qttools
qt6.qtwayland
qt6.wrapQtAppsHook
]
++ vcpkgDeps;
shellHook = ''
export VCPKG_ROOT=$(realpath $(dirname $(readlink -f $(type -p vcpkg)))/../share/vcpkg)
# set required environment variables for Qt
setQtEnvironment=$(mktemp --suffix .setQtEnvironment.sh)
makeShellWrapper "$(type -p sh)" "$setQtEnvironment" "''${qtWrapperArgs[@]}"
sed "/^exec/d" -i "$setQtEnvironment"
source "$setQtEnvironment"
# TODO: upstream?
# instead of fixing all the ports manually, we prompt the user to install them using Nix
# in the future, a better solution would be to generate a nix derivation from
# the vcpkg manifest
newPortsDir=$HOME/.vcpkg/overlay-ports
for port in ${pkgs.lib.concatStringsSep " " nativePackages}
do
portdir=$newPortsDir/$port
mkdir -p $portdir
echo 'set(VCPKG_POLICY_EMPTY_PACKAGE enabled)' > $portdir/portfile.cmake
echo "message(WARNING Please install $port with Nix)" >> $portdir/portfile.cmake
# We're going to manipulate the vcpkg.json here
# We want to preserve the structure, but remove all dependencies
${pkgs.jq}/bin/jq 'walk(if type == "object" and has("dependencies") then .dependencies = [] else . end)' \
"$VCPKG_ROOT/ports/$port/vcpkg.json" > "$newPortsDir/$port/vcpkg.json"
done
export VCPKG_OVERLAY_PORTS=$newPortsDir:$VCPKG_OVERLAY_PORTS
'';
};
});
};
}