From e8e3b46207b6295671be4872b161316f8e30e289 Mon Sep 17 00:00:00 2001 From: Samuel Dionne-Riel Date: Tue, 24 Sep 2019 22:57:43 -0400 Subject: [PATCH] examples/demo: inits a demo configuration for a system --- examples/demo/configuration.nix | 107 ++++++++++++++++++++++++++++++++ examples/demo/default.nix | 5 ++ 2 files changed, 112 insertions(+) create mode 100644 examples/demo/configuration.nix diff --git a/examples/demo/configuration.nix b/examples/demo/configuration.nix new file mode 100644 index 00000000..d45d5b82 --- /dev/null +++ b/examples/demo/configuration.nix @@ -0,0 +1,107 @@ +{ config, lib, pkgs, ... }: + +let + inherit (lib) mkForce; +in + { + imports = [ + ../../profiles/installer.nix + ]; + disabledModules = [ + + + ]; + + config = lib.mkMerge [ + { + + services.xserver = { + enable = true; + + libinput.enable = true; + videoDrivers = [ "fbdev" ]; + + # xfce has been chosen mainly because it is light, and quick to start. + # FIXME: Find a better demo environment. + desktopManager.xfce.enable = true; + + # Automatically login as nixos. + displayManager.slim = { + enable = true; + defaultUser = "nixos"; + autoLogin = true; + }; + + }; + + powerManagement.enable = true; + hardware.pulseaudio.enable = true; + + environment.systemPackages = with pkgs; [ + firefox + sgtpuzzles + hard-reboot + hard-shutdown + ]; + + # 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; + } + ]; +} diff --git a/examples/demo/default.nix b/examples/demo/default.nix index 9e465a35..469f5aac 100644 --- a/examples/demo/default.nix +++ b/examples/demo/default.nix @@ -1,10 +1,15 @@ { device ? null }: let + system-build = import ../../. { + inherit device; + configuration = [ (import ./configuration.nix) ]; + }; burn-tool-build = import ../../. { inherit device; configuration = [ (import ./android-burn-tool.nix) ]; }; in { + inherit (system-build.build) android-bootimg android-device; android-burn-tool = burn-tool-build.build.android-bootimg; }