Build with nix properly

This commit is contained in:
bluepython508
2026-02-10 14:18:56 +00:00
parent 5930ffd357
commit 148dee337e
7 changed files with 154 additions and 84 deletions

2
.gitignore vendored
View File

@@ -1,5 +1,5 @@
/.direnv/
/.jpm/
/build/
/result/
/result
/_build/

View File

@@ -1 +1 @@
@{:name "censtablo" :description "River Window Manager" :jpm-dependencies @["https://codeberg.org/ifreund/janet-wayland" "https://codeberg.org/ifreund/janet-xkbcommon"]}
@{:name "censtablo" :description "River Window Manager"}

200
flake.nix
View File

@@ -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/"
'';
});
};
});
};
}

6
lockfile.jdn Normal file
View File

@@ -0,0 +1,6 @@
[
{:config @{:auto-remove true :installed-with "spork/pm" :pm {:type :git :url "https://github.com/pyrmont/lemongrass"}} :name "lemongrass" :pm {:type :git :url "https://github.com/pyrmont/lemongrass"}}
{:config @{:auto-remove true :installed-with "spork/pm" :pm {:type :git :url "https://github.com/janet-lang/spork"}} :name "spork" :pm {:type :git :url "https://github.com/janet-lang/spork"}}
{:config @{:auto-remove true :installed-with "spork/pm" :pm {:type :git :url "https://codeberg.org/ifreund/janet-wayland"}} :name "wayland" :pm {:type :git :url "https://codeberg.org/ifreund/janet-wayland"}}
{:config @{:auto-remove true :installed-with "spork/pm" :pm {:type :git :url "https://codeberg.org/ifreund/janet-xkbcommon"}} :name "xkbcommon" :pm {:type :git :url "https://codeberg.org/ifreund/janet-xkbcommon"}}
]

View File

@@ -496,9 +496,10 @@
(def ks [:tag-main :tag-offload :tags-other])
(fn [seat binding]
(def outputs (wm :outputs))
(def tags (map |(table (seq [k :in ks] k ($ k))) outputs))
(def tags (map |(tabseq [k :in ks] k ($ k)) outputs))
(map (fn [out tags]
(eachp [k tag] tags (put out k tag))) outputs [;(slice tags 1) (first tags)])))
(eachp [k tag] tags (put out k tag))) outputs [;(slice tags 1) (first tags)])
((action/focus-output :next) seat nil)))
(defn rule/pulldown []
(fn [window]
@@ -522,11 +523,11 @@
(defn locked-screen []
(print "Locked!")
(def notifs-status (= 0 (os/execute ["dunstctl" "is-paused" "-e"] :p)))
(os/execute ["dunstctl" "set-paused" "true"] :p)
(os/execute ["pidwait" "swaylock"] :p) # Blocking is fine here -- we're locked
(os/execute ["dunstctl" "set-paused" (if notifs-status "true" "false")] :p))
(ev/spawn
(os/execute ["pidwait" "swaylock"] :p)
(os/execute ["dunstctl" "set-paused" (if notifs-status "true" "false")] :p)))
(defn lock-screen []
(spawn "swaylock")
@@ -583,7 +584,7 @@
(defn startup []
(spawn "pkill waybar && waybar")
(spawn "pkill waybar; waybar")
(spawn "kanshi")
(spawn "vesktop")

View File

@@ -1,9 +1,16 @@
(declare-project
:name "censtablo"
:description ""
:dependencies @["spork" "https://codeberg.org/ifreund/janet-wayland"]
:version "0.0.0")
(declare-executable
:name "censtablo"
:entry "./main.janet")
:entry "./main.janet"
:install true
:pkg-config-libs ["wayland-client" "xkbcommon"])
(declare-executable
:name "censtablo-repl"
:entry "./repl.janet"
:install true
:pkg-config-libs ["wayland-client" "xkbcommon"])

4
repl.janet Normal file
View File

@@ -0,0 +1,4 @@
(import spork/netrepl)
(defn main [exe]
(netrepl/client :unix (string (os/getenv "XDG_RUNTIME_DIR") "/censtablo-" (os/getenv "WAYLAND_DISPLAY"))))