diff --git a/flake.nix b/flake.nix index 6ef8722..fb9b6fe 100644 --- a/flake.nix +++ b/flake.nix @@ -142,9 +142,13 @@ }; home.user = [ ./home/hosts/nixmsi.nix ]; }; - phone = { + phone = rec { system = "aarch64-linux"; modules = [ ./system/devices/oneplus-6-phone.nix ]; + home.common.extraSpecialArgs = { + notlua = inputs.notlua.lib.${system}; + }; + home.user = [ ./home/hosts/phone.nix ]; }; }; @@ -169,8 +173,10 @@ hydraJobs = { server.${config.server.system} = self.nixosConfigurations.server.config.system.build.toplevel; - workstation.${config.nixmsi.system} = self.nixosConfigurations.nixmsi.config.system.build.toplevel; router.${config.router-emmc.system} = self.nixosConfigurations.router-emmc.config.system.build.toplevel; + phone.${config.phone.system} = self.nixosConfigurations.phone.config.system.build.toplevel; + phone-home.${config.phone.system} = self.homeConfigurations."user@phone".activation-script; + workstation.${config.nixmsi.system} = self.nixosConfigurations.nixmsi.config.system.build.toplevel; workstation-home.${config.nixmsi.system} = self.homeConfigurations."user@nixmsi".activation-script; }; diff --git a/home/common/firefox.nix b/home/common/firefox.nix deleted file mode 100644 index 42652ba..0000000 --- a/home/common/firefox.nix +++ /dev/null @@ -1,43 +0,0 @@ -{ config, pkgs, ... }: - -{ - imports = [ - ./gui.nix - ]; - programs.firefox = { - enable = true; - package = pkgs.wrapFirefox pkgs.librewolf-unwrapped { - inherit (pkgs.librewolf-unwrapped) extraPrefsFiles extraPoliciesFiles; - wmClass = "LibreWolf"; - libName = "librewolf"; - nativeMessagingHosts = with pkgs; [ keepassxc ]; - }; - profiles.chayleaf = { - extensions = (with config.nur.repos.rycee.firefox-addons; [ - cookies-txt - don-t-fuck-with-paste - greasemonkey - keepassxc-browser - libredirect - localcdn - noscript - privacy-pass - protondb-for-steam - return-youtube-dislikes - rust-search-extension - search-by-image - sponsorblock - steam-database - ublock-origin - unpaywall - vimium-c - youtube-shorts-block - ]) ++ (with pkgs.firefoxAddons; [ - fastforwardteam - middle-mouse-button-scroll - rikaitan - youtube-nonstop - ]); - }; - }; -} diff --git a/home/common/waybar.nix b/home/common/waybar.nix deleted file mode 100644 index 775999e..0000000 --- a/home/common/waybar.nix +++ /dev/null @@ -1,129 +0,0 @@ -{ config, pkgs, ... }: -{ - services.playerctld.enable = config.wayland.windowManager.sway.enable; - programs.waybar = { - enable = config.wayland.windowManager.sway.enable; - package = pkgs.waybar.override { - withMediaPlayer = true; - }; - /*).overrideAttrs (old: { - src = pkgs.fetchFromGitHub { - owner = "chayleaf"; - repo = "Waybar"; - rev = "3091cf4a009e92665325c0dd61adf5ab367786a3"; - sha256 = "sha256-zH4hbQ8+9TYRVW/XYqmAVsi0vsSPn1LPqXxr0gi0j1E="; - }; - });*/ - settings = [{ - layer = "bottom"; - # position = "bottom"; - ipc = true; - height = 40; - modules-left = [ "sway/workspaces" "sway/mode" "idle_inhibitor" "mpris" ]; - idle_inhibitor = { - format = "{icon}"; - format-icons = { - activated = "󰅶"; - deactivated = "󰾪"; - }; - }; - mpris = { - tooltip = true; - format = "{player_icon} {dynamic}"; - format-paused = "{status_icon} {dynamic}"; - interval = 1; - ellipsis = "…"; - # tooltip-format = "{dynamic}"; - album-len = 44; - artist-len = 44; - title-len = 44; - dynamic-len = 44; - player-icons = { - default = ""; - mpd = ""; - }; - status-icons.paused = ""; - }; - "sway/workspaces" = { - disable-scroll = true; - format = "{value}{icon}"; - format-icons = { - default = ""; - urgent = " "; - "2" = " 󰵅"; - "3" = " "; - "4" = " "; - "5" = " "; - }; - persistent-workspaces = { - "1" = [ ]; "2" = [ ]; "3" = [ ]; - }; - }; - "sway/mode" = { - tooltip = false; - }; - modules-center = [ "sway/window" ]; - #fixed-center = false; - "sway/window" = { - format = "{title}"; - max-length = 50; - # tooltip = false; - icon = true; - rewrite = { - kitty = ""; - zsh = ""; - nheko = ""; - Nextcloud = ""; - "(.*) — LibreWolf" = "$1"; - "(.*) - KeePassXC" = "$1"; - }; - }; - modules-right = [ "memory" "cpu" "tray" "wireplumber" "clock" "sway/language" ]; - cpu = { - # format = "{usage}% "; - format = "{icon0}{icon1}{icon2}{icon3}{icon4}{icon5}{icon6}{icon7}{icon8}{icon9}{icon10}{icon11}{icon12}{icon13}{icon14}{icon15}"; - format-icons = ["▁" "▂" "▃" "▄" "▅" "▆" "▇" "█"]; - }; - memory = { - format = "{used}G"; - }; - tray = { - icon-size = 26; - spacing = 5; - }; - wireplumber = { - format = "{volume}%"; - format-muted = "ﱝ"; - tooltip = false; - }; - clock = { - interval = 5; - format = "{:%Y-%m-%d %H:%M:%S}"; - tooltip-format = "{calendar}"; - calendar = { - mode = "year"; - # TODO: make this work - mode-mon-col = 3; - on-scroll = 1; - on-click-right = "mode"; - format = { - months = "{}"; - days = "{}"; - weeks = "W{}"; - weekdays = "{}"; - today = "{}"; - }; - }; - }; - "sway/language" = { - tooltip = false; - # make sure it isn't pushed away when other modules get too big - min-length = 2; - }; - }]; - style = ./waybar.css; - }; - home.packages = with pkgs; [ - playerctl - ]; -} diff --git a/home/hosts/nixmsi.nix b/home/hosts/nixmsi.nix index 41e44aa..5c65299 100644 --- a/home/hosts/nixmsi.nix +++ b/home/hosts/nixmsi.nix @@ -6,12 +6,12 @@ { imports = [ - ../common/general.nix - ../common/firefox.nix - ../common/i3-sway.nix - ../common/nvim.nix - ../common/helix.nix - ../common/kakoune.nix + ../modules/general.nix + ../modules/firefox.nix + ../modules/i3-sway.nix + ../modules/nvim.nix + ../modules/helix.nix + ../modules/kakoune.nix inputs.nur.nixosModules.nur ]; @@ -42,28 +42,10 @@ home.stateVersion = "22.11"; home.username = "user"; home.homeDirectory = "/home/user"; - termShell = { - enable = true; - path = "${pkgs.fish}/bin/fish"; - }; + terminals = [ "kitty" ]; # xsession.windowManager.i3.enable = true; wayland.windowManager.sway.enable = true; - terminals = [ "kitty" "urxvt" ]; - services.mpd = { - enable = true; - network.startWhenNeeded = true; - }; - services.mpdris2 = { - enable = true; - }; - programs.ncmpcpp = { - enable = true; - }; services.kdeconnect.enable = true; - systemd.user.services.kdeconnect.Service = { - Restart = lib.mkForce "always"; - RestartSec = "30"; - }; home.sessionVariables = { STEAM_EXTRA_COMPAT_TOOLS_PATHS = "${pkgs.proton-ge}"; CARGO_PROFILE_DEV_INCREMENTAL = "true"; diff --git a/home/hosts/phone.nix b/home/hosts/phone.nix new file mode 100644 index 0000000..971e37b --- /dev/null +++ b/home/hosts/phone.nix @@ -0,0 +1,38 @@ +{ pkgs +, inputs, +... +}: + +{ + imports = [ + ../modules/general.nix + ../modules/firefox.nix + ../modules/i3-sway.nix + ../modules/nvim.nix + inputs.nur.nixosModules.nur + ]; + + nix.settings = { + trusted-public-keys = [ + "binarycache.pavluk.org:Vk0ms/vSqoOV2JXeNVOroc8EfilgVxCCUtpCShGIKsQ=" + "cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY=" + ]; + trusted-substituters = [ + "https://binarycache.pavluk.org" + "https://cache.nixos.org" + ]; + }; + + phone.enable = true; + home.stateVersion = "23.11"; + home.username = "user"; + home.homeDirectory = "/home/user"; + terminals = [ "foot" "kitty" ]; + wayland.windowManager.sway.enable = true; + services.kdeconnect.enable = true; + home.packages = with pkgs; [ + squeekboard + techmino + tdesktop + ]; +} diff --git a/home/modules/firefox.nix b/home/modules/firefox.nix new file mode 100644 index 0000000..f2896d8 --- /dev/null +++ b/home/modules/firefox.nix @@ -0,0 +1,75 @@ +{ config +, pkgs +, lib +, ... +}: + +{ + imports = [ + ./gui.nix + ]; + home.file.".mozilla/firefox/profiles.ini".target = ".librewolf/profiles.ini"; + programs.firefox = { + enable = true; + package = pkgs.wrapFirefox pkgs.librewolf-unwrapped { + inherit (pkgs.librewolf-unwrapped) extraPrefsFiles extraPoliciesFiles; + wmClass = "LibreWolf"; + libName = "librewolf"; + nativeMessagingHosts = with pkgs; [ keepassxc ]; + }; + profiles.chayleaf = lib.mkMerge [ + { + extensions = (with config.nur.repos.rycee.firefox-addons; [ + cookies-txt + don-t-fuck-with-paste + greasemonkey + keepassxc-browser + libredirect + localcdn + noscript + privacy-pass + protondb-for-steam + return-youtube-dislikes + rust-search-extension + search-by-image + sponsorblock + steam-database + ublock-origin + unpaywall + vimium-c + youtube-shorts-block + ]) ++ (with pkgs.firefoxAddons; [ + fastforwardteam + middle-mouse-button-scroll + rikaitan + youtube-nonstop + ]); + settings = lib.mkIf config.phone.enable { + "dom.w3c.touch_events.enabled" = true; + "apz.allow_zooming" = true; + "apz.allow_double_tap_zooming" = true; + "dom.w3c_touch_events.legacy_apis.enabled" = true; + "browser.tabs.inTitlebar" = 1; + "toolkit.legacyUserProfileCustomizations.stylesheets" = true; + "browser.urlbar.clickSelectsAll" = true; + "toolkit.cosmeticAnimations.enabled" = false; + "browser.download.animateNotifications" = false; + }; + } + (let + concatFiles = dir: + builtins.concatStringsSep "" + (map + (k: lib.optionalString (!lib.hasInfix ".before-ff" k) (builtins.readFile "${dir}/${k}")) + (builtins.attrNames (builtins.readDir dir))); + in lib.mkIf config.phone.enable { + userChrome = + concatFiles "${pkgs.mobile-config-firefox}/etc/mobile-config-firefox/common" + + concatFiles "${pkgs.mobile-config-firefox}/etc/mobile-config-firefox/userChrome"; + userContent = + concatFiles "${pkgs.mobile-config-firefox}/etc/mobile-config-firefox/common" + + concatFiles "${pkgs.mobile-config-firefox}/etc/mobile-config-firefox/userContent"; + }) + ]; + }; +} diff --git a/home/common/fish.nix b/home/modules/fish.nix similarity index 100% rename from home/common/fish.nix rename to home/modules/fish.nix diff --git a/home/common/general.nix b/home/modules/general.nix similarity index 100% rename from home/common/general.nix rename to home/modules/general.nix diff --git a/home/common/gui.nix b/home/modules/gui.nix similarity index 95% rename from home/common/gui.nix rename to home/modules/gui.nix index abf8e90..cdce9e3 100644 --- a/home/common/gui.nix +++ b/home/modules/gui.nix @@ -234,6 +234,23 @@ # settings = { # }; #}; + termShell = { + enable = true; + path = "${pkgs.fish}/bin/fish"; + }; + services.mpd = { + enable = true; + network.startWhenNeeded = true; + }; + services.mpdris2 = { + enable = true; + }; + systemd.user.services.kdeconnect = lib.mkIf config.services.kdeconnect.enable { + Service = { + Restart = lib.mkForce "always"; + RestartSec = "30"; + }; + }; # some packages require a pointer theme home.pointerCursor.gtk.enable = true; diff --git a/home/common/helix.nix b/home/modules/helix.nix similarity index 100% rename from home/common/helix.nix rename to home/modules/helix.nix diff --git a/home/common/i3-sway.nix b/home/modules/i3-sway.nix similarity index 93% rename from home/common/i3-sway.nix rename to home/modules/i3-sway.nix index fd75c26..a385ff0 100644 --- a/home/common/i3-sway.nix +++ b/home/modules/i3-sway.nix @@ -1,6 +1,6 @@ { options, config, pkgs, lib, ... }: let -modifier = "Mod4"; +modifier = if config.phone.enable then "Mod1" else "Mod4"; rofiSway = config.programs.rofi.finalPackage; rofiI3 = pkgs.rofi.override { plugins = config.programs.rofi.plugins; }; audioNext = pkgs.writeShellScript "playerctl-next" '' @@ -35,7 +35,7 @@ audioPrev = pkgs.writeShellScript "playerctl-prev" '' fi ''; barConfig = { - mode = "dock"; + mode = "overlay"; hiddenState = "hide"; position = "bottom"; workspaceButtons = true; @@ -80,6 +80,11 @@ commonConfig = { inherit modifier; startup = [ { command = toString (pkgs.writeShellScript "init-wm" '' + ${lib.optionalString config.phone.enable '' + ${pkgs.squeekboard}/bin/squeekboard& + ${pkgs.wvkbd}/bin/wvkbd-mobintl --hidden -l full,special,cyrillic,emoji& + ${pkgs.systemd}/bin/busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 SetVisible b true + ''} ${pkgs.home-daemon}/bin/home-daemon system76-scheduler& ${pkgs.gnome.zenity}/bin/zenity --password | (${pkgs.keepassxc}/bin/keepassxc --pw-stdin ~/Nextcloud/keepass.kdbx&) # nextcloud and nheko need secret service access @@ -232,7 +237,7 @@ in extraConfig = '' title_align center ''; - config = let swayConfig = { + config = commonConfig // { bars = [ { command = "${config.programs.waybar.package}/bin/waybar"; @@ -308,7 +313,7 @@ in "--inhibited --no-repeat --allow-other --release Scroll_Lock" = "exec ${pkgs.mumble}/bin/mumble rpc stoptalking"; "${modifier}+c" = "exec ${rofiSway}/bin/rofi -show calc -no-show-match -no-sort -no-persist-history"; "${modifier}+Print" = "exec ${grimshot}/bin/grimshot copy area"; - "${modifier}+Mod1+Print" = "exec ${grimshot}/bin/grimshot copy window"; + "${modifier}+${if modifier == "Mod1" then "Mod4" else "Mod1"}+Print" = "exec ${grimshot}/bin/grimshot copy window"; "--locked XF86AudioRaiseVolume" = "exec ${pkgs.pamixer}/bin/pamixer --increase 5"; "--locked XF86AudioLowerVolume" = "exec ${pkgs.pamixer}/bin/pamixer --decrease 5"; "--locked XF86AudioMute" = "exec ${pkgs.pamixer}/bin/pamixer --toggle-mute"; @@ -340,7 +345,8 @@ in }; }; menu = "${rofiSway}/bin/rofi -show drun"; - }; in commonConfig // swayConfig; + workspaceLayout = "tabbed"; + }; # export WLR_RENDERER=vulkan extraSessionCommands = lib.optionalString config.wayland.windowManager.sway.vulkan '' export WLR_RENDERER=vulkan @@ -358,9 +364,15 @@ in export XDG_SESSION_DESKTOP=sway ''; }; - services.swayidle = let swaylock-start = toString (pkgs.writeShellScript "swaylock-start" '' - ${pkgs.procps}/bin/pgrep -fx "${pkgs.swaylock}/bin/swaylock -f" || ${pkgs.swaylock}/bin/swaylock -f - ''); in { + services.swayidle = let + swaylock = + if config.phone.enable + then "${pkgs.schlock}/bin/schlock -f /secrets/schlock.pin" + else "${pkgs.swaylock}/bin/swaylock -f"; + swaylock-start = toString (pkgs.writeShellScript "swaylock-start" '' + ${pkgs.procps}/bin/pgrep -fx "${swaylock}" || ${swaylock} + ''); + in { enable = config.wayland.windowManager.sway.enable; events = [ { event = "before-sleep"; command = swaylock-start; } @@ -466,7 +478,13 @@ in }; terminal = config.terminalBin; extraConfig = { - modi = [ "steam:${pkgs.rofi-steam-game-list}/bin/rofi-steam-game-list" "drun" "run" "ssh" ]; + modi = lib.optionals (!config.phone.enable) [ + "steam:${pkgs.rofi-steam-game-list}/bin/rofi-steam-game-list" + ] ++ [ + "drun" + "run" + "ssh" + ]; icon-theme = "hicolor"; drun-match-fields = [ "name" "generic" "exec" "keywords" ]; show-icons = true; diff --git a/home/common/kakoune.nix b/home/modules/kakoune.nix similarity index 100% rename from home/common/kakoune.nix rename to home/modules/kakoune.nix diff --git a/home/common/nvim.nix b/home/modules/nvim.nix similarity index 100% rename from home/common/nvim.nix rename to home/modules/nvim.nix diff --git a/home/common/options.nix b/home/modules/options.nix similarity index 96% rename from home/common/options.nix rename to home/modules/options.nix index 34feb21..03d33c6 100644 --- a/home/common/options.nix +++ b/home/modules/options.nix @@ -1,5 +1,12 @@ { lib, config, ... }: with lib; { + options.phone = { + enable = mkOption { + type = types.bool; + default = false; + description = "whether this is a phone"; + }; + }; options.rustAnalyzerAndroidSettings = mkOption { type = with types; attrs; description = "Additional cargo arguments for rust-analyzer's RustAndroid command"; @@ -89,7 +96,7 @@ with lib; { config.colors.brMagenta = builtins.elemAt config.colors.base 13; config.colors.brCyan = builtins.elemAt config.colors.base 14; config.colors.brWhite = builtins.elemAt config.colors.base 15; - options.termShell = mkOption { + options.termShell = { enable = mkOption { description = "Use a separate shell for gui terminal"; type = types.bool; diff --git a/home/common/sway.patch b/home/modules/sway.patch similarity index 100% rename from home/common/sway.patch rename to home/modules/sway.patch diff --git a/home/common/terminal.nix b/home/modules/terminal.nix similarity index 97% rename from home/common/terminal.nix rename to home/modules/terminal.nix index 0c2a84d..c3bd5de 100644 --- a/home/common/terminal.nix +++ b/home/modules/terminal.nix @@ -1,7 +1,7 @@ { config, pkgs, lib, ... }: let supportTerminal = term: builtins.elem term config.terminals; - getTerminalBin = term: lib.getExe { + getTerminalBin = term: { alacritty = "${pkgs.alacritty}/bin/alacritty"; foot = "${pkgs.foot}/bin/footclient"; kitty = "${pkgs.kitty}/bin/kitty"; @@ -123,7 +123,9 @@ in { "*antialias" = true; "*autohint" = true; }; - home.file.".Xdefaults".source = lib.mkIf config.programs.urxvt.enable config.home.file."${config.home.homeDirectory}/.Xresources".source; + home.file.".Xdefaults" = lib.mkIf config.programs.urxvt.enable { + source = config.home.file."${config.home.homeDirectory}/.Xresources".source; + }; programs.foot = { enable = supportTerminal "foot"; server.enable = true; diff --git a/home/common/waybar.css b/home/modules/waybar.css similarity index 87% rename from home/common/waybar.css rename to home/modules/waybar.css index f9efb66..f65f96f 100644 --- a/home/common/waybar.css +++ b/home/modules/waybar.css @@ -11,10 +11,18 @@ border: none; border-radius: 0; font-family: Noto Sans Mono, "Symbols Nerd Font Mono", monospace; - font-size: 19; + font-size: 19px; min-height: 0; } +#custom-a { font-size: 40px; } +#custom-b { font-size: 40px; } +#custom-c { font-size: 40px; } +#custom-d { font-size: 40px; } +#custom-e { font-size: 40px; } +#custom-f { font-size: 40px; } +#custom-g { font-size: 40px; } + #mpris { padding-left: 3px; font-family: "Noto Sans Mono CJK JP", "Noto Sans Mono", "Symbols Nerd Font Mono", monospace; diff --git a/home/modules/waybar.nix b/home/modules/waybar.nix new file mode 100644 index 0000000..24f596b --- /dev/null +++ b/home/modules/waybar.nix @@ -0,0 +1,225 @@ +{ config +, pkgs +, lib +, ... +}: + +{ + services.playerctld.enable = config.wayland.windowManager.sway.enable; + programs.waybar = { + enable = config.wayland.windowManager.sway.enable; + package = pkgs.waybar.override { + withMediaPlayer = true; + }; + /*).overrideAttrs (old: { + src = pkgs.fetchFromGitHub { + owner = "chayleaf"; + repo = "Waybar"; + rev = "3091cf4a009e92665325c0dd61adf5ab367786a3"; + sha256 = "sha256-zH4hbQ8+9TYRVW/XYqmAVsi0vsSPn1LPqXxr0gi0j1E="; + }; + });*/ + settings = lib.toList { + layer = "top"; + position = "top"; + ipc = true; + height = 40; + modules-left = [ + "sway/workspaces" + "sway/mode" + "idle_inhibitor" + ] + ++ lib.optional (!config.phone.enable) "mpris"; + idle_inhibitor = { + format = "{icon}"; + format-icons = { + activated = "󰅶"; + deactivated = "󰾪"; + }; + }; + mpris = { + tooltip = true; + format = "{player_icon} {dynamic}"; + format-paused = "{status_icon} {dynamic}"; + interval = 1; + ellipsis = "…"; + # tooltip-format = "{dynamic}"; + album-len = 44; + artist-len = 44; + title-len = 44; + dynamic-len = 44; + player-icons = { + default = ""; + mpd = ""; + }; + status-icons.paused = ""; + }; + "sway/workspaces" = { + disable-scroll = true; + format = "{value}{icon}"; + format-icons = { + default = ""; + urgent = " "; + } // lib.optionalAttrs (!config.phone.enable) { + "2" = " 󰵅"; + "3" = " "; + "4" = " "; + "5" = " "; + }; + persistent-workspaces = { + "1" = [ ]; "2" = [ ]; "3" = [ ]; + }; + }; + "sway/mode" = { + tooltip = false; + }; + modules-center = [ "sway/window" ]; + #fixed-center = false; + "sway/window" = { + format = "{title}"; + max-length = 50; + # tooltip = false; + icon = true; + rewrite = { + kitty = ""; + zsh = ""; + nheko = ""; + Nextcloud = ""; + "(.*) — LibreWolf" = "$1"; + "(.*) - KeePassXC" = "$1"; + }; + }; + modules-right = [ + "memory" + ] + ++ lib.optional (!config.phone.enable) "cpu" + ++ [ + "tray" + (if config.phone.enable then "pulseaudio" else "wireplumber") + ] + ++ lib.optional (!config.phone.enable) "clock" + ++ [ "sway/language" ] + ++ lib.optional config.phone.enable "battery"; + battery = { + format = "{capacity}%"; + }; + cpu = { + # format = "{usage}% "; + format = "{icon0}{icon1}{icon2}{icon3}{icon4}{icon5}{icon6}{icon7}{icon8}{icon9}{icon10}{icon11}{icon12}{icon13}{icon14}{icon15}"; + format-icons = ["▁" "▂" "▃" "▄" "▅" "▆" "▇" "█"]; + }; + memory = { + format = "{used}G"; + }; + tray = { + icon-size = 26; + spacing = 5; + }; + wireplumber = { + format = "{volume}%"; + format-muted = "ﱝ"; + tooltip = false; + }; + pulseaudio = { + format = "{volume}%"; + format-muted = "ﱝ"; + tooltip = false; + }; + clock = { + interval = 5; + format = "{:%Y-%m-%d %H:%M:%S}"; + tooltip-format = "{calendar}"; + calendar = { + mode = "year"; + # TODO: make this work + mode-mon-col = 3; + on-scroll = 1; + on-click-right = "mode"; + format = { + months = "{}"; + days = "{}"; + weeks = "W{}"; + weekdays = "{}"; + today = "{}"; + }; + }; + }; + "sway/language" = { + tooltip = false; + # make sure it isn't pushed away when other modules get too big + min-length = 2; + }; + } ++ lib.optionals config.phone.enable [ + { + layer = "top"; + position = "top"; + ipc = true; + height = 40; + clock = { + interval = 5; + format = "{:%Y-%m-%d %H:%M:%S}"; + }; + cpu = { + # format = "{usage}% "; + format = "{icon0}{icon1}{icon2}{icon3}{icon4}{icon5}{icon6}{icon7}{icon8}{icon9}{icon10}{icon11}{icon12}{icon13}{icon14}{icon15}"; + format-icons = ["▁" "▂" "▃" "▄" "▅" "▆" "▇" "█"]; + }; + modules-left = [ "cpu" ]; + modules-right = [ "clock" ]; + } + { + layer = "top"; + position = "bottom"; + ipc = true; + height = 80; + modules-left = [ "custom/a" "custom/b" "custom/c" ]; + modules-right = [ "custom/d""custom/e" "custom/f" ]; + # 2 btns: keyboards + # 1 btn: close + # + "custom/a" = { + interval = "once"; exec = "${pkgs.coreutils}/bin/echo a"; exec-if = "${pkgs.coreutils}/bin/true"; + format = " A "; + on-click = "${config.home.homeDirectory}/scripts/a.sh"; + }; + "custom/b" = { + interval = "once"; exec = "${pkgs.coreutils}/bin/echo a"; exec-if = "${pkgs.coreutils}/bin/true"; + format = " 󰌌 "; + on-click = pkgs.writeShellScript "toggle-keyboard.sh" '' + pkill -x -SIGRTMIN wvkbd-mobintl + ''; + }; + "custom/c" = { + interval = "once"; exec = "${pkgs.coreutils}/bin/echo a"; exec-if = "${pkgs.coreutils}/bin/true"; + format = " C "; + on-click = "${config.home.homeDirectory}/scripts/c.sh"; + }; + "custom/d" = { + interval = "once"; exec = "${pkgs.coreutils}/bin/echo a"; exec-if = "${pkgs.coreutils}/bin/true"; + format = " D "; + on-click = "${config.home.homeDirectory}/scripts/d.sh"; + }; + "custom/e" = { + interval = "once"; exec = "${pkgs.coreutils}/bin/echo a"; exec-if = "${pkgs.coreutils}/bin/true"; + format = " 󰌌 "; + on-click = pkgs.writeShellScript "toggle-keyboard.sh" '' + if ${pkgs.systemd}/bin/busctl get-property --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 Visible | ${pkgs.gnugrep}/bin/grep true; then + ${pkgs.systemd}/bin/busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 SetVisible b false + else + ${pkgs.systemd}/bin/busctl call --user sm.puri.OSK0 /sm/puri/OSK0 sm.puri.OSK0 SetVisible b true + fi + ''; + }; + "custom/f" = { + interval = "once"; exec = "${pkgs.coreutils}/bin/echo a"; exec-if = "${pkgs.coreutils}/bin/true"; + format = " X "; + on-click = "${pkgs.sway}/bin/swaymsg kill"; + }; + } + ]; + style = ./waybar.css; + }; + home.packages = with pkgs; [ + playerctl + ]; +} diff --git a/home/common/zsh.nix b/home/modules/zsh.nix similarity index 100% rename from home/common/zsh.nix rename to home/modules/zsh.nix diff --git a/pkgs/default.nix b/pkgs/default.nix index 79ca196..e8515b8 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -114,6 +114,7 @@ in kvmfrOverlay = kvmfr: kvmfr.overrideAttrs (old: { inherit (pkgs'.looking-glass-client) version src; }); + mobile-config-firefox = callPackage ./mobile-config-firefox { }; ping-exporter = callPackage ./ping-exporter { }; proton-ge = pkgs.stdenvNoCC.mkDerivation { inherit (sources.proton-ge) pname version src; @@ -129,6 +130,7 @@ in version = "unstable-" + sources.searxng.date; postInstall = builtins.replaceStrings [ "/botdetection" ] [ "" ] old.postInstall; })); + schlock = callPackage ./schlock { }; techmino = callPackage ./techmino { }; firefoxAddons = lib.recurseIntoAttrs (callPackage ./firefox-addons { inherit nur sources; }); diff --git a/pkgs/mobile-config-firefox/default.nix b/pkgs/mobile-config-firefox/default.nix new file mode 100644 index 0000000..fdbe3a9 --- /dev/null +++ b/pkgs/mobile-config-firefox/default.nix @@ -0,0 +1,31 @@ +{ lib +, stdenv +, fetchFromGitLab +}: + +stdenv.mkDerivation rec { + pname = "mobile-config-firefox"; + version = "4.2.0"; + + src = fetchFromGitLab { + owner = "postmarketOS"; + repo = "mobile-config-firefox"; + rev = version; + hash = "sha256-JEfgB+dqfy97n4FC2N6eHDV0aRFAhmFujYJHYa3kENE="; + }; + + makeFlags = [ "DESTDIR=$(out)" "FIREFOX_DIR=/lib/firefox" ]; + + postInstall = '' + rm -rf "$out/usr" + ''; + + meta = with lib; { + description = "Mobile and privacy friendly configuration for Firefox (distro-independent"; + homepage = "https://gitlab.com/postmarketOS/mobile-config-firefox"; + license = licenses.mpl20; + maintainers = with maintainers; [ chayleaf ]; + mainProgram = "mobile-config-firefox"; + platforms = platforms.all; + }; +} diff --git a/pkgs/schlock/default.nix b/pkgs/schlock/default.nix new file mode 100644 index 0000000..324f555 --- /dev/null +++ b/pkgs/schlock/default.nix @@ -0,0 +1,56 @@ +{ lib +, stdenv +, fetchFromGitHub +, meson +, ninja +, pkg-config +, scdoc +, cairo +, gdk-pixbuf +, libsodium +, libxkbcommon +, wayland +, wayland-protocols +}: + +stdenv.mkDerivation { + pname = "schlock"; + version = "unstable-2022-02-02"; + + src = fetchFromGitHub { + owner = "telent"; + repo = "schlock"; + rev = "f3dde16f074fd5b7482a253b9d26b4ead66dea82"; + hash = "sha256-Ot86vALt1kkzbBocwh9drCycbRIw2jMKJU4ODe9PYQM="; + }; + + nativeBuildInputs = [ + meson + ninja + pkg-config + scdoc + ]; + + buildInputs = [ + cairo + gdk-pixbuf + libsodium + libxkbcommon + wayland + wayland-protocols + ]; + + mesonFlags = [ + "-Dgdk-pixbuf=enabled" + "-Dman-pages=enabled" + ]; + + meta = with lib; { + description = ""; + homepage = "https://github.com/telent/schlock"; + license = licenses.mit; + maintainers = with maintainers; [ chayleaf ]; + mainProgram = "schlock"; + platforms = platforms.all; + }; +} diff --git a/system/hardware/oneplus-enchilada/default.nix b/system/hardware/oneplus-enchilada/default.nix index 2e1a357..c0007f3 100644 --- a/system/hardware/oneplus-enchilada/default.nix +++ b/system/hardware/oneplus-enchilada/default.nix @@ -38,10 +38,15 @@ in requires = [ "dbus.socket" ]; serviceConfig.ExecStart = "${pkgs.q6voiced}/bin/q6voiced hw:0,6"; }; - environment.etc."wireplumber/main.lua.d/51-qcom-sdm845.lua".source = pkgs.fetchurl { - url = "https://gitlab.com/postmarketOS/pmaports/-/raw/0aa9524204e9c9c002c860b87c972bc2ebf025f3/device/community/soc-qcom-sdm845/51-qcom-sdm845.lua"; - hash = "sha256-56oNJJyuZZe1Iig1xskDuyazw3PbRZtmU/YRFUTqjwk="; - }; + systemd.user.services.wireplumber.environment.WIREPLUMBER_CONFIG_DIR = pkgs.runCommand "wireplumber-config" {} '' + cp -a "${pkgs.wireplumber}/share/wireplumber" "$out" + chmod +w "$out" "$out/main.lua.d" + ln -s ${pkgs.fetchurl { + url = "https://gitlab.com/postmarketOS/pmaports/-/raw/0aa9524204e9c9c002c860b87c972bc2ebf025f3/device/community/soc-qcom-sdm845/51-qcom-sdm845.lua"; + hash = "sha256-56oNJJyuZZe1Iig1xskDuyazw3PbRZtmU/YRFUTqjwk="; + }} "$out/main.lua.d/51-qcom-sdm845.lua" + ''; + systemd.services.wireplumber.environment.WIREPLUMBER_CONFIG_DIR = config.systemd.user.services.wireplumber.environment.WIREPLUMBER_CONFIG_DIR; networking.modemmanager.enable = !config.networking.networkmanager.enable; services.udev.extraRules = '' SUBSYSTEM=="input", KERNEL=="event*", ENV{ID_INPUT}=="1", SUBSYSTEMS=="input", ATTRS{name}=="spmi_haptics", TAG+="uaccess", ENV{FEEDBACKD_TYPE}="vibra" @@ -108,16 +113,23 @@ in boot.initrd.postMountCommands = '' pkill -x buffyboard ''; - services.getty.extraArgs = [ "--skip-login" ]; - services.getty.loginProgram = let - lockfile = "/tmp/buffyboard-lock.lock"; - in pkgs.writeShellScript "login-with-buffyboard-once" '' - if [ ! -f '${lockfile}' ]; then - ${pkgs.coreutils}/bin/touch '${lockfile}' - ${pkgs.buffyboard}/bin/buffyboard 2>/dev/null & - fi - exec ${pkgs.shadow}/bin/login -f user - ''; + common.gettyAutologin = true; + systemd.services.buffyboard = { + description = "buffyboard"; + wantedBy = [ "multi-user.target" ]; + serviceConfig = { + ExecStart = "${pkgs.buffyboard}/bin/buffyboard"; + Restart = "always"; + RestartSec = "1"; + }; + }; + security.sudo.extraRules = [ + { groups = [ "users" ]; + commands = [ + { command = "/run/current-system/sw/bin/systemctl stop buffyboard"; options = [ "SETENV" "NOPASSWD" ]; } + { command = "/run/current-system/sw/bin/systemctl start buffyboard"; options = [ "SETENV" "NOPASSWD" ]; } + ]; } + ]; }) (lib.mkIf cfg.rndis.enable { boot.initrd.kernelModules = [ "configfs" "libcomposite" ]; diff --git a/system/hardware/oneplus-enchilada/pkgs.nix b/system/hardware/oneplus-enchilada/pkgs.nix index 93c4c1d..9626e77 100644 --- a/system/hardware/oneplus-enchilada/pkgs.nix +++ b/system/hardware/oneplus-enchilada/pkgs.nix @@ -49,7 +49,7 @@ in { mkdir -p "$out"/share/alsa/ucm2/{OnePlus,conf.d/sdm845,lib} mv ucm2/lib/card-init.conf "$out/share/alsa/ucm2/lib/" mv ucm2/OnePlus/enchilada "$out/share/alsa/ucm2/OnePlus/" - ln -s ../../OnePlus/enchilada/enchilada.conf "$out/share/alsa/ucm2/conf.d/sdm845/OnePlus 6.conf" + ln -s ../../OnePlus/enchilada/enchilada.conf "$out/share/alsa/ucm2/conf.d/sdm845/oneplus-OnePlus6-Unknown.conf" ''; # to overwrite card-init.conf meta.priority = -10; diff --git a/system/hosts/phone/default.nix b/system/hosts/phone/default.nix index 0be8ee3..39b5011 100644 --- a/system/hosts/phone/default.nix +++ b/system/hosts/phone/default.nix @@ -1,12 +1,36 @@ { pkgs , lib -# , config +, config , ... }: { + imports = [ ./options.nix ]; + system.stateVersion = "23.11"; + systemd.network.links."40-wlan0" = { + matchConfig.OriginalName = "wlan0"; + linkConfig.MACAddressPolicy = "none"; + linkConfig.MACAddress = config.phone.mac; + }; + + sound.enable = true; + services.logind.powerKey = "ignore"; + services.logind.powerKeyLongPress = "poweroff"; + hardware.sensor.iio.enable = true; + services.pipewire.enable = false; + hardware.pulseaudio.enable = lib.mkForce true; + users.users.${config.common.mainUsername}.extraGroups = [ + "dialout" + "feedbackd" + "video" + ] ++ lib.optional (config.networking.modemmanager.enable || config.networking.networkmanager.enable) "networkmanager"; + + common.minimal = false; + services.sshd.enable = true; + services.tlp.enable = true; + # kde connect networking.firewall.allowedTCPPortRanges = [ { from = 1714; to = 1764; } @@ -15,12 +39,20 @@ { from = 1714; to = 1764; } ]; - common.minimal = false; + programs.calls.enable = true; + environment.systemPackages = with pkgs; [ + # IM and SMS + chatty + ]; + programs.sway.enable = true; xdg.portal = { enable = true; extraPortals = with pkgs; [ xdg-desktop-portal-gtk xdg-desktop-portal-wlr ]; }; - services.sshd.enable = true; - # users.users.${config.common.mainUsername}.extraGroups = [ "video" "feedbackd" "dialout" ]; + # services.xserver.desktopManager.phosh = { + # enable = true; + # group = "users"; + # user = config.common.mainUsername; + # }; } diff --git a/system/hosts/phone/options.nix b/system/hosts/phone/options.nix new file mode 100644 index 0000000..6989333 --- /dev/null +++ b/system/hosts/phone/options.nix @@ -0,0 +1,12 @@ +{ lib +, ... +}: + +{ + options.phone = { + mac = lib.mkOption { + description = "mac address"; + type = lib.types.str; + }; + }; +} diff --git a/system/hosts/server/files.nix b/system/hosts/server/files.nix index ccaf757..37f64e7 100644 --- a/system/hosts/server/files.nix +++ b/system/hosts/server/files.nix @@ -11,6 +11,13 @@ in { enableACME = true; forceSSL = true; locations."/".proxyPass = "http://${lib.quoteListenAddr settings.server.HTTP_ADDR}:${toString settings.server.HTTP_PORT}"; + locations."= /robots.txt".extraConfig = '' + return 200 ${builtins.toJSON '' + User-agent: * + Disallow: /mirrors/nixpkgs + Disallow: /chayleaf/nixpkgs + ''}; + ''; }; services.forgejo = { enable = true; diff --git a/system/hosts/server/matrix.nix b/system/hosts/server/matrix.nix index fc18c45..0e4f423 100644 --- a/system/hosts/server/matrix.nix +++ b/system/hosts/server/matrix.nix @@ -8,17 +8,17 @@ let "m.server" = "matrix.${cfg.domainName}:443"; }; matrixClientJson = { - "m.homeserver" = { base_url = "https://matrix.${cfg.domainName}"; }; - "m.identity_server" = { base_url = "https://vector.im"; }; + "m.homeserver".base_url = "https://matrix.${cfg.domainName}"; + "m.identity_server".base_url = "https://vector.im"; }; matrixServerConfigResponse = '' add_header Content-Type application/json; - return 200 '${builtins.toJSON matrixServerJson}'; + return 200 ${builtins.toJSON (builtins.toJSON matrixServerJson)}; ''; matrixClientConfigResponse = '' add_header Content-Type application/json; add_header Access-Control-Allow-Origin *; - return 200 '${builtins.toJSON matrixClientJson}'; + return 200 ${builtins.toJSON (builtins.toJSON matrixClientJson)}; ''; matrixAddr = "::1"; matrixPort = 8008; diff --git a/system/modules/common.nix b/system/modules/common.nix index 62bcf6f..691bf64 100644 --- a/system/modules/common.nix +++ b/system/modules/common.nix @@ -123,6 +123,7 @@ in { wget kitty.terminfo + foot.terminfo # rxvt-unicode-unwrapped.terminfo ]; programs.fish.enable = true; @@ -200,6 +201,7 @@ in { security.polkit.enable = true; security.rtkit.enable = true; services.dbus.enable = true; + programs.dconf.enable = true; }) ];