Compare commits

...

4 Commits
main ... phoen

Author SHA1 Message Date
Daniel Barlow 521c004726 some generally (I hope) useful config for the Pinephone 2022-07-01 22:14:51 +00:00
Daniel Barlow 160ca21afd nixos module to start kiwmi at boot
this is here for my convenience, I make no claims of practicality
or beauty (it uses nix-shell and hardcodes pathnames)
2022-07-01 22:10:12 +00:00
Daniel Barlow 0e20e4d261 only resize output when using wayland backend
surprisingly enough, real hardware complains
2022-07-01 22:09:00 +00:00
Daniel Barlow 7db61a7af0 use output width/height instead of hardcoding 2022-07-01 22:08:15 +00:00
6 changed files with 184 additions and 9 deletions

58
module.nix Normal file
View File

@ -0,0 +1,58 @@
{ config, lib, pkgs, ... }:
{
systemd.services."eufon" = {
wants = [
"systemd-machined.service"
"accounts-daemon.service"
"systemd-udev-settle.service"
"dbus.socket"
];
aliases = [ "display-manager.service" ];
after = [
"rc-local.service"
"systemd-machined.service"
"systemd-user-sessions.service"
"getty@tty2.service"
"plymouth-quit.service"
"plymouth-start.service"
"systemd-logind.service"
"systemd-udev-settle.service"
];
conflicts = [
"getty@tty2.service"
"plymouth-quit.service"
];
wantedBy = [ "multi-user.target" ];
serviceConfig =
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
systemd-cat echo "dbus-run-session $?"
'';
in {
WorkingDirectory = "/home/dan/src/eufon";
TTYPath = "/dev/tty2";
TTYReset = "yes";
TTYVHangup = "yes";
TTYVTDisallocate = "yes";
PAMName = "login";
StandardInput = "tty";
StandardError = "journal";
StandardOutput = "journal";
User = "dan";
ExecStart = run-eufon;
Restart = "always";
};
environment = {
NIX_PATH = "nixpkgs=${<nixpkgs>}";
};
};
environment.systemPackages = with pkgs; [
git
];
networking.networkmanager.enable = true;
services.logind.extraConfig = ''
HandlePowerKey=ignore
'';
}

59
pinephone.nix Normal file
View File

@ -0,0 +1,59 @@
{ config, lib, pkgs, ... }:
# configuration.nix contains settings applicable to _my_ pinephone
# pinephone.nix contains settings applicable to eufon on pinephones.
# module.nix contains settings applicable to eufon generally
{
config = {
powerManagement = {
enable = true;
cpuFreqGovernor = "ondemand";
};
mobile.boot.stage-1.firmware = [
config.mobile.device.firmware
];
hardware.sensor.iio.enable = true;
hardware.firmware = [ config.mobile.device.firmware ];
services.fwupd = {
enable = true;
};
environment.systemPackages =
let refresh-bootfs = (import ./refresh-bootfs.nix { inherit config pkgs lib; });
in with pkgs; [
dtc
file
refresh-bootfs
];
environment.etc."fwupd/remotes.d/testing.conf" = {
mode = "0644";
text = ''
[fwupd Remote]
Enabled=true
Title=Linux Vendor Firmware Service (testing)
MetadataURI=https://cdn.fwupd.org/downloads/firmware-testing.xml.gz
ReportURI=https://fwupd.org/lvfs/firmware/report
OrderBefore=lvfs,fwupd
AutomaticReports=false
ApprovalRequired=false
'';
};
nixpkgs = {
config.allowUnfreePredicate = pkg: builtins.elem (lib.getName pkg) [
"pine64-pinephone-firmware"
];
};
# boot.loader.generic-extlinux-compatible.enable = lib.mkForce true;
hardware.opengl = {
enable = true;
driSupport = true;
};
};
}

25
rc.fnl
View File

@ -24,36 +24,43 @@
pixels.height
(pixels:get_pixels))))
(fn resize-wayland-backend [output]
(when (string.find (output:name) "^WL-")
(output:set_mode 360 720 0)))
(kiwmi:on
"output"
(fn [output]
(output:set_mode 360 720 0)
(let [r (output:renderer)
(resize-wayland-backend output)
(let [[width height] (output:size)
r (output:renderer)
kill (texture-from-file r "close-window.png")
launch (texture-from-file r "launcher.png")
spinner (texture-from-file r "carousel.png")]
(output:on "render"
(fn [{: output : renderer}]
(let [bar-height 40
(let [bar-height (/ height 15)
matrix [1 0 0
0 1 0
0 0 1]]
(renderer:draw_rect :#00000077
0 (- 720 bar-height)
690 360 bar-height)
0 (- height bar-height)
width bar-height)
(renderer:draw_texture
kill
matrix
30 (- 720 bar-height)
30 (- height bar-height)
0.7)
(renderer:draw_texture
launch matrix
(- 180 (/ bar-height 2)) (- 720 bar-height)
launch
matrix
(- (/ width 2) (/ bar-height 2)) (- height bar-height)
0.7)
(renderer:draw_texture
spinner
matrix
(- 360 30 bar-height) (- 720 bar-height)
(- width 30 bar-height) (- height bar-height)
0.7)))))))
(fn kill-window []

43
refresh-bootfs.nix Normal file
View File

@ -0,0 +1,43 @@
{ config, pkgs, lib, ... }:
# nixos/mobile-nixos don't currently (June 2022) update the kernel and
# initrd used by the bootloader when nixos-rebuild is run. This is a
# workaround until they do. Mount your boot filesystem somewhere
# and run "refresh-bootfs /path/to/mounted/bootfs" after switching
# configuration
let
inherit (config.mobile.outputs) recovery stage-0;
inherit (pkgs) writeScriptBin buildPackages imageBuilder runCommandNoCC;
kernel = stage-0.mobile.boot.stage-1.kernel.package;
kernel_file = "${kernel}/${if kernel ? file then kernel.file else pkgs.stdenv.hostPlatform.linux-kernel.target}";
# bootscr = runCommandNoCC "boot.scr" {
# nativeBuildInputs = [
# buildPackages.ubootTools
# ];
# } ''
# mkimage -C none -A arm64 -T script -d {bootcmd} $out
# '';
in writeScriptBin "refresh-bootfs" ''
#!${pkgs.runtimeShell}
test -n "$1" || exit 1
test -d "$1" || exit 1
cd $1
test -f ./boot.scr || exit 1
mkdir -vp mobile-nixos/{boot,recovery}
(
cd mobile-nixos/boot
cp -v ${stage-0.mobile.outputs.initrd} stage-1
cp -v ${kernel_file} kernel
cp -vr ${kernel}/dtbs dtbs
)
(
cd mobile-nixos/recovery
cp -v ${recovery.mobile.outputs.initrd} stage-1
cp -v ${kernel_file} kernel
cp -vr ${kernel}/dtbs dtbs
)
# cp -v {bootscr} ./boot.scr
''

2
run.sh Normal file
View File

@ -0,0 +1,2 @@
#!/usr/bin/env bash
nix-shell --run "start_eufon"

View File

@ -5,5 +5,11 @@ in (p.overrideAttrs (o:{
shellHook = ''
export LUA_PATH=`lua -e 'print(package.path)'`
export LUA_CPATH=`lua -e 'print(package.cpath)'`
# this is a shell function mostly so that I can comment it out
# to experiment with starting sway or tinywl or something else
# to see how they behave if kiwmi is being weird
start_eufon(){
kiwmi -c init.lua;
}
'';
})).override { debug = true; }