forked from Green-Sky/tomato
update nix flake to support more platforms
This commit is contained in:
parent
73ee0f905b
commit
f5c7261805
34
flake.lock
generated
34
flake.lock
generated
@ -1,5 +1,23 @@
|
||||
{
|
||||
"nodes": {
|
||||
"flake-utils": {
|
||||
"inputs": {
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1694529238,
|
||||
"narHash": "sha256-zsNZZGTGnMOf9YpHKJqMSsa0dXbfmxeoJ7xHlrt+xmY=",
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"rev": "ff7b65b44d01cf9ba6a71320833626af21126384",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "flake-utils",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1694553957,
|
||||
@ -18,8 +36,24 @@
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixpkgs": "nixpkgs"
|
||||
}
|
||||
},
|
||||
"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",
|
||||
|
160
flake.nix
160
flake.nix
@ -5,95 +5,97 @@
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs/release-23.05";
|
||||
flake-utils.url = "github:numtide/flake-utils";
|
||||
};
|
||||
|
||||
outputs = { self, nixpkgs }:
|
||||
let
|
||||
system = "x86_64-linux";
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
in {
|
||||
packages.${system}.default = pkgs.stdenv.mkDerivation {
|
||||
pname = "tomato";
|
||||
version = "0.0.0";
|
||||
outputs = { self, nixpkgs, flake-utils }:
|
||||
flake-utils.lib.eachDefaultSystem (system:
|
||||
let
|
||||
pkgs = import nixpkgs { inherit system; };
|
||||
in {
|
||||
packages.default = pkgs.stdenv.mkDerivation {
|
||||
pname = "tomato";
|
||||
version = "0.0.0";
|
||||
|
||||
src = ./.;
|
||||
submodules = 1;
|
||||
src = ./.;
|
||||
submodules = 1;
|
||||
|
||||
nativeBuildInputs = with pkgs; [
|
||||
cmake
|
||||
ninja
|
||||
pkg-config
|
||||
patchelf
|
||||
];
|
||||
nativeBuildInputs = with pkgs; [
|
||||
cmake
|
||||
ninja
|
||||
pkg-config
|
||||
patchelf
|
||||
];
|
||||
|
||||
# for some reason, buildInputs performs some magic an converts them to build dependencies, not runtime dependencies
|
||||
# also, non static dependencies (?? how to ensure ??)
|
||||
dlopenBuildInputs = with pkgs; [
|
||||
xorg.libX11
|
||||
xorg.libXext
|
||||
xorg.xorgproto
|
||||
xorg.libICE
|
||||
xorg.libXi
|
||||
xorg.libXScrnSaver
|
||||
xorg.libXcursor
|
||||
xorg.libXinerama
|
||||
xorg.libXrandr
|
||||
xorg.libXxf86vm
|
||||
libGL
|
||||
];
|
||||
# for some reason, buildInputs performs some magic an converts them to build dependencies, not runtime dependencies
|
||||
# also, non static dependencies (?? how to ensure ??)
|
||||
dlopenBuildInputs = with pkgs; [
|
||||
xorg.libX11
|
||||
xorg.libXext
|
||||
xorg.xorgproto
|
||||
xorg.libICE
|
||||
xorg.libXi
|
||||
xorg.libXScrnSaver
|
||||
xorg.libXcursor
|
||||
xorg.libXinerama
|
||||
xorg.libXrandr
|
||||
xorg.libXxf86vm
|
||||
libGL
|
||||
];
|
||||
|
||||
buildInputs = with pkgs; [
|
||||
#(libsodium.override { stdenv = pkgs.pkgsStatic.stdenv; })
|
||||
#pkgsStatic.libsodium
|
||||
libsodium
|
||||
] ++ self.packages.${system}.default.dlopenBuildInputs;
|
||||
buildInputs = with pkgs; [
|
||||
#(libsodium.override { stdenv = pkgs.pkgsStatic.stdenv; })
|
||||
#pkgsStatic.libsodium
|
||||
libsodium
|
||||
] ++ self.packages.${system}.default.dlopenBuildInputs;
|
||||
|
||||
# TODO: replace with install command
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
mv bin/tomato $out/bin
|
||||
'';
|
||||
|
||||
# copied from nixpkgs's SDL2 default.nix
|
||||
# SDL is weird in that instead of just dynamically linking with
|
||||
# libraries when you `--enable-*` (or when `configure` finds) them
|
||||
# it `dlopen`s them at runtime. In principle, this means it can
|
||||
# ignore any missing optional dependencies like alsa, pulseaudio,
|
||||
# some x11 libs, wayland, etc if they are missing on the system
|
||||
# and/or work with wide array of versions of said libraries. In
|
||||
# nixpkgs, however, we don't need any of that. Moreover, since we
|
||||
# don't have a global ld-cache we have to stuff all the propagated
|
||||
# libraries into rpath by hand or else some applications that use
|
||||
# SDL API that requires said libraries will fail to start.
|
||||
#
|
||||
# You can grep SDL sources with `grep -rE 'SDL_(NAME|.*_SYM)'` to
|
||||
# list the symbols used in this way.
|
||||
# TODO: only patch if building FOR nix (like not for when static building)
|
||||
postFixup =
|
||||
let
|
||||
#rpath = lib.makeLibraryPath (dlopenPropagatedBuildInputs ++ dlopenBuildInputs);
|
||||
rpath = nixpkgs.lib.makeLibraryPath (self.packages.${system}.default.dlopenBuildInputs);
|
||||
in
|
||||
nixpkgs.lib.optionalString (pkgs.stdenv.hostPlatform.extensions.sharedLibrary == ".so") ''
|
||||
patchelf --set-rpath "$(patchelf --print-rpath $out/bin/tomato):${rpath}" "$out/bin/tomato"
|
||||
# TODO: replace with install command
|
||||
installPhase = ''
|
||||
mkdir -p $out/bin
|
||||
mv bin/tomato $out/bin
|
||||
'';
|
||||
};
|
||||
|
||||
devShells.${system}.default = pkgs.mkShell {
|
||||
#inputsFrom = with pkgs; [ SDL2 ];
|
||||
buildInputs = [ self.packages.${system}.default ]; # this makes a prebuild tomato available in the shell, do we want this?
|
||||
# copied from nixpkgs's SDL2 default.nix
|
||||
# SDL is weird in that instead of just dynamically linking with
|
||||
# libraries when you `--enable-*` (or when `configure` finds) them
|
||||
# it `dlopen`s them at runtime. In principle, this means it can
|
||||
# ignore any missing optional dependencies like alsa, pulseaudio,
|
||||
# some x11 libs, wayland, etc if they are missing on the system
|
||||
# and/or work with wide array of versions of said libraries. In
|
||||
# nixpkgs, however, we don't need any of that. Moreover, since we
|
||||
# don't have a global ld-cache we have to stuff all the propagated
|
||||
# libraries into rpath by hand or else some applications that use
|
||||
# SDL API that requires said libraries will fail to start.
|
||||
#
|
||||
# You can grep SDL sources with `grep -rE 'SDL_(NAME|.*_SYM)'` to
|
||||
# list the symbols used in this way.
|
||||
# TODO: only patch if building FOR nix (like not for when static building)
|
||||
postFixup =
|
||||
let
|
||||
#rpath = lib.makeLibraryPath (dlopenPropagatedBuildInputs ++ dlopenBuildInputs);
|
||||
rpath = nixpkgs.lib.makeLibraryPath (self.packages.${system}.default.dlopenBuildInputs);
|
||||
in
|
||||
nixpkgs.lib.optionalString (pkgs.stdenv.hostPlatform.extensions.sharedLibrary == ".so") ''
|
||||
patchelf --set-rpath "$(patchelf --print-rpath $out/bin/tomato):${rpath}" "$out/bin/tomato"
|
||||
'';
|
||||
};
|
||||
|
||||
packages = with pkgs; [
|
||||
cmake
|
||||
pkg-config
|
||||
];
|
||||
devShells.${system}.default = pkgs.mkShell {
|
||||
#inputsFrom = with pkgs; [ SDL2 ];
|
||||
buildInputs = [ self.packages.${system}.default ]; # this makes a prebuild tomato available in the shell, do we want this?
|
||||
|
||||
shellHook = "echo hello to tomato dev shell!";
|
||||
};
|
||||
packages = with pkgs; [
|
||||
cmake
|
||||
pkg-config
|
||||
];
|
||||
|
||||
apps.${system}.default = {
|
||||
program = "${self.packages.${system}.default}/bin/tomato";
|
||||
type = "app";
|
||||
};
|
||||
};
|
||||
shellHook = "echo hello to tomato dev shell!";
|
||||
};
|
||||
|
||||
apps.default = {
|
||||
type = "app";
|
||||
program = "${self.packages.${system}.default}/bin/tomato";
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user