From 46c858faa0954bb2f3ac17d6f7a88540c043ac8d Mon Sep 17 00:00:00 2001 From: kiana-S Date: Sat, 7 Jan 2023 20:54:12 -0500 Subject: [PATCH] Add mobile support (PinePhone Pro) --- config/config.nix | 18 +++++++++++---- flake.nix | 26 +++++++++++++++++++++ hardware-configuration/mobile.nix | 12 ++++++++++ mobile/home-manager.nix | 38 +++++++++++++++++++++++++++++++ 4 files changed, 90 insertions(+), 4 deletions(-) create mode 100644 hardware-configuration/mobile.nix create mode 100644 mobile/home-manager.nix diff --git a/config/config.nix b/config/config.nix index 48d1de4..7e2c11d 100644 --- a/config/config.nix +++ b/config/config.nix @@ -1,6 +1,7 @@ { config, pkgs, nur, username, fullname, ... }: let - inherit (config.custom) platform; + inherit (config) platform; + isMobile = platform == "mobile"; hashedPassword = if platform == "desktop" then @@ -43,7 +44,8 @@ in users.users.${username} = { isNormalUser = true; description = fullname; - extraGroups = [ "wheel" "networkmanager" ]; # Enable ‘sudo’ for the user. + extraGroups = [ "wheel" "networkmanager" ] + ++ lib.optionals isMobile [ "dialout" "feedbackd" "video" ]; shell = pkgs.fish; inherit hashedPassword; }; @@ -66,8 +68,8 @@ in fontconfig = { enable = true; defaultFonts = { - serif = [ "Noto Serif" ]; - sansSerif = [ "Noto Sans" ]; + serif = lib.optional (!isMobile) "Noto Serif"; + sansSerif = lib.optional (!isMobile) "Noto Sans"; monospace = [ "VictorMono" ]; }; }; @@ -86,3 +88,11 @@ in # (e.g. man configuration.nix or on https://nixos.org/nixos/options.html). system.stateVersion = "21.11"; # Did you read the comment? } +// lib.mkIf (platform == "mobile") { + + hardware.bluetooth.enable = true; + hardware.pulseaudio.package = pkgs.pulseAudioFull; + zramSwap.enable = true; + + services.xserver.desktopManager.phosh.user = username; +} diff --git a/flake.nix b/flake.nix index ef0439a..a1405b1 100644 --- a/flake.nix +++ b/flake.nix @@ -3,7 +3,10 @@ description = "System conf"; inputs = { nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; nur.url = "github:nix-community/NUR"; + nixos-hardware.url = "github:NixOS/nixos-hardware"; + mobile-nixos.url = "github:wentam/mobile-nixos/ppp-pr"; + mobile-nixos.flake = false; home-manager.url = "github:nix-community/home-manager/master"; home-manager.inputs.nixpkgs.follows = "nixpkgs"; @@ -66,6 +69,29 @@ outputs = { self, } ]; }; + + "${username}-mobile" = lib.makeOverridable lib.nixosSystem { + inherit system; + modules = [ + ./config + + { _module.args = moduleArgs; + platform = "mobile"; } + ./platform.nix + ./hardware-configuration/mobile.nix + home-manager.nixosModules.home-manager + (import ${mobile-nixos}/lib/configuration.nix { device = "pine64-pinephonepro"; }) + ${mobile-nixos}/examples/phosh/phosh.nix + { + home-manager.users.${username} = import ./mobile/home-manager.nix; + + home-manager.useGlobalPkgs = true; + home-manager.useUserPackages = true; + home-manager.sharedModules = [ ./platform.nix { platform = "mobile"; } ]; + home-manager.extraSpecialArgs = moduleArgs; + } + ]; + }; }; }; } diff --git a/hardware-configuration/mobile.nix b/hardware-configuration/mobile.nix new file mode 100644 index 0000000..43a4cd5 --- /dev/null +++ b/hardware-configuration/mobile.nix @@ -0,0 +1,12 @@ +# Do not modify this file! It was generated by ‘nixos-generate-config’ +# and may be overwritten by future invocations. Please make changes +# to /etc/nixos/configuration.nix instead. +{ config, lib, pkgs, ... }: +{ + fileSystems."/" = + { device = "/dev/disk/by-uuid/0e34be6f-a042-433e-bcfc-9df254a571c3"; + fsType = "ext4"; + }; + + nix.settings.max-jobs = lib.mkDefault 3; +} diff --git a/mobile/home-manager.nix b/mobile/home-manager.nix new file mode 100644 index 0000000..a4116ad --- /dev/null +++ b/mobile/home-manager.nix @@ -0,0 +1,38 @@ +{ config, pkgs, username, fullname, ... }: +{ + home.username = username; + home.homeDirectory = "/home/" + username; + + home.stateVersion = "22.11"; + + imports = [ ../home-manager/shell ]; + + xdg.enable = true; + xdg.userDirs.enable = true; + + programs.git = { + enable = true; + userName = fullname; + userEmail = "kiana.a.sheibani@gmail.com"; + + extraConfig = { + credential.helper = "store"; + git.allowForcePush = true; + init.defaultBranch = "main"; + + user.signingkey = "6CB106C25E86A9F7"; + commit.gpgsign = true; + }; + }; + + programs.gpg.enable = true; + services.gpg-agent = { + enable = true; + enableSshSupport = true; + pinentryFlavor = "curses"; + extraConfig = '' + allow-emacs-pinentry + allow-loopback-pinentry + ''; + }; +}