diff --git a/clients/quadphone/cross-fixes.nix b/clients/quadphone/cross-fixes.nix new file mode 100644 index 0000000..f49d425 --- /dev/null +++ b/clients/quadphone/cross-fixes.nix @@ -0,0 +1,41 @@ +# Fixes for things that don't cross-compile (they run host binaries at build time). +{ + inputs, + ... +}: +{ + nixpkgs.overlays = [ + (final: prev: { + gnome = prev.gnome // { + nixos-gsettings-overrides = prev.gnome.nixos-gsettings-overrides.override { + glib = final.buildPackages.glib; + }; + }; + }) + ]; + + # The cache builder doesn't find gtk-query-immodules-3.0 when cross compiling, + # and GNOME Shell connects apps to IBus itself, so the GTK module isn't used anyway. + i18n.inputMethod.enableGtk3 = false; + + # nix-maid runs the host mustache-go at build time, swap in a copy of its core + # module that uses the build platform's one for that step. + # TODO: upstream (use pkgs.buildPackages.mustache-go in core.nix) + maid.sharedModules = + let + core = "${inputs.nix-maid}/src/maid/modules/core.nix"; + in + [ + { + disabledModules = [ core ]; + imports = [ + (builtins.toFile "nix-maid-core.nix" ( + builtins.replaceStrings + [ "import ../vars.nix" "lib.getExe pkgs.mustache-go" ] + [ "import ${inputs.nix-maid}/src/maid/vars.nix" "lib.getExe pkgs.buildPackages.mustache-go" ] + (builtins.readFile core) + )) + ]; + } + ]; +} diff --git a/clients/quadphone/cross.nix b/clients/quadphone/cross.nix new file mode 100644 index 0000000..fadc5b4 --- /dev/null +++ b/clients/quadphone/cross.nix @@ -0,0 +1,130 @@ +{ + inputs, + lib, + config, + ... +}: +let + cfg = config.quadphone; + host = config.nixpkgs.hostPlatform; + + otherOverlays = lib.init config.nixpkgs.overlays; + + # cache-only due to no binfmt + nativePkgs = import inputs.nixpkgs { + localSystem = host; + inherit (config.nixpkgs) config; + }; + + # Only used to detect which packages the other overlays change. + nativeOverlaid = import inputs.nixpkgs { + localSystem = host; + inherit (config.nixpkgs) config; + overlays = otherOverlays; + }; + + # The cross toolchain and bootstrapping must stay cross. + # Interpreters too: their package sets splice the interpreter from this set. + toolchainRegex = "(python[0-9]*(Minimal|Full)?|.*[sS]tdenv.*|glibc|libc|libcCross|gcc|libgcc|binutils.*|bintools.*|musl|linuxHeaders)"; + + drvPathOf = v: (builtins.tryEval v.drvPath).value or null; + tryGet = path: set: (builtins.tryEval (lib.attrByPath path null set)).value or null; + + useNative = + path: native: + let + name = lib.concatStringsSep "." path; + in + !(builtins.elem name cfg.crossPackages) + && builtins.match toolchainRegex name == null + && lib.isDerivation native + && lib.meta.availableOn host native + && (native.meta.license.free or true) + # Trivial builders (runCommand, buildEnv, ...) are never substituted + && (native.allowSubstitutes or true) != false + && (native.allowSubstitutes or true) != "" + # Not modified (directly or through a dependency) by another overlay + && drvPathOf native == drvPathOf (tryGet path nativeOverlaid); + + withCrossFunctions = + native: cross: + let + wrap = + n: arg: + let + r = native.${n} arg; + in + if lib.isDerivation r && drvPathOf r == drvPathOf native then + withCrossFunctions r (cross.${n} arg) + else + cross.${n} arg; + + isBuilder = n: builtins.match builderRegex n != null && !lib.elem n customisers; + in + # Attr names must only depend on native, forcing cross here can recurse. + native + // lib.genAttrs (lib.filter (n: native ? ${n}) customisers) wrap + // lib.genAttrs (lib.filter isBuilder (builtins.attrNames native)) (n: cross.${n}); + + builderRegex = "(pkgs|.*[pP]ackages|callPackage|(mk|build|with|wrap)([A-Z].*)?)"; + + customisers = [ + "override" + "overrideAttrs" + "overrideDerivation" + "overridePythonAttrs" + "overrideModAttrs" + ]; + + pick = + path: v: + if lib.isDerivation v then + let + native = tryGet path nativePkgs; + in + if useNative path native then withCrossFunctions native v else v + # Package sets like kdePackages, gnomeExtensions, lixPackageSets.lix_2_96 + else if builtins.length path <= 2 && builtins.isAttrs v && (v.recurseForDerivations or false) then + builtins.mapAttrs (name: pick (path ++ [ name ])) v + else + v; +in +{ + options.quadphone.crossPackages = lib.mkOption { + type = with lib.types; listOf str; + default = [ ]; + description = '' + Top-level attribute names that should always be cross-compiled instead of + substituted from the binary cache (i.e. ones that turn out not to be cached). + ''; + }; + + config = { + nixpkgs.buildPlatform = "x86_64-linux"; + + # Must be the last overlay, see otherOverlays. + nixpkgs.overlays = lib.mkOrder 10000 [ + ( + _: prev: + lib.optionalAttrs (prev.stdenv.hostPlatform.config != prev.stdenv.buildPlatform.config) { + stdenv = prev.overrideCC prev.stdenv ( + prev.stdenv.cc.override { + bintools = prev.stdenv.cc.bintools.override { + extraBuildCommands = '' + echo "-rpath-link ${nativePkgs.stdenv.cc.cc.lib}/lib" >> $out/nix-support/libc-ldflags + ''; + }; + } + ); + } + ) + ( + _: prev: + builtins.mapAttrs ( + name: v: + if prev.stdenv.hostPlatform.config == prev.stdenv.buildPlatform.config then v else pick [ name ] v + ) prev + ) + ]; + }; +} diff --git a/clients/quadphone/nixphone.nix b/clients/quadphone/nixphone.nix index b3ceb03..c77bb6d 100644 --- a/clients/quadphone/nixphone.nix +++ b/clients/quadphone/nixphone.nix @@ -1,19 +1,21 @@ +{ inputs, lib, ... }: { - inputs, - lib, - config, - crossPkgs, - ... -}: -{ - imports = [ - ( - _: - import inputs.nixphone.nixosModules.sdm845-oneplus-fajita { - inherit lib config; - pkgs = crossPkgs; - inputs = inputs.sdm845.inputs; - } - ) + imports = [ inputs.nixphone.nixosModules.sdm845-oneplus-fajita ]; + + quadphone.crossPackages = [ + "nix-direnv" ]; + + # nixphone loads pmi8998_haptics in the initrd, but the kernel config doesn't build it + # TODO: upstream to nixphone + boot.kernelPatches = [ + { + name = "pmi8998-haptics"; + patch = null; + structuredExtraConfig.INPUT_QCOM_PMI8998_HAPTICS = lib.kernel.module; + } + ]; + + # TODO: flutter apps don't cross compile, and the flake's package isn't cached + programs.nexus.enable = lib.mkForce false; } diff --git a/flake.lock b/flake.lock index 2f53721..c64edd5 100644 --- a/flake.lock +++ b/flake.lock @@ -656,6 +656,22 @@ "type": "github" } }, + "gadgetfs": { + "flake": false, + "locked": { + "lastModified": 1744406659, + "narHash": "sha256-AH0sOO7CmtQ1w5ug7a58/HgCz8qMclXiRwG+H4K2El4=", + "owner": "sorki", + "repo": "nixos-gadgetfs-proto", + "rev": "ca150fb79c3bc637d6539ae9b8286b856eb97581", + "type": "github" + }, + "original": { + "owner": "sorki", + "repo": "nixos-gadgetfs-proto", + "type": "github" + } + }, "gaypanel": { "inputs": { "nixpkgs": [ @@ -663,11 +679,11 @@ ] }, "locked": { - "lastModified": 1794191656, - "narHash": "sha256-BZmDqA0wmeevgnsxXpYXd/yH/jN1lTwhv8IPacvcfYU=", + "lastModified": 1794272044, + "narHash": "sha256-WpipW+nHzneo04e12244DfjPKsE6TP2+cJupT01nNYI=", "ref": "refs/heads/main", - "rev": "9e5f1a69f9480d6936fd9cb6168f126f614ef9c4", - "revCount": 358, + "rev": "a7ec380c64da049a53c08ee5fe7c4ff824075ca9", + "revCount": 363, "type": "git", "url": "https://codeberg.org/pastthepixels/gaypanel" }, @@ -698,6 +714,23 @@ "type": "github" } }, + "gnome-mobile": { + "inputs": { + "nixpkgs": [ + "nixpkgs" + ] + }, + "locked": { + "lastModified": 0, + "narHash": "sha256-SkR1Brw/vcZnlekZGrhTs26/qMF1EzZ1oVjijZgjVhY=", + "type": "git", + "url": "file:///home/quadradical/Documents/Code/nixos-gnome-mobile" + }, + "original": { + "type": "git", + "url": "file:///home/quadradical/Documents/Code/nixos-gnome-mobile" + } + }, "gnome-shell": { "flake": false, "locked": { @@ -724,11 +757,11 @@ ] }, "locked": { - "lastModified": 1794252721, - "narHash": "sha256-sD1rhEjMghSyWSUG2xEOw+FOVd2wnoWwi/809w8fRkI=", + "lastModified": 1794260194, + "narHash": "sha256-jmaqtyhtPFNgK52WZo33PRvNPPs8AjOWBeCc07nTAM8=", "owner": "nix-community", "repo": "home-manager", - "rev": "f1db7c474bb49babfe9d8def532939e0c7404327", + "rev": "a9752a621164e9f84eb2a15858f1d54fd3cedab8", "type": "github" }, "original": { @@ -800,11 +833,11 @@ ] }, "locked": { - "lastModified": 1794256817, - "narHash": "sha256-3g8voqPE32QoFeDR1hP5P99VX4rWWOyjCqMxN+4+M7k=", + "lastModified": 1794265105, + "narHash": "sha256-kCz1dBfcAPjrIDDXeAZi/1LWUDKnVgIgslOkwrafdgU=", "ref": "refs/heads/main", - "rev": "8aada9a8958745c695724ad7442996716e836af1", - "revCount": 1191, + "rev": "ab3b9cc83fb1aa688bf01b0a498ca25cbce41453", + "revCount": 1196, "submodules": true, "type": "git", "url": "https://git.federated.nexus/Nexus/nexus" @@ -858,11 +891,11 @@ }, "nix-maid": { "locked": { - "lastModified": 1793005444, - "narHash": "sha256-h0XoWnvPIeU0u8deg/Fg7mYTD6+hXJrupU0d7D+qvYU=", + "lastModified": 1794213517, + "narHash": "sha256-bryY6i495uT5OEz0eSeTPeJ35E6JLpI0PjPGNa5EdRk=", "ref": "refs/heads/master", - "rev": "35a7aa1d167c55c95849c500252ecb6bdc2daf1c", - "revCount": 135, + "rev": "d4f00026e380858e683a022abe313a0ae52ad2c0", + "revCount": 136, "type": "git", "url": "https://codeberg.org/viperML/nix-maid" }, @@ -897,11 +930,11 @@ ] }, "locked": { - "lastModified": 1792196447, - "narHash": "sha256-cDxL/uTDeD2xD7AGP6s/YdsGSlWOK9okdAptxjWcFgk=", + "lastModified": 1794267681, + "narHash": "sha256-l8l2GcotQbf3wPShdGKqhSJWncMyjIK+6SHAfad1Wfo=", "ref": "refs/heads/master", - "rev": "5bc9b52b9486bcfc4f709d0582dfa7345ef9c1b4", - "revCount": 28, + "rev": "a6a259f2591c28e2013407f2c84afb3dd8ee17e9", + "revCount": 52, "type": "git", "url": "https://codeberg.org/nixphone/nixphone" }, @@ -1145,7 +1178,9 @@ "fht-compositor": "fht-compositor", "firefox-gnome-theme": "firefox-gnome-theme", "flake-parts": "flake-parts_5", + "gadgetfs": "gadgetfs", "gaypanel": "gaypanel", + "gnome-mobile": "gnome-mobile", "home-manager": "home-manager", "lasuite-docs-proxy": "lasuite-docs-proxy", "lk-jwt-service-module": "lk-jwt-service-module", @@ -1251,11 +1286,11 @@ ] }, "locked": { - "lastModified": 1794257173, - "narHash": "sha256-eQdMmTujqSWaze4pv78oYvxTqyf15ra3vWBzyJ0bsO0=", + "lastModified": 1794259911, + "narHash": "sha256-6Zm2gmTB6WtWogzUKw1YqAU2rWaOA05LMp07TgpRNdk=", "ref": "refs/heads/main", - "rev": "dbc42e4e64175d4cecbf2d8d0a9fc75ef71d85bf", - "revCount": 7805, + "rev": "5cb5432aa859dec1e80027e58ffd7493dd2f8e99", + "revCount": 7817, "type": "git", "url": "https://git.sable.moe/SableClient/sable-next" }, diff --git a/flake.nix b/flake.nix index 7a672ea..5820571 100755 --- a/flake.nix +++ b/flake.nix @@ -6,6 +6,14 @@ wrapper-manager.url = "git+https://codeberg.org/viperML/wrapper-manager"; flake-parts.url = "github:hercules-ci/flake-parts"; nix-maid.url = "git+https://codeberg.org/viperML/nix-maid"; + gadgetfs = { + url = "github:sorki/nixos-gadgetfs-proto"; + flake = false; + }; + gnome-mobile = { + url = "git+file:///home/quadradical/Documents/Code/nixos-gnome-mobile"; + inputs.nixpkgs.follows = "nixpkgs"; + }; nixphone = { url = "git+https://codeberg.org/nixphone/nixphone"; inputs.nixpkgs.follows = "nixpkgs"; diff --git a/modules/common/nh.nix b/modules/common/nh.nix index 08e8261..4340c4b 100644 --- a/modules/common/nh.nix +++ b/modules/common/nh.nix @@ -14,6 +14,8 @@ in flake = "/home/quadradical/.config/nixos"; }; + system.tools.nixos-rebuild.enable = false; + environment.systemPackages = [ (pkgs.writeShellScriptBin "server" '' ${lib.concatMapAttrsStringSep "\n" ( diff --git a/modules/desktop/phone-usb.nix b/modules/desktop/phone-usb.nix new file mode 100644 index 0000000..0447d3d --- /dev/null +++ b/modules/desktop/phone-usb.nix @@ -0,0 +1,15 @@ +{ + networking.networkmanager.ensureProfiles.profiles.phone-usb = { + connection = { + id = "Phone (USB)"; + type = "ethernet"; + }; + ethernet.mac-address = "02:00:00:00:42:02"; + ipv4 = { + method = "manual"; + address1 = "172.16.42.2/24"; + never-default = true; + }; + ipv6.method = "disabled"; + }; +} diff --git a/modules/graphical/gnome/burn-my-windows.conf b/modules/graphical/gnome/burn-my-windows.conf deleted file mode 100644 index 85727d6..0000000 --- a/modules/graphical/gnome/burn-my-windows.conf +++ /dev/null @@ -1,7 +0,0 @@ -[burn-my-windows-profile] -fire-enable-effect=false -apparition-enable-effect=false -broken-glass-enable-effect=false -energize-a-enable-effect=false -energize-b-enable-effect=false -glide-enable-effect=true \ No newline at end of file diff --git a/modules/graphical/gnome/default.nix b/modules/graphical/gnome/default.nix index e3ea322..1448271 100644 --- a/modules/graphical/gnome/default.nix +++ b/modules/graphical/gnome/default.nix @@ -1,23 +1,47 @@ +{ + config, + lib, + pkgs, + ... +}: { services = { - desktopManager.gnome.enable = true; displayManager.gdm.enable = true; + + gnome = { + core-os-services.enable = true; + core-apps.enable = true; + }; + + gvfs.enable = true; }; + environment.sessionVariables.NAUTILUS_4_EXTENSION_DIR = lib.mkForce "${config.system.path}/lib/nautilus/extensions-4"; + + environment.gnome.excludePackages = with pkgs; [ + yelp + orca + totem + xterm + evince + decibels + epiphany + gnome-logs + gnome-tour + gnome-music + simple-scan + gnome-console + gnome-software + gnome-user-docs + gnome-characters + gnome-font-viewer + gnome-connections + gnome-text-editor + gnome-system-monitor + ]; + users.users.quadradical.maid.gsettings.settings.org.gnome = { desktop = { - wm.preferences.focus-mode = "mouse"; - search-providers.sort-order = [ - "org.gnome.Contacts.desktop" - "org.gnome.Documents.desktop" - "org.gnome.Nautilus.desktop" - ]; - - background = rec { - picture-uri = "file://${../../../background.jpg}"; - picture-uri-dark = picture-uri; - }; - interface = rec { color-scheme = "prefer-dark"; @@ -30,30 +54,12 @@ font-name = "sans 11"; document-font-name = font-name; monospace-font-name = "monospace"; - - show-battery-percentage = true; }; lockdown = { disable-printing = true; disable-print-setup = true; - user-administration-disabled = true; }; - - peripherals.touchpad.disable-while-typing = false; }; - - shell = { - remember-mount-password = true; - favorite-apps = [ - "librewolf.desktop" - "org.gnome.Geary.desktop" - "org.gnome.Nautilus.desktop" - ]; - }; - - mutter.edge-tiling = false; - system.location.enabled = true; - settings-daemon.plugins.media-keys.calculator-static = [ ]; }; } diff --git a/modules/graphical/gnome/extensions.nix b/modules/graphical/gnome/extensions.nix deleted file mode 100644 index 1076f75..0000000 --- a/modules/graphical/gnome/extensions.nix +++ /dev/null @@ -1,120 +0,0 @@ -{ - pkgs, - lib, - ... -}: -{ - environment = { - systemPackages = with pkgs.gnomeExtensions; [ - pop-shell - appindicator - blur-my-shell - just-perfection - burn-my-windows - launch-new-instance - compiz-windows-effect - rounded-window-corners-reborn - brightness-control-using-ddcutil - ]; - - gnome.excludePackages = with pkgs; [ - yelp - orca - totem - xterm - evince - decibels - epiphany - gnome-logs - gnome-tour - gnome-music - simple-scan - gnome-console - gnome-software - gnome-user-docs - gnome-characters - gnome-font-viewer - gnome-connections - gnome-text-editor - gnome-system-monitor - ]; - }; - - users.users.quadradical.maid.gsettings.settings.org.gnome.shell = { - disable-user-extensions = false; - allow-extension-installation = false; - enabled-extensions = [ - "blur-my-shell@aunetx" - "pop-shell@system76.com" - "rounded-window-corners@fxgn" - "burn-my-windows@schneegans.github.com" - "fullscreen-avoider@noobsai.github.com" - "appindicatorsupport@rgcjonas.gmail.com" - "compiz-windows-effect@hermes83.github.com" - "display-brightness-ddcutil@themightydeity.github.com" - "launch-new-instance@gnome-shell-extensions.gcampax.github.com" - ]; - disabled-extensions = [ - "just-perfection-desktop@just-perfection" - ]; - - extensions = { - rounded-window-corners-reborn = { - border-width = -5; - skip-libadwaita-app = false; - skip-libhandy-app = false; - }; - - pop-shell = rec { - active-hint = true; - tile-by-default = true; - active-hint-border-radius = 16; - gap-inner = 3; - gap-outer = gap-inner; - }; - - just-perfection = { - accessibility-menu = false; - activities-button = true; - calendar = true; - clock-menu = true; - clock-menu-position = 0; - dash = false; - dash-app-running = false; - dash-separator = false; - events-button = false; - keyboard-layout = false; - panel-size = 0; - power-icon = true; - quick-settings = true; - quick-settings-dark-mode = false; - show-apps-button = false; - startup-status = 0; - window-menu-take-screenshot-button = false; - window-picker-icon = true; - workspace = true; - workspace-switcher-size = 0; - world-clock = false; - }; - - display-brightness-ddcutil = { - allow-zero-brightness = true; - button-location = 1; - ddcutil-binary-path = lib.meta.getExe pkgs.ddcutil; - decrease-brightness-shortcut = [ "XF86MonBrightnessDown" ]; - increase-brightness-shortcut = [ "XF86MonBrightnessUp" ]; - hide-system-indicator = true; - only-all-slider = true; - position-system-menu = 3.0; - show-internal-slider = false; - show-all-slider = true; - show-display-name = false; - show-osd = true; - show-value-label = false; - step-change-keyboard = 2.0; - }; - - burn-my-windows.active-profile = toString ./burn-my-windows.conf; - }; - }; -} diff --git a/modules/mobile/disable-man.nix b/modules/mobile/disable-man.nix index 0db3e6b..e94c201 100644 --- a/modules/mobile/disable-man.nix +++ b/modules/mobile/disable-man.nix @@ -1 +1 @@ -{ documentation.man.generateCaches = false; } +{ documentation.man.cache.enable = false; } diff --git a/modules/mobile/gnome-mobile.nix b/modules/mobile/gnome-mobile.nix new file mode 100644 index 0000000..72b12d9 --- /dev/null +++ b/modules/mobile/gnome-mobile.nix @@ -0,0 +1,56 @@ +# GNOME Shell mobile. GDM and the GNOME services/apps are in modules/graphical/gnome. +{ inputs, pkgs, ... }: +{ + nixpkgs.overlays = [ inputs.gnome-mobile.overlays.default ]; + + services = { + desktopManager.gnome = { + enable = true; + + # One app per workspace + extraGSettingsOverrides = '' + [org.gnome.mutter] + dynamic-workspaces=true + ''; + extraGSettingsOverridePackages = [ pkgs.mutter ]; + }; + + logind.settings.Login = { + HandlePowerKey = "ignore"; + HandlePowerKeyLongPress = "poweroff"; + }; + }; + + # GNOME talks to IBus over D-Bus, with these set the on-screen keyboard won't show up. + environment.extraInit = '' + unset GTK_IM_MODULE QT_IM_MODULE XMODIFIERS + ''; + + users.users.quadradical.maid.gsettings.settings.org.gnome = { + desktop = { + search-providers.sort-order = [ + "org.gnome.Contacts.desktop" + "org.gnome.Documents.desktop" + "org.gnome.Nautilus.desktop" + ]; + + background = rec { + picture-uri = "file://${../../background.jpg}"; + picture-uri-dark = picture-uri; + }; + + lockdown.user-administration-disabled = true; + }; + + system.location.enabled = true; + + shell = { + remember-mount-password = true; + favorite-apps = [ + "librewolf.desktop" + "org.gnome.Geary.desktop" + "org.gnome.Nautilus.desktop" + ]; + }; + }; +} diff --git a/modules/mobile/phone.nix b/modules/mobile/phone.nix new file mode 100644 index 0000000..139727f --- /dev/null +++ b/modules/mobile/phone.nix @@ -0,0 +1,21 @@ +{ pkgs, ... }: +{ + programs = { + feedbackd.enable = true; + calls.enable = true; + }; + + environment.systemPackages = with pkgs; [ + chatty + ]; + + nixpkgs.config.permittedInsecurePackages = [ + "olm-3.2.16" + ]; + + networking.modemmanager.enable = true; + + services.geoclue2.enable = true; + users.users.geoclue.extraGroups = [ "networkmanager" ]; + location.provider = "geoclue2"; +} diff --git a/modules/mobile/phosh.nix b/modules/mobile/phosh.nix deleted file mode 100644 index 71305f6..0000000 --- a/modules/mobile/phosh.nix +++ /dev/null @@ -1,38 +0,0 @@ -{ pkgs, ... }: -{ - programs = { - feedbackd.enable = true; - calls.enable = true; - firefox.package = pkgs.firefox-mobile; - }; - - environment.systemPackages = with pkgs; [ - chatty - ]; - - nixpkgs.config.permittedInsecurePackages = [ - "olm-3.2.16" - ]; - - networking.modemmanager.enable = true; - - services = { - geoclue2 = { - enable = true; - whitelistedAgents = [ "sm.puri.Phosh" ]; - appConfig."sm.puri.Phosh" = { - isAllowed = true; - isSystem = true; - }; - }; - - xserver.desktopManager.phosh = { - enable = true; - group = "users"; - user = "quadradical"; - }; - }; - - users.users.geoclue.extraGroups = [ "networkmanager" ]; - location.provider = "geoclue2"; -} diff --git a/modules/mobile/ssh.nix b/modules/mobile/ssh.nix new file mode 100644 index 0000000..db30bac --- /dev/null +++ b/modules/mobile/ssh.nix @@ -0,0 +1,12 @@ +{ + users.users.quadradical.openssh.authorizedKeys.keys = import ../../secrets/keys.nix; + services.openssh = { + enable = true; + openFirewall = true; + settings = { + PasswordAuthentication = false; + AllowUsers = [ "quadradical" ]; + PermitRootLogin = "no"; + }; + }; +} diff --git a/modules/mobile/usb-network.nix b/modules/mobile/usb-network.nix new file mode 100644 index 0000000..2fc7f89 --- /dev/null +++ b/modules/mobile/usb-network.nix @@ -0,0 +1,34 @@ +{ inputs, ... }: +{ + imports = [ "${inputs.gadgetfs}/usb-gadget.nix" ]; + + hardware.usb-gadget = { + enable = true; + gadgets.g = { + default = true; + product = "quadphone"; + functions.ecm.usb0 = { + deviceAddress = "02:00:00:00:42:01"; + hostAddress = "02:00:00:00:42:02"; + }; + configs.def = { + id = 1; + functions = [ "ecm.usb0" ]; + }; + }; + }; + + networking.networkmanager.ensureProfiles.profiles.usb-network = { + connection = { + id = "USB network"; + type = "ethernet"; + interface-name = "usb0"; + }; + ipv4 = { + method = "manual"; + address1 = "172.16.42.1/24"; + never-default = true; + }; + ipv6.method = "disabled"; + }; +}