2019-09-25 05:57:43 +03:00
|
|
|
{ config, lib, pkgs, ... }:
|
|
|
|
|
|
|
|
let
|
|
|
|
inherit (lib) mkForce;
|
2019-10-10 07:38:03 +03:00
|
|
|
system_type = config.mobile.system.type;
|
2019-10-06 07:08:44 +03:00
|
|
|
|
|
|
|
# Why copy them all?
|
|
|
|
# Because otherwise the wallpaper picker will default to /nix/store as a path
|
|
|
|
# and this could get messy with the amazing amount of files there are in there.
|
|
|
|
# Why copy only pngs?
|
|
|
|
# Rendering of `svg` is hard! Not that it's costly in cpu time, but that the
|
|
|
|
# rendering might not be as expected depending on what renders it.
|
|
|
|
# The SVGs in that directory are used as an authoring format files, not files
|
|
|
|
# to be used as they are. They need to be pre-rendered.
|
|
|
|
wallpapers = pkgs.runCommandNoCC "wallpapers" {} ''
|
|
|
|
mkdir -p $out/
|
|
|
|
cp ${../../artwork/wallpapers}/*.png $out/
|
|
|
|
'';
|
2019-09-25 05:57:43 +03:00
|
|
|
in
|
2019-10-06 09:32:21 +03:00
|
|
|
{
|
|
|
|
imports = [
|
|
|
|
../../profiles/installer.nix
|
|
|
|
];
|
|
|
|
|
|
|
|
disabledModules = [
|
|
|
|
<nixpkgs/nixos/modules/installer/cd-dvd/iso-image.nix>
|
|
|
|
<nixpkgs/nixos/modules/installer/cd-dvd/installation-cd-base.nix>
|
|
|
|
];
|
2019-09-25 05:57:43 +03:00
|
|
|
|
|
|
|
config = lib.mkMerge [
|
|
|
|
{
|
|
|
|
|
2019-10-09 03:20:15 +03:00
|
|
|
boot.growPartition = lib.mkDefault true;
|
|
|
|
|
2019-09-25 05:57:43 +03:00
|
|
|
services.xserver = {
|
|
|
|
enable = true;
|
|
|
|
|
|
|
|
libinput.enable = true;
|
2019-10-10 07:38:03 +03:00
|
|
|
videoDrivers = lib.mkDefault [ "fbdev" ];
|
2019-09-25 05:57:43 +03:00
|
|
|
|
|
|
|
# Automatically login as nixos.
|
2019-11-27 21:24:48 +03:00
|
|
|
displayManager.lightdm = {
|
2019-09-25 05:57:43 +03:00
|
|
|
enable = true;
|
2019-11-27 21:24:48 +03:00
|
|
|
autoLogin = {
|
|
|
|
enable = true;
|
|
|
|
user = "nixos";
|
|
|
|
};
|
2019-09-25 05:57:43 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
};
|
|
|
|
powerManagement.enable = true;
|
|
|
|
hardware.pulseaudio.enable = true;
|
|
|
|
|
|
|
|
environment.systemPackages = with pkgs; [
|
2019-10-06 09:32:21 +03:00
|
|
|
(writeShellScriptBin "firefox" ''
|
|
|
|
export MOZ_USE_XINPUT2=1
|
|
|
|
exec ${pkgs.firefox}/bin/firefox "$@"
|
|
|
|
'')
|
2019-09-25 05:57:43 +03:00
|
|
|
sgtpuzzles
|
|
|
|
hard-reboot
|
|
|
|
hard-shutdown
|
2019-10-06 07:08:44 +03:00
|
|
|
];
|
|
|
|
|
2019-09-25 05:57:43 +03:00
|
|
|
# Hacky way to setup an initial brightness
|
|
|
|
# TODO: better factor this out...
|
|
|
|
mobile.boot.stage-1.initFramebuffer = ''
|
|
|
|
brightness=10
|
|
|
|
echo "Setting brightness to $brightness"
|
|
|
|
if [ -e /sys/class/backlight/backlight/brightness ]; then
|
|
|
|
echo $(($(cat /sys/class/backlight/backlight/max_brightness) * brightness / 100)) > /sys/class/backlight/backlight/brightness
|
|
|
|
elif [ -e /sys/class/leds/lcd-backlight/max_brightness ]; then
|
|
|
|
echo $(($(cat /sys/class/leds/lcd-backlight/max_brightness) * brightness / 100)) > /sys/class/leds/lcd-backlight/brightness
|
|
|
|
elif [ -e /sys/class/leds/lcd-backlight/brightness ]; then
|
|
|
|
# Assumes max brightness is 100... probably wrong, but good enough, eh.
|
|
|
|
echo $brightness > /sys/class/leds/lcd-backlight/brightness
|
|
|
|
fi
|
|
|
|
'';
|
|
|
|
|
|
|
|
# Puts some icons on the desktop.
|
|
|
|
system.activationScripts.fillDesktop = let
|
|
|
|
minesDesktopFile = pkgs.writeScript "mines.desktop" ''
|
|
|
|
[Desktop Entry]
|
|
|
|
Version=1.0
|
|
|
|
Type=Application
|
|
|
|
Name=Mines
|
|
|
|
Exec=${pkgs.sgtpuzzles}/bin/sgt-puzzle-mines
|
|
|
|
'';
|
|
|
|
|
|
|
|
homeDir = "/home/nixos/";
|
|
|
|
desktopDir = homeDir + "Desktop/";
|
|
|
|
|
|
|
|
in ''
|
|
|
|
mkdir -p ${desktopDir}
|
|
|
|
chown nixos ${homeDir} ${desktopDir}
|
|
|
|
|
|
|
|
ln -sfT ${minesDesktopFile} ${desktopDir + "mines.desktop"}
|
|
|
|
'';
|
|
|
|
|
|
|
|
# FIXME : Stop relying on initrd for `ssh` via USB.
|
|
|
|
networking.networkmanager.enable = true;
|
|
|
|
networking.networkmanager.unmanaged = [ "rndis0" "usb0" ];
|
|
|
|
|
|
|
|
# Setup USB gadget networking in initrd...
|
|
|
|
mobile.boot.stage-1.networking.enable = true;
|
|
|
|
#mobile.boot.stage-1.ssh.enable = true;
|
|
|
|
|
|
|
|
# Start SSH by default...
|
|
|
|
systemd.services.sshd.wantedBy = lib.mkOverride 10 [ "multi-user.target" ];
|
|
|
|
services.openssh.permitRootLogin = lib.mkForce "yes";
|
|
|
|
|
|
|
|
# Forcibly set a password on users...
|
|
|
|
# FIXME: highly insecure!
|
|
|
|
# FIXME: Figure out why this breaks...
|
|
|
|
#services.openssh.extraConfig = "PermitEmptyPasswords yes";
|
|
|
|
users.users.nixos.password = "nixos";
|
|
|
|
users.users.root.password = "nixos";
|
|
|
|
|
|
|
|
# Okay, systemd-udev-settle times out... no idea why yet...
|
|
|
|
# Though, it seems fine to simply disable it.
|
|
|
|
# FIXME : figure out why systemd-udev-settle doesn't work.
|
|
|
|
systemd.services.systemd-udev-settle.enable = false;
|
|
|
|
}
|
2019-10-06 09:32:21 +03:00
|
|
|
|
|
|
|
# Customized XFCE environment
|
|
|
|
{
|
|
|
|
services.xserver = {
|
|
|
|
desktopManager.xfce.enable = true;
|
|
|
|
};
|
|
|
|
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
adapta-gtk-theme
|
2019-10-09 08:14:06 +03:00
|
|
|
breeze-icons
|
2019-10-06 09:32:21 +03:00
|
|
|
];
|
|
|
|
|
|
|
|
fonts.fonts = with pkgs; [
|
|
|
|
aileron
|
|
|
|
];
|
|
|
|
|
|
|
|
environment.etc."xdg/xfce4" = {
|
|
|
|
# TODO: DPI/size settings, so that a DPI can be derived from the device info.
|
|
|
|
source = pkgs.runCommandNoCC "xfce4-defaults" {} ''
|
|
|
|
cp -r ${./xdg/xfce4} $out
|
|
|
|
wallpaper="${wallpapers}/mobile-nixos-19.09.png"
|
|
|
|
substituteInPlace $out/xfconf/xfce-perchannel-xml/xfce4-desktop.xml \
|
|
|
|
--subst-var wallpaper
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
# Replace xfwm with awesome with a custom config.
|
|
|
|
{
|
|
|
|
services.xserver = {
|
|
|
|
desktopManager.xfce.enableXfwm = false;
|
|
|
|
desktopManager.xfce.extraSessionCommands = ''
|
|
|
|
awesome &
|
|
|
|
'';
|
|
|
|
};
|
|
|
|
|
2019-10-08 02:59:20 +03:00
|
|
|
environment.systemPackages = with pkgs;
|
|
|
|
let
|
|
|
|
close = writeShellScript "action-close-window" ''
|
|
|
|
awesome-client '
|
|
|
|
local awful = require("awful");
|
|
|
|
local c = awful.client.focus.filter(client.focus)
|
|
|
|
if c then
|
|
|
|
c:kill()
|
|
|
|
end
|
|
|
|
'
|
|
|
|
'';
|
|
|
|
in
|
|
|
|
[
|
2019-10-06 09:32:21 +03:00
|
|
|
awesome
|
2019-10-08 02:59:20 +03:00
|
|
|
(runCommandNoCC "awesome-actions" {} ''
|
|
|
|
mkdir -vp $out/share/applications/
|
|
|
|
(cd $out/share/applications/
|
|
|
|
cat > awesome-close.desktop <<EOF
|
|
|
|
[Desktop Entry]
|
|
|
|
Name=Close active window
|
|
|
|
Exec=${close}
|
|
|
|
Icon=process-stop
|
|
|
|
EOF
|
|
|
|
)
|
|
|
|
''/* TODO: better icon than process-stop */)
|
2019-10-06 09:32:21 +03:00
|
|
|
];
|
|
|
|
|
|
|
|
environment.etc."xdg/awesome" = {
|
|
|
|
source = ./xdg/awesome;
|
|
|
|
};
|
2019-10-09 08:14:16 +03:00
|
|
|
|
|
|
|
services.unclutter.enable = true;
|
2019-10-06 09:32:21 +03:00
|
|
|
}
|
2019-10-07 06:25:02 +03:00
|
|
|
|
|
|
|
# Onboard on-screen keyboard
|
|
|
|
{
|
|
|
|
environment.systemPackages = with pkgs; [
|
|
|
|
onboard
|
|
|
|
];
|
2019-10-08 03:00:07 +03:00
|
|
|
environment.etc."xdg/autostart/onboard-boottime-configuration.desktop" = {
|
|
|
|
text = let script = pkgs.writeShellScript "onboard-boottime-configuration" ''
|
|
|
|
set -u
|
|
|
|
set -e
|
|
|
|
|
|
|
|
# A bit rude, but this ensures the keyboard always starts at a quarter
|
|
|
|
# of the resolution.
|
|
|
|
# onboard will not accept -s to set size with a docked keyboard.
|
|
|
|
height=$(( $( ${pkgs.xlibs.xwininfo}/bin/xwininfo -root | grep '^\s\+Height:' | cut -d':' -f2 ) / 4 ))
|
|
|
|
|
|
|
|
${pkgs.gnome3.dconf}/bin/dconf write /org/onboard/window/landscape/dock-height "$height" || :
|
|
|
|
${pkgs.gnome3.dconf}/bin/dconf write /org/onboard/window/portrait/dock-height "$height" || :
|
|
|
|
'';
|
|
|
|
in ''
|
|
|
|
[Desktop Entry]
|
|
|
|
Name=Onboard boot time configuration
|
|
|
|
Exec=${script}
|
|
|
|
X-XFCE-Autostart-Override=true
|
|
|
|
'';
|
|
|
|
};
|
2019-10-07 06:25:02 +03:00
|
|
|
environment.etc."xdg/autostart/onboard-autostart.desktop" = {
|
|
|
|
source = pkgs.runCommandNoCC "onboard-autostart.desktop" {} ''
|
|
|
|
cat "${pkgs.onboard}/etc/xdg/autostart/onboard-autostart.desktop" > $out
|
|
|
|
echo "X-XFCE-Autostart-Override=true" >> $out
|
2019-10-08 03:00:20 +03:00
|
|
|
substituteInPlace $out \
|
|
|
|
--replace "Icon=onboard" "Icon=input-keyboard"
|
2019-10-07 06:25:02 +03:00
|
|
|
'';
|
|
|
|
};
|
|
|
|
}
|
2019-10-10 07:38:03 +03:00
|
|
|
|
|
|
|
# FIXME : depthcharge is the wrong assumption.
|
|
|
|
# A better abstraction over the X11 stack is required within mobile-nixos.
|
|
|
|
# The qemu VM requires the fbdev one to work as expcted.
|
|
|
|
# The android devices may have hwcomposer stuff coming.
|
|
|
|
(lib.mkIf (system_type == "depthcharge") {
|
|
|
|
services.xserver = {
|
|
|
|
videoDrivers = [ "modesetting" ];
|
|
|
|
};
|
|
|
|
})
|
2019-09-25 05:57:43 +03:00
|
|
|
];
|
|
|
|
}
|