From a629f928270f3e945938f37439ff69936b6f948d Mon Sep 17 00:00:00 2001 From: Donovan Glover Date: Sat, 15 Jun 2024 10:46:45 -0400 Subject: [PATCH] meta: Revert combining mobile-nixos flake This was causing a lot of issues unfortunately presumably due to things not working with the aarch64 PinePhone system. Random errors like "expected string 'D'" were common and I'd rather use a separate flake to make things easier to debug and keep evaluation times to a minimum. --- laptop.nix => default.nix | 0 flake.lock | 17 ----- flake.nix | 37 ++------- modules/desktop.nix | 37 ++------- modules/system.nix | 18 +---- phone.nix | 19 ----- phone/configuration.nix | 75 +++++++++++++++++++ phone/flake.lock | 44 +++++++++++ phone/flake.nix | 29 +++++++ .../hardware-configuration.nix | 3 +- phone/phosh.nix | 39 ++++++++++ 11 files changed, 204 insertions(+), 114 deletions(-) rename laptop.nix => default.nix (100%) delete mode 100644 phone.nix create mode 100644 phone/configuration.nix create mode 100644 phone/flake.lock create mode 100644 phone/flake.nix rename hardware/phone.nix => phone/hardware-configuration.nix (78%) create mode 100644 phone/phosh.nix diff --git a/laptop.nix b/default.nix similarity index 100% rename from laptop.nix rename to default.nix diff --git a/flake.lock b/flake.lock index 11632065..511cec6f 100644 --- a/flake.lock +++ b/flake.lock @@ -183,22 +183,6 @@ "type": "github" } }, - "mobile-nixos": { - "flake": false, - "locked": { - "lastModified": 1715627339, - "narHash": "sha256-HJ6V7hc64iBqXlZ8kH4sXmUzPH+0Hn6wYURmZmL5LFk=", - "owner": "NixOS", - "repo": "mobile-nixos", - "rev": "655c8830d5fe2eae79c8fc0bab8033b34c8456eb", - "type": "github" - }, - "original": { - "owner": "NixOS", - "repo": "mobile-nixos", - "type": "github" - } - }, "nixpkgs": { "locked": { "lastModified": 1718297587, @@ -218,7 +202,6 @@ "root": { "inputs": { "home-manager": "home-manager", - "mobile-nixos": "mobile-nixos", "nixpkgs": "nixpkgs", "sakaya": "sakaya", "stylix": "stylix" diff --git a/flake.nix b/flake.nix index 1cebe3a6..b4ce676e 100644 --- a/flake.nix +++ b/flake.nix @@ -19,14 +19,9 @@ url = "github:donovanglover/sakaya"; inputs.nixpkgs.follows = "nixpkgs"; }; - - mobile-nixos = { - url = "github:NixOS/mobile-nixos"; - flake = false; - }; }; - outputs = { self, nixpkgs, mobile-nixos, ... } @ attrs: + outputs = { self, nixpkgs, ... } @ attrs: let inherit (nixpkgs.lib) nixosSystem; inherit (nixpkgs.legacyPackages.x86_64-linux) nixpkgs-fmt callPackage; @@ -52,10 +47,7 @@ name = if file == "laptop.nix" then "nixos" - else - if file == "phone.nix" - then "mobile-nixos" - else replaceStrings [ ".nix" ] [ "" ] file; + else replaceStrings [ ".nix" ] [ "" ] file; value = if directory == "packages" then callPackage ./${directory}/${file} { } @@ -72,27 +64,12 @@ then nixosSystem { - system = - if file == "phone.nix" - then "aarch64-linux" - else "x86_64-linux"; + system = "x86_64-linux"; specialArgs = attrs // { nix-config = self; }; - modules = - [ - ./${file} - ./${directory}/${file} - ] ++ nixpkgs.lib.optionals (file == "phone.nix") [ - (import "${mobile-nixos}/lib/configuration.nix" { - device = "pine64-pinephone"; - }) - - { - mobile.beautification = { - silentBoot = nixpkgs.lib.mkDefault true; - splash = nixpkgs.lib.mkDefault true; - }; - } - ]; + modules = [ + ./. + ./${directory}/${file} + ]; } else import ./${directory}/${file}; }) diff --git a/modules/desktop.nix b/modules/desktop.nix index 93d5fd5c..9c96519e 100644 --- a/modules/desktop.nix +++ b/modules/desktop.nix @@ -3,7 +3,7 @@ let inherit (lib) mkEnableOption mkIf mkMerge mkOption; inherit (lib.types) str float int; - inherit (config.modules.system) username phone; + inherit (config.modules.system) username; 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,7 +15,6 @@ in imports = attrValues { inherit (nix-config.inputs.home-manager.nixosModules) home-manager; inherit (nix-config.inputs.stylix.nixosModules) stylix; - }; options.modules.desktop = { @@ -42,22 +41,11 @@ in }; config = { - hardware = { - opengl.driSupport32Bit = mkIf (!phone) true; - - pulseaudio = mkIf phone { - enable = true; - package = pkgs.pulseaudioFull; - }; - - bluetooth.enable = mkIf phone true; - sensor.iio.enable = mkIf phone true; - }; + hardware.opengl.driSupport32Bit = true; programs = { - hyprland.enable = mkIf (!container && !phone) true; + hyprland.enable = mkIf (!container) true; cdemu.enable = true; - calls.enable = mkIf phone true; thunar = { enable = true; @@ -68,7 +56,7 @@ in }; }; - i18n.inputMethod = mkIf (!phone) { + i18n.inputMethod = { enabled = "fcitx5"; fcitx5 = { @@ -86,15 +74,9 @@ in xserver = mkIf (!container || graphical) { enable = true; excludePackages = [ pkgs.xterm ]; - - desktopManager.phosh = mkIf phone { - enable = true; - user = username; - group = "users"; - }; }; - pipewire = mkIf (!phone) { + pipewire = { enable = true; alsa = { @@ -105,7 +87,7 @@ in pulse.enable = true; }; - greetd = mkIf (!container && !phone) { + greetd = mkIf (!container) { enable = true; restart = false; @@ -151,13 +133,6 @@ in ; })) - (mkIf phone (attrValues { - inherit (pkgs) - chatty - megapixels - ; - })) - (attrValues { inherit (pkgs) anki kanjidraw pulseaudio glib; inherit (nix-config.inputs.sakaya.packages.${pkgs.system}) sakaya; diff --git a/modules/system.nix b/modules/system.nix index 303382b1..3216d33e 100644 --- a/modules/system.nix +++ b/modules/system.nix @@ -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 phone; + inherit (cfg) username iHaveLotsOfRam hashedPassword mullvad allowSRB2Port allowDevPort noRoot postgres; inherit (builtins) attrValues; cfg = config.modules.system; @@ -46,8 +46,6 @@ in iHaveLotsOfRam = mkEnableOption "tmpfs on /tmp"; - phone = mkEnableOption "PinePhone support"; - hostName = mkOption { type = str; default = "nixos"; @@ -125,19 +123,7 @@ in isNormalUser = true; uid = 1000; password = mkIf (hashedPassword == null && !noRoot) username; - extraGroups = - if noRoot - then [ ] - else - if phone - then [ - "dialout" - "feedbackd" - "networkmanager" - "video" - "wheel" - ] - else [ "wheel" "networkmanager" ]; + extraGroups = if noRoot then [ ] else [ "wheel" "networkmanager" ]; }; }; diff --git a/phone.nix b/phone.nix deleted file mode 100644 index c2d668f4..00000000 --- a/phone.nix +++ /dev/null @@ -1,19 +0,0 @@ -{ self, pkgs, ... }: - -let - inherit (builtins) attrValues; -in -{ - imports = attrValues self.nixosModules; - nixpkgs.overlays = attrValues self.overlays; - home-manager.sharedModules = attrValues self.homeManagerModules; - environment.systemPackages = attrValues self.packages.${pkgs.system}; - - modules = { - system = { - phone = true; - hostName = "mobile-nixos"; - stateVersion = "23.11"; - }; - }; -} diff --git a/phone/configuration.nix b/phone/configuration.nix new file mode 100644 index 00000000..400dad3f --- /dev/null +++ b/phone/configuration.nix @@ -0,0 +1,75 @@ +{ pkgs, ... }: + +{ + environment.systemPackages = with pkgs; [ + neovim + fish + yazi + bat + w3m + librewolf + git + htop + gnupg + mpv + ncmpcpp + pqiv + qutebrowser + starship + eza + fd + fzf + ripgrep + yt-dlp + neofetch + genact + zellij + p7zip + unar + ]; + + programs.fish.enable = true; + programs.neovim.enable = true; + users.defaultUserShell = pkgs.fish; + environment.shells = [ pkgs.fish ]; + + networking = { + hostName = "mobile-nixos"; + wireless.enable = false; + networkmanager.enable = true; + }; + + hardware = { + pulseaudio = { + enable = true; + package = pkgs.pulseaudioFull; + }; + + bluetooth.enable = true; + }; + + powerManagement.enable = true; + + zramSwap.enable = true; + + nix.settings.experimental-features = [ "nix-command" "flakes" "repl-flake" ]; + + services.xserver.desktopManager.phosh = { + user = "user"; + }; + + users.users."user" = { + isNormalUser = true; + description = "User"; + password = "user"; + extraGroups = [ + "dialout" + "feedbackd" + "networkmanager" + "video" + "wheel" + ]; + }; + + system.stateVersion = "23.11"; +} diff --git a/phone/flake.lock b/phone/flake.lock new file mode 100644 index 00000000..b15768bf --- /dev/null +++ b/phone/flake.lock @@ -0,0 +1,44 @@ +{ + "nodes": { + "mobile-nixos": { + "flake": false, + "locked": { + "lastModified": 1715627339, + "narHash": "sha256-HJ6V7hc64iBqXlZ8kH4sXmUzPH+0Hn6wYURmZmL5LFk=", + "owner": "NixOS", + "repo": "mobile-nixos", + "rev": "655c8830d5fe2eae79c8fc0bab8033b34c8456eb", + "type": "github" + }, + "original": { + "owner": "NixOS", + "repo": "mobile-nixos", + "type": "github" + } + }, + "nixpkgs": { + "locked": { + "lastModified": 1718160348, + "narHash": "sha256-9YrUjdztqi4Gz8n3mBuqvCkMo4ojrA6nASwyIKWMpus=", + "owner": "NixOS", + "repo": "nixpkgs", + "rev": "57d6973abba7ea108bac64ae7629e7431e0199b6", + "type": "github" + }, + "original": { + "owner": "NixOS", + "ref": "nixos-unstable", + "repo": "nixpkgs", + "type": "github" + } + }, + "root": { + "inputs": { + "mobile-nixos": "mobile-nixos", + "nixpkgs": "nixpkgs" + } + } + }, + "root": "root", + "version": 7 +} diff --git a/phone/flake.nix b/phone/flake.nix new file mode 100644 index 00000000..1eff9679 --- /dev/null +++ b/phone/flake.nix @@ -0,0 +1,29 @@ +{ + inputs = { + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; + + mobile-nixos = { + url = "github:NixOS/mobile-nixos"; + flake = false; + }; + }; + + outputs = { self, nixpkgs, mobile-nixos } @ attrs: + { + nixosConfigurations = { + mobile-nixos = nixpkgs.lib.nixosSystem { + system = "aarch64-linux"; + specialArgs = attrs; + modules = [ + (import "${mobile-nixos}/lib/configuration.nix" { + device = "pine64-pinephone"; + }) + + ./configuration.nix + ./hardware-configuration.nix + ./phosh.nix + ]; + }; + }; + }; +} diff --git a/hardware/phone.nix b/phone/hardware-configuration.nix similarity index 78% rename from hardware/phone.nix rename to phone/hardware-configuration.nix index c540ef91..36782500 100644 --- a/hardware/phone.nix +++ b/phone/hardware-configuration.nix @@ -1,4 +1,5 @@ -{ lib, ... }: +# NOTE: this file was generated by the Mobile NixOS installer. +{ config, lib, pkgs, ... }: { fileSystems = { diff --git a/phone/phosh.nix b/phone/phosh.nix new file mode 100644 index 00000000..bbeb4368 --- /dev/null +++ b/phone/phosh.nix @@ -0,0 +1,39 @@ +# +# This file represents safe opinionated defaults for a basic Phosh system. +# +# NOTE: this file and any it imports **have** to be safe to import from +# an end-user's config. +# +{ config, lib, pkgs, options, ... }: + +{ + 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. + ''; + } + ]; +}