meta: Merge phone module with system / desktop

This commit is contained in:
Donovan Glover 2024-06-14 01:21:06 -04:00
parent 7afc6b27f8
commit 05b14fa423
No known key found for this signature in database
GPG Key ID: EA7408A77AE1BE65
3 changed files with 47 additions and 58 deletions

View File

@ -3,7 +3,7 @@
let
inherit (lib) mkEnableOption mkIf mkMerge mkOption;
inherit (lib.types) str float int;
inherit (config.modules.system) username;
inherit (config.modules.system) username phone;
inherit (cfg) bloat gnome plasma container theme opacity fontSize graphical;
inherit (nix-config.packages.${pkgs.system}) aleo-fonts;
inherit (pkgs) phinger-cursors noto-fonts-cjk-sans maple-mono noto-fonts-emoji;
@ -15,6 +15,7 @@ in
imports = attrValues {
inherit (nix-config.inputs.home-manager.nixosModules) home-manager;
inherit (nix-config.inputs.stylix.nixosModules) stylix;
};
options.modules.desktop = {
@ -41,11 +42,22 @@ in
};
config = {
hardware.opengl.driSupport32Bit = true;
hardware = {
opengl.driSupport32Bit = true;
pulseaudio = mkIf phone {
enable = true;
package = pkgs.pulseaudioFull;
};
bluetooth.enable = mkIf phone true;
sensor.iio.enable = mkIf phone true;
};
programs = {
hyprland.enable = mkIf (!container) true;
hyprland.enable = mkIf (!container && !phone) true;
cdemu.enable = true;
calls.enable = mkIf phone true;
thunar = {
enable = true;
@ -56,7 +68,7 @@ in
};
};
i18n.inputMethod = {
i18n.inputMethod = mkIf (!phone) {
enabled = "fcitx5";
fcitx5 = {
@ -74,9 +86,15 @@ in
xserver = mkIf (!container || graphical) {
enable = true;
excludePackages = [ pkgs.xterm ];
desktopManager.phosh = mkIf phone {
enable = true;
user = username;
group = "users";
};
};
pipewire = {
pipewire = mkIf (!phone) {
enable = true;
alsa = {
@ -87,7 +105,7 @@ in
pulse.enable = true;
};
greetd = mkIf (!container) {
greetd = mkIf (!container && !phone) {
enable = true;
restart = false;
@ -133,6 +151,13 @@ in
;
}))
(mkIf phone (attrValues {
inherit (pkgs)
chatty
megapixels
;
}))
(attrValues {
inherit (pkgs) anki kanjidraw pulseaudio glib;
inherit (nix-config.inputs.sakaya.packages.${pkgs.system}) sakaya;

View File

@ -1,50 +0,0 @@
{ lib, pkgs, options, config, mobile-nixos, ... }:
let
inherit (lib) mkEnableOption mkIf;
cfg = config.modules.phone;
in
{
imports = [
(import "${mobile-nixos}/lib/configuration.nix" {
device = "pine64-pinephone";
})
];
options.modules.phone = {
enable = mkEnableOption "PinePhone support";
};
config = mkIf cfg.enable {
mobile.beautification = {
silentBoot = lib.mkDefault true;
splash = lib.mkDefault true;
};
services.xserver.desktopManager.phosh = {
enable = true;
group = "users";
};
programs.calls.enable = true;
environment.systemPackages = with pkgs; [
chatty # IM and SMS
epiphany # Web browser
gnome-console # Terminal
megapixels # Camera
];
hardware.sensor.iio.enable = true;
assertions = [
{ assertion = options.services.xserver.desktopManager.phosh.user.isDefined;
message = ''
`services.xserver.desktopManager.phosh.user` not set.
When importing the phosh configuration in your system, you need to set `services.xserver.desktopManager.phosh.user` to the username of the session user.
'';
}
];
};
}

View File

@ -3,7 +3,7 @@
let
inherit (lib) mkOption mkEnableOption mkIf singleton;
inherit (lib.types) nullOr str listOf;
inherit (cfg) username iHaveLotsOfRam hashedPassword mullvad allowSRB2Port allowDevPort noRoot postgres;
inherit (cfg) username iHaveLotsOfRam hashedPassword mullvad allowSRB2Port allowDevPort noRoot postgres phone;
inherit (builtins) attrValues;
cfg = config.modules.system;
@ -46,6 +46,8 @@ in
iHaveLotsOfRam = mkEnableOption "tmpfs on /tmp";
phone = mkEnableOption "PinePhone support";
hostName = mkOption {
type = str;
default = "nixos";
@ -123,7 +125,19 @@ in
isNormalUser = true;
uid = 1000;
password = mkIf (hashedPassword == null && !noRoot) username;
extraGroups = if noRoot then [ ] else [ "wheel" "networkmanager" ];
extraGroups =
if noRoot
then [ ]
else
if phone
then [
"dialout"
"feedbackd"
"networkmanager"
"video"
"wheel"
]
else [ "wheel" "networkmanager" ];
};
};