make an installable derivation

untested as yet
main
Daniel Barlow 2022-08-14 10:46:55 +00:00
parent cba4549304
commit 4c4bd9e997
5 changed files with 59 additions and 36 deletions

3
.gitignore vendored Normal file
View File

@ -0,0 +1,3 @@
*~
result*
*.img

View File

@ -2,7 +2,7 @@
**Broken, not ready for use**
> *euphony*: _noun_ Harmonious aqrrangement of sounds in composition; a smooth and agreeable combination of articulate elements in any piece of writing.
> *euphony*: _noun_ Harmonious arrangement of sounds in composition; a smooth and agreeable combination of articulate elements in any piece of writing.
A mostly Fennel-based graphical environment tailored for Linux-based
mobile devices. The principles we aspire to are
@ -19,35 +19,12 @@ mobile devices. The principles we aspire to are
As of 2022 these principles are more aspirational than actual. _This
repo is basically in an advanced state of brokenness_
## Building for a device
To build an image, unpack [Mobile NixOS](https://github.com/NixOS/mobile-nixos/) in a sibling directory
of this repo (so that `../mobile-nixos` addresses it) and then do
something like this (substituing an appropriate device name for
`motorola-potter`)
$ nix-build ../mobile-nixos/ -I mobile-nixos-configuration=./configuration.nix --argstr device motorola-potter -A build.default
You are warmly encouraged to refer to the [Mobile Nixos
docs](https://mobile.nixos.org/devices/) for how to use this image.
Once you have your device up and running and you can ssh into it
somehow (this may take further research, again I invite you to look at
the Mobile Nixos site) then you should be able to use
`nix-copy-closure` to update it without reinstalling.
$ phone=myphone.lan
$ nix-build ../mobile-nixos/ -I mobile-nixos-configuration=./configuration.nix --argstr device motorola-potter -A config.system.build.toplevel
$ nix-copy-closure --to root@${phone} --include-outputs \
./result && ssh root@${phone} \
`readlink result`/bin/switch-to-configuration switch
## Running the shell/apps locally
You may prefer to develop on a desktop device of some kind, especially
if you're changing C code and have that edit/compile run cycle to go
round. You can start the shell locally with
Eufon is intendfed for phones, but you may prefer to develop on a
desktop device of some kind, especially if you're changing C code and
have that edit/compile run cycle to go round. You can start the shell
locally with
$ nix-shell --run "kiwmi -c init.lua"
@ -58,11 +35,31 @@ for the Lua interpreter itself, but it doesn't do the same for kiwmi.
## Connecting to the repl
If you are using the example rc.fnl, it opens a Unix socket that you
can connect to and interact with a Fennel REPL. I use
[socat](http://www.dest-unreach.org/socat/) for this purpose:
If you are using the example rc.fnl, it opens a Unix socket to which
you can connect to interact with a Fennel REPL. The `eufonctl`
script is a wrapper around [socat](http://www.dest-unreach.org/socat/)
$ eufonctl $WAYLAND_DISPLAY
## Building for a device
Eufon can be installed as a [Mobile NixOS](https://github.com/NixOS/mobile-nixos/) module, by adding
`module.nix` to the `imports` in `your configuration.nix`. For example, on my development phone I
have
```nix
imports = [
(import <mobile-nixos/lib/configuration.nix> {
device = "motorola-potter";
})
/home/dan/src/phoen/eufon/module.nix
];
```
Instructions for using Mobile NixOS are currently outside the scope of
this README.
$ socat - unix-connect:${XDG_RUNTIME_DIR}/kiwmi-repl.wayland-1.socket
# TODO

2
bin/eufon.sh Executable file
View File

@ -0,0 +1,2 @@
#!/usr/bin/env bash
kiwmi -V -V -c init.lua

View File

@ -11,6 +11,9 @@
, gtk-layer-shell
, lua5_3
, socat
, cpio
, makeWrapper
} :
let
lua = lua5_3;
@ -63,11 +66,21 @@ stdenv.mkDerivation {
gtk3
webkitgtk
];
nativeBuildInputs = [ cpio makeWrapper ];
installPhase = ''
export LUA_PATH="`lua -e 'print(package.path)'`"
export LUA_CPATH="`lua -e 'print(package.cpath)'`"
mkdir -p $out/bin
substitute bin/eufon.sh $out/bin/eufon \
find . -name kiwmi -prune -o -type l -prune -o -print0 | cpio -0 -v --pass-through $out
substitute bin/eufonctl.sh $out/bin/eufonctl \
--replace SOCAT=socat SOCAT=${socat}/bin/socat
makeWrapper ${kiwmi}/bin/kiwmi $out/bin/eufon \
--set LUA_PATH ".;$out/?.fnl;$LUA_PATH" \
--set LUA_CPATH ".;$out/?.so;$LUA_CPATH" \
--prefix PATH : ${kiwmi}/bin \
--add-flags "-c $out/init.lua"
chmod +x $out/bin/eufon
'';

View File

@ -1,4 +1,5 @@
{ config, lib, pkgs, ... }:
let eufon = pkgs.callPckage ./default.nix; in
{
systemd.services."eufon" = {
wants = [
@ -19,6 +20,7 @@
"systemd-udev-settle.service"
];
conflicts = [
"getty@tty1.service" # not sure if needed
"getty@tty2.service"
"plymouth-quit.service"
];
@ -27,11 +29,11 @@
let run-eufon = pkgs.writeScript "run-eufon" ''
#!${pkgs.bash}/bin/bash
source ${config.system.build.setEnvironment}
${pkgs.dbus}/bin/dbus-run-session /home/dan/src/eufon/run.sh
${pkgs.dbus}/bin/dbus-run-session ${eufon}/bin/eufon
systemd-cat echo "dbus-run-session $?"
'';
in {
WorkingDirectory = "/home/dan/src/eufon";
WorkingDirectory = "${eufon}";
TTYPath = "/dev/tty2";
TTYReset = "yes";
TTYVHangup = "yes";
@ -52,7 +54,13 @@
environment.systemPackages = with pkgs; [
git
];
networking.networkmanager.enable = true;
boot.postBootCommands = lib.mkOrder (-1) ''
brightness=4000
echo "Setting brightness to $brightness"
echo $brightness > /sys/class/backlight/wled/brightness
'';
services.logind.extraConfig = ''
HandlePowerKey=ignore
'';