Files
censtablo/flake.nix
T
bluepython508 bbd16df0ef Update river
2026-06-06 14:22:19 +01:00

160 lines
4.6 KiB
Nix

{
inputs.nixpkgs.url = "github:NixOS/nixpkgs";
inputs.river = {
url = "git+https://codeberg.org/river/river.git?ref=main";
flake = false;
};
inputs.spork = {
url = "github:janet-lang/spork";
flake = false;
};
inputs.janet-pkgs = {
url = "github:janet-lang/pkgs";
flake = false;
};
inputs.lemongrass = {
url = "github:pyrmont/lemongrass";
flake = false;
};
inputs.janet-wayland = {
url = "git+https://codeberg.org/ifreund/janet-wayland";
flake = false;
};
inputs.janet-xkbcommon = {
url = "git+https://codeberg.org/ifreund/janet-xkbcommon";
flake = false;
};
outputs = inputs @ {
self,
nixpkgs,
river,
spork,
janet-pkgs,
lemongrass,
janet-wayland,
janet-xkbcommon,
}: let
systems = ["x86_64-linux" "aarch64-linux"];
eachSystem = f:
nixpkgs.lib.genAttrs systems (system:
f {
inherit system;
pkgs = nixpkgs.legacyPackages.${system};
ownPkgs = self.packages.${system};
});
in {
packages = eachSystem ({
pkgs,
system,
...
}: let
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 = 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_16.hook];
buildInputs = with pkgs; [
libGL
libevdev
libinput
pixman
udev
wayland
wayland-protocols
wlroots_0_20
libx11
libxkbcommon
];
});
default = pkgs.stdenv.mkDerivation {
pname = "censtablo";
version = "0.1.0";
src = ./.;
nativeBuildInputs = [pkgs.pkg-config janet-pm];
buildInputs = [
(pkgs.wayland.overrideAttrs (final: prev: {
# patches = [
# (pkgs.fetchpatch {
# url = "https://gitlab.freedesktop.org/wayland/wayland/-/merge_requests/485.patch";
# hash = "sha256-gd5BRE/ioFMM86Q8HLSzdvuwDDaqws0b3HiInC0nNgQ=";
# })
# ];
}))
pkgs.wayland-scanner
pkgs.wayland-protocols
pkgs.libxkbcommon
pkgs.janet
];
RIVER_PROTOCOLS = "${inputs.river}/protocol/";
deps = [
"${janet-pkgs}:git__https___github.com_janet-lang_pkgs.git"
"${spork}:git__https___github.com_janet-lang_spork"
"${lemongrass}:git__https___github.com_pyrmont_lemongrass"
"${janet-wayland}:git__https___codeberg.org_ifreund_janet-wayland"
"${janet-xkbcommon}: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 ownPkgs.river];
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/"
'';
};
});
};
}