Build with nix properly
This commit is contained in:
200
flake.nix
200
flake.nix
@@ -5,7 +5,7 @@
|
||||
flake = false;
|
||||
};
|
||||
|
||||
outputs = {
|
||||
outputs = inputs @ {
|
||||
self,
|
||||
nixpkgs,
|
||||
river,
|
||||
@@ -16,85 +16,70 @@
|
||||
f {
|
||||
inherit system;
|
||||
pkgs = nixpkgs.legacyPackages.${system};
|
||||
ownPkgs = self.packages.${system};
|
||||
});
|
||||
in {
|
||||
devShells = eachSystem ({
|
||||
packages = eachSystem ({
|
||||
pkgs,
|
||||
system,
|
||||
...
|
||||
}: {
|
||||
default = pkgs.mkShell (let
|
||||
libxkbcommon = pkgs.libxkbcommon.overrideAttrs {
|
||||
version = "1.12.0";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "xkbcommon";
|
||||
repo = "libxkbcommon";
|
||||
tag = "xkbcommon-1.12.0";
|
||||
hash = "sha256-QO3snl7NiyS2ao2MF3eT/lkNmVBjijr3JdTyrPn/2MQ=";
|
||||
};
|
||||
patches = [];
|
||||
doCheck = false;
|
||||
}: let
|
||||
libxkbcommon = pkgs.libxkbcommon.overrideAttrs {
|
||||
version = "1.12.0";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "xkbcommon";
|
||||
repo = "libxkbcommon";
|
||||
tag = "xkbcommon-1.12.0";
|
||||
hash = "sha256-QO3snl7NiyS2ao2MF3eT/lkNmVBjijr3JdTyrPn/2MQ=";
|
||||
};
|
||||
in {
|
||||
packages = let
|
||||
janet-pm = pkgs.stdenv.mkDerivation rec {
|
||||
pname = "janet-pm";
|
||||
version = "1.1.1";
|
||||
src = pkgs.fetchFromGitHub {
|
||||
owner = "janet-lang";
|
||||
repo = "spork";
|
||||
rev = "v${version}";
|
||||
hash = "sha256-0L2G7flzNzi8w1nkGcQrtKjGl/D2uC8xSRgsBuLgRxM=";
|
||||
};
|
||||
patches = [
|
||||
(pkgs.fetchpatch {
|
||||
url = "https://github.com/tw4452852/spork/commit/304ff781565d9bac21bef450770a312182730727.patch";
|
||||
hash = "sha256-9hTY3s3GphAg07we7gOF8vAPAYaWOjVkaspt8wP5KOU=";
|
||||
})
|
||||
(pkgs.fetchpatch {
|
||||
url = "https://patch-diff.githubusercontent.com/raw/janet-lang/spork/pull/269.patch";
|
||||
hash = "sha256-HMvqmiZR+a2yE54PqlLji2Vi6zoUcQ8eD5HFcqAPxEo=";
|
||||
})
|
||||
];
|
||||
nativeBuildInputs = [pkgs.janet];
|
||||
patches = [];
|
||||
doCheck = false;
|
||||
};
|
||||
spork = pkgs.fetchFromGitHub {
|
||||
owner = "janet-lang";
|
||||
repo = "spork";
|
||||
rev = "master";
|
||||
hash = "sha256-gFUyrqkcjD34LZ9G7igaDwHnfIUUN9MzbvwEk9uWl1w=";
|
||||
};
|
||||
janet-pm = pkgs.stdenv.mkDerivation {
|
||||
pname = "janet-pm";
|
||||
version = "1.1.1";
|
||||
src = spork;
|
||||
buildInputs = [pkgs.janet];
|
||||
|
||||
buildPhase = ''
|
||||
export JANET_PATH=$out
|
||||
mkdir $JANET_PATH
|
||||
janet --install .
|
||||
'';
|
||||
};
|
||||
river-pkg = pkgs.stdenv.mkDerivation (finalAttrs: {
|
||||
name = "river";
|
||||
version = "0.4";
|
||||
src = river;
|
||||
deps = pkgs.callPackage ./river.build.zig.zon.nix {};
|
||||
zigBuildFlags = ["--system" "${finalAttrs.deps}" "-Dxwayland"];
|
||||
nativeBuildInputs = with pkgs; [pkg-config wayland-scanner xwayland zig_0_15.hook];
|
||||
buildInputs = with pkgs; [
|
||||
libGL
|
||||
libevdev
|
||||
libinput
|
||||
pixman
|
||||
udev
|
||||
wayland
|
||||
wayland-protocols
|
||||
wlroots_0_19
|
||||
libx11
|
||||
libxkbcommon
|
||||
];
|
||||
buildPhase = ''
|
||||
export JANET_PATH=$out
|
||||
mkdir $JANET_PATH
|
||||
janet --install .
|
||||
'';
|
||||
};
|
||||
river = pkgs.stdenv.mkDerivation (finalAttrs: {
|
||||
name = "river";
|
||||
version = "0.4";
|
||||
src = inputs.river;
|
||||
deps = pkgs.callPackage ./river.build.zig.zon.nix {};
|
||||
zigBuildFlags = ["--system" "${finalAttrs.deps}" "-Dxwayland"];
|
||||
nativeBuildInputs = with pkgs; [pkg-config wayland-scanner xwayland zig_0_15.hook];
|
||||
buildInputs = with pkgs; [
|
||||
libGL
|
||||
libevdev
|
||||
libinput
|
||||
pixman
|
||||
udev
|
||||
wayland
|
||||
wayland-protocols
|
||||
wlroots_0_19
|
||||
libx11
|
||||
libxkbcommon
|
||||
];
|
||||
|
||||
dontConfigure = true;
|
||||
});
|
||||
repl = pkgs.writeScriptBin "censtablo-repl" ''
|
||||
#!/usr/bin/env janet
|
||||
(import spork/netrepl)
|
||||
|
||||
(netrepl/client :unix (string (os/getenv "XDG_RUNTIME_DIR") "/censtablo-" (os/getenv "WAYLAND_DISPLAY")))
|
||||
'';
|
||||
in [pkgs.janet janet-pm river-pkg repl];
|
||||
|
||||
nativeBuildInputs = [pkgs.pkg-config];
|
||||
dontConfigure = true;
|
||||
});
|
||||
default = pkgs.stdenv.mkDerivation {
|
||||
pname = "censtablo";
|
||||
version = "0.1.0";
|
||||
src = ./.;
|
||||
nativeBuildInputs = [pkgs.pkg-config janet-pm];
|
||||
buildInputs = [
|
||||
(pkgs.wayland.overrideAttrs (final: prev: {
|
||||
patches =
|
||||
@@ -109,17 +94,84 @@
|
||||
pkgs.wayland-scanner
|
||||
pkgs.wayland-protocols
|
||||
libxkbcommon
|
||||
pkgs.janet
|
||||
];
|
||||
|
||||
RIVER_PROTOCOLS = "${river}/protocol/";
|
||||
RIVER_PROTOCOLS = "${inputs.river}/protocol/";
|
||||
deps = [
|
||||
"${pkgs.fetchFromGitHub {
|
||||
owner = "janet-lang";
|
||||
repo = "pkgs";
|
||||
rev = "master";
|
||||
hash = "sha256-VPzMcRq8oerlHwDegKaqP6MpOMsUprDAAzyqrI7YEY8=";
|
||||
}}:git__https___github.com_janet-lang_pkgs.git"
|
||||
"${spork}:git__https___github.com_janet-lang_spork"
|
||||
"${pkgs.fetchFromGitHub {
|
||||
owner = "pyrmont";
|
||||
repo = "lemongrass";
|
||||
rev = "master";
|
||||
hash = "sha256-OUqK57EYh6McnxnbvqoPm92eBMYM5iNaPuN6R0yZHA4=";
|
||||
}}:git__https___github.com_pyrmont_lemongrass"
|
||||
"${pkgs.fetchFromGitea {
|
||||
domain = "codeberg.org";
|
||||
owner = "ifreund";
|
||||
repo = "janet-wayland";
|
||||
rev = "189eb3b2e3a87a676b7f682d8cf1764bb6eb457f";
|
||||
hash = "sha256-dIGjPeBL8/enIwwrSMqNdSOtBWnyo1ioHSLcL1VN2uI=";
|
||||
}}:git__https___codeberg.org_ifreund_janet-wayland"
|
||||
"${pkgs.fetchFromGitea {
|
||||
domain = "codeberg.org";
|
||||
owner = "ifreund";
|
||||
repo = "janet-xkbcommon";
|
||||
rev = "main";
|
||||
hash = "sha256-W7X1ABu1v2+sqZ29OICiYYaFixxXo4uclYfsF4OMAPE=";
|
||||
}}:git__https___codeberg.org_ifreund_janet-xkbcommon"
|
||||
];
|
||||
|
||||
buildPhase = ''
|
||||
export JANET_OFFLINE=1
|
||||
export JANET_PATH=$PWD/janet-path
|
||||
export JANET_BUILD_DIR=$(mktemp -d)
|
||||
mkdir -p $JANET_PATH/.cache
|
||||
cd $JANET_PATH/.cache
|
||||
for dep in $deps; do
|
||||
echo $dep
|
||||
cp -r --no-preserve=mode $(tr ':' ' ' <<<"$dep")
|
||||
f=$(sed -e 's/.*://' <<<"$dep")/bundle/info.jdn
|
||||
[ -f "$f" ] && sed -ie 's/:(jpm-)?dependencies @\[.*\]//' $f
|
||||
done
|
||||
cd -
|
||||
janet-pm install https://github.com/janet-lang/spork
|
||||
janet-pm install https://github.com/pyrmont/lemongrass
|
||||
janet-pm install https://codeberg.org/ifreund/janet-wayland
|
||||
janet-pm install https://codeberg.org/ifreund/janet-xkbcommon
|
||||
janet-pm install
|
||||
'';
|
||||
|
||||
installPhase = ''
|
||||
install -D -t $out/bin/ ./janet-path/bin/censtablo{,-repl}
|
||||
'';
|
||||
};
|
||||
in {
|
||||
inherit default janet-pm river;
|
||||
});
|
||||
devShells = eachSystem ({
|
||||
pkgs,
|
||||
system,
|
||||
ownPkgs,
|
||||
...
|
||||
}: {
|
||||
default = pkgs.mkShell {
|
||||
inputsFrom = [ownPkgs.default];
|
||||
inherit (ownPkgs.default) RIVER_PROTOCOLS;
|
||||
packages = [ownPkgs.janet-pm];
|
||||
shellHook = ''
|
||||
export JANET_PATH="$PWD/.jpm"
|
||||
mkdir -p $JANET_PATH
|
||||
# Put this at the end so that installing spork in a local environment _doesn't_ override the janet-pm we're providing with patches so that pkg-config doesn't get `with-path`
|
||||
export PATH="$PATH:$JANET_PATH/bin/"
|
||||
'';
|
||||
});
|
||||
};
|
||||
});
|
||||
};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user