Help-wanted: install with configuration.nix
Opened this issue · 2 comments
How do I install this in my configuration.nix? In hyprland (my previous wm) there's a guide; https://github.com/hyprwm/Hyprland/wiki/Installation#without-flakes is there such a thing for newm?
I have everything set up using flakes (see my repositories). Maybe you can use that as a basis to build sth without flakes.
Unfortunately I have got very little time at the moment and can't provide support, maybe other nix users on here can.
I was able to get this working, mostly by copying the contents of the flakes into derivations. Though, I'm pretty new to nix, so my style not be the greatest ;)
For pyWM:
{
python3Packages,
fetchgit,
fetchFromGitHub,
pkgs,
...
}:
python3Packages.buildPythonPackage rec {
# A released derivation would ask you if you wanted to include xwayland support.
# I wasn't interested in that, so I statically set it to yes. Basically you would modify your buildInputs and mesonFlags to not include it if you didn't want it.
pname = "pywm";
version = "v0.3alpha";
name = "${pname}-${version}";
srcs = [
(fetchgit {
url = "https://github.com/jbuchermn/pywm.git";
rev = "02dd26196d0a8cd5390fa22f583f8e5a4ed198e4";
sha256 = "iCZhb+byXsBIBH7QkfiesOjBM1CHuf0jxF//NPQs3xg=";
})
(fetchgit {
url = "https://gitlab.freedesktop.org/wlroots/wlroots";
rev = "e279266f714c7122e9ad97d56d047313f78cfdbe";
sha256 = "8RldE5JsQILUZ2DF1nB6AEz1pZecgnURIjRXK/dCAdI=";
fetchSubmodules = true;
})
];
setSourceRoot = ''
for i in ./*; do
if [ -f "$i/wlroots.syms" ]; then
wlrootsDir=$i
fi
if [ -f "$i/pywm/pywm.py" ]; then
sourceRoot=$i
fi
done
'';
preConfigure = ''
echo "--- Pre-configure --------------"
echo " wlrootsDir=$wlrootsDir"
echo " sourceRoot=$sourceRoot"
echo "--- ls -------------------------"
ls -al
echo "--- ls ../wlrootsDir -----------"
ls -al ../$wlrootsDir
rm -rf ./subprojects/wlroots 2> /dev/null
cp -r ../$wlrootsDir ./subprojects/wlroots
rm -rf ./build
echo "--- ls ./subprojects/wlroots ---"
ls -al ./subprojects/wlroots/
echo "--------------------------------"
'';
mesonFlags = ["-Dxwayland=enabled"];
nativeBuildInputs = with pkgs; [
meson
ninja
pkg-config
wayland-scanner
glslang
];
preBuild = "cd ..";
buildInputs = with pkgs;
[
libGL
wayland
wayland-protocols
libinput
libxkbcommon
pixman
vulkan-loader
mesa
seatd
libpng
ffmpeg
libcap
xorg.xcbutilwm
xorg.xcbutilrenderutil
xorg.xcbutilerrors
xorg.xcbutilimage
xorg.libX11
]
++ [
xwayland
];
propagatedBuildInputs = with pkgs.python3Packages; [
imageio
numpy
pycairo
evdev
];
}
The module thefuzz is not currently part of nixpkgs, so you need to create a derivation for that:
{ python3Packages, ... }:
with python3Packages;
buildPythonPackage rec {
version = "0.19.0";
pname = "thefuzz";
name = "${pname}-${version}";
propagatedBuildInputs = [
python-Levenshtein
pycodestyle
];
src = fetchPypi {
inherit pname version;
sha256 = "b3Em2y8silQhKwXjp0DkX0KRxJfXXSB1Fyj2Nbt0qj0=";
};
}
And then finally, import those two derivations into your newm derivation:
{
pkgs,
python3Packages,
fetchFromGitHub,
}:
with python3Packages; let
thefuzz = pkgs.callPackage (import ./python-thefuzz.nix) {};
pywm = pkgs.callPackage (import ./pywm.nix) {};
in
buildPythonApplication rec {
pname = "newm";
version = "v0.3alpha";
src = fetchFromGitHub {
owner = "jbuchermn";
repo = "newm";
rev = "v0.3alpha";
sha256 = "5mpXPvxfCr7bDdT/zwFAyZUqjgHe5yGK4lE3HuDYJkY=";
};
setuptoolsCheckPhase = "true";
propagatedBuildInputs = with python3Packages;
[
pywm
pycairo
psutil
python-pam
pyfiglet
dasbus
thefuzz
setuptools
];
# newm comes with some desktop environment like helpers that you might want it to have on its PATH. I think you would put those here.
# buildInputs = with pkgs; [ brightnessctl ];
# For reasons I don't understand, the desktop file isn't part of my build directory, so I just make it here.
postInstall = ''
mkdir -p $out/share/wayland-sessions/
echo "[Desktop Entry]
Name=newm
Comment=A scrolling Wayland compositor
Exec=$out/bin/start-newm
Type=Application" > $out/share/wayland-sessions/newm.desktop
chmod u+rw $out/share/wayland-sessions/newm.desktop
chmod g+r $out/share/wayland-sessions/newm.desktop
chmod o+r $out/share/wayland-sessions/newm.desktop
'';
}
Then you just call this package and add it to your system packages. You'll also want to add it to your display manager's session packages.