mirror of
https://github.com/ryan4yin/nix-config.git
synced 2026-04-24 09:48:30 +02:00
feat: add WeChat(UOS) sandboxed
fix: mkdir - persist qq's config feat: update kernel params for nvidia
This commit is contained in:
4
Justfile
4
Justfile
@@ -381,6 +381,10 @@ emacs-reload:
|
|||||||
path:
|
path:
|
||||||
$env.PATH | split row ":"
|
$env.PATH | split row ":"
|
||||||
|
|
||||||
|
[group('common')]
|
||||||
|
trace-access app *args:
|
||||||
|
strace -f -t -e trace=file {{app}} {{args}} | complete | $in.stderr | lines | find -v -r "(/nix/store|/newroot|/proc)" | parse --regex '"(/.+)"' | sort | uniq
|
||||||
|
|
||||||
[linux]
|
[linux]
|
||||||
[group('common')]
|
[group('common')]
|
||||||
penvof pid:
|
penvof pid:
|
||||||
|
|||||||
@@ -22,6 +22,9 @@ in {
|
|||||||
qq = wrapper super ./qq.nix;
|
qq = wrapper super ./qq.nix;
|
||||||
qq-desktop-item = super.callPackage ./qq-desktop-item.nix {};
|
qq-desktop-item = super.callPackage ./qq-desktop-item.nix {};
|
||||||
|
|
||||||
|
wechat-uos = wrapper super ./wechat-uos.nix;
|
||||||
|
wechat-uos-desktop-item = super.callPackage ./wechat-uos-desktop-item.nix {};
|
||||||
|
|
||||||
firefox = wrapper super ./firefox.nix;
|
firefox = wrapper super ./firefox.nix;
|
||||||
firefox-desktop-item = super.callPackage ./firefox-desktop-item.nix {};
|
firefox-desktop-item = super.callPackage ./firefox-desktop-item.nix {};
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -37,10 +37,15 @@ mkNixPak {
|
|||||||
};
|
};
|
||||||
|
|
||||||
bubblewrap = {
|
bubblewrap = {
|
||||||
|
# To trace all the home files QQ accesses, you can use the following nushell command:
|
||||||
|
# just trace-access firefox
|
||||||
|
# See the Justfile in the root of this repository for more information.
|
||||||
bind.rw = [
|
bind.rw = [
|
||||||
(sloth.concat' sloth.homeDir "/.mozilla")
|
# given the read write permission to the following directories.
|
||||||
(sloth.concat' sloth.homeDir "/Downloads")
|
# NOTE: sloth.mkdir is used to create the directory if it does not exist!
|
||||||
|
(sloth.mkdir (sloth.concat' sloth.homeDir "/.mozilla"))
|
||||||
|
|
||||||
|
sloth.xdgDownloadDir
|
||||||
# ================ for externsions ===============================
|
# ================ for externsions ===============================
|
||||||
# required by https://github.com/browserpass/browserpass-extension
|
# required by https://github.com/browserpass/browserpass-extension
|
||||||
(sloth.concat' sloth.homeDir "/.local/share/password-store") # pass
|
(sloth.concat' sloth.homeDir "/.local/share/password-store") # pass
|
||||||
|
|||||||
@@ -7,7 +7,9 @@ makeDesktopItem {
|
|||||||
desktopName = "QQ";
|
desktopName = "QQ";
|
||||||
exec = "qq %U";
|
exec = "qq %U";
|
||||||
terminal = false;
|
terminal = false;
|
||||||
# icon = "qq";
|
# To find the icon name(nushell):
|
||||||
|
# let p = NIXPKGS_ALLOW_UNFREE=1 nix eval --impure nixpkgs#qq.outPath | str trim --char '"'
|
||||||
|
# tree $"($p)/share/icons"
|
||||||
icon = "${qq}/share/icons/hicolor/512x512/apps/qq.png";
|
icon = "${qq}/share/icons/hicolor/512x512/apps/qq.png";
|
||||||
type = "Application";
|
type = "Application";
|
||||||
categories = ["Network"];
|
categories = ["Network"];
|
||||||
|
|||||||
@@ -34,8 +34,13 @@ mkNixPak {
|
|||||||
"org.kde.StatusNotifierWatcher" = "talk";
|
"org.kde.StatusNotifierWatcher" = "talk";
|
||||||
};
|
};
|
||||||
bubblewrap = {
|
bubblewrap = {
|
||||||
|
# To trace all the home files QQ accesses, you can use the following nushell command:
|
||||||
|
# just trace-access qq
|
||||||
|
# See the Justfile in the root of this repository for more information.
|
||||||
bind.rw = [
|
bind.rw = [
|
||||||
(sloth.concat [sloth.xdgConfigHome "/QQ"])
|
# given the read write permission to the following directories.
|
||||||
|
# NOTE: sloth.mkdir is used to create the directory if it does not exist!
|
||||||
|
(sloth.mkdir (sloth.concat [sloth.xdgConfigHome "/QQ"]))
|
||||||
(sloth.mkdir (sloth.concat [sloth.xdgDownloadDir "/QQ"]))
|
(sloth.mkdir (sloth.concat [sloth.xdgDownloadDir "/QQ"]))
|
||||||
];
|
];
|
||||||
sockets = {
|
sockets = {
|
||||||
|
|||||||
17
hardening/nixpaks/wechat-uos-desktop-item.nix
Normal file
17
hardening/nixpaks/wechat-uos-desktop-item.nix
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
{
|
||||||
|
makeDesktopItem,
|
||||||
|
wechat-uos,
|
||||||
|
}:
|
||||||
|
makeDesktopItem {
|
||||||
|
name = "wechat";
|
||||||
|
desktopName = "WeChat";
|
||||||
|
exec = "wechat-uos %U";
|
||||||
|
terminal = false;
|
||||||
|
# To find the icon name(nushell):
|
||||||
|
# let p = NIXPKGS_ALLOW_UNFREE=1 nix eval --impure nixpkgs#wechat-uos.outPath | str trim --char '"'
|
||||||
|
# tree $"($p)/share/icons"
|
||||||
|
icon = "${wechat-uos}/share/icons/hicolor/256x256/apps/com.tencent.wechat.png";
|
||||||
|
type = "Application";
|
||||||
|
categories = ["Network"];
|
||||||
|
comment = "Wechat boxed";
|
||||||
|
}
|
||||||
73
hardening/nixpaks/wechat-uos.nix
Normal file
73
hardening/nixpaks/wechat-uos.nix
Normal file
@@ -0,0 +1,73 @@
|
|||||||
|
# TODO: wechat-uos is running in FHS sandbox by default, it's problematic
|
||||||
|
# to wrap it again via flatpak. We need to find a way to fix it.
|
||||||
|
# https://github.com/NixOS/nixpkgs/blob/nixos-unstable/pkgs/by-name/we/wechat-uos/package.nix
|
||||||
|
# Refer:
|
||||||
|
# - Flatpak manifest's docs:
|
||||||
|
# - https://docs.flatpak.org/en/latest/manifests.html
|
||||||
|
# - https://docs.flatpak.org/en/latest/sandbox-permissions.html
|
||||||
|
# - wechat-uos's flatpak manifest: https://github.com/flathub/com.tencent.WeChat/blob/master/com.tencent.WeChat.yaml
|
||||||
|
{
|
||||||
|
lib,
|
||||||
|
pkgs,
|
||||||
|
mkNixPak,
|
||||||
|
...
|
||||||
|
}:
|
||||||
|
mkNixPak {
|
||||||
|
config = {sloth, ...}: {
|
||||||
|
app = {
|
||||||
|
package = pkgs.wechat-uos;
|
||||||
|
binPath = "bin/wechat-uos";
|
||||||
|
};
|
||||||
|
flatpak.appId = "com.tencent.WeChat";
|
||||||
|
|
||||||
|
imports = [
|
||||||
|
./modules/gui-base.nix
|
||||||
|
./modules/network.nix
|
||||||
|
];
|
||||||
|
|
||||||
|
# list all dbus services:
|
||||||
|
# ls -al /run/current-system/sw/share/dbus-1/services/
|
||||||
|
# ls -al /etc/profiles/per-user/ryan/share/dbus-1/services/
|
||||||
|
dbus.policies = {
|
||||||
|
"org.gnome.Shell.Screencast" = "talk";
|
||||||
|
# System tray icon
|
||||||
|
"org.freedesktop.Notifications" = "talk";
|
||||||
|
"org.kde.StatusNotifierWatcher" = "talk";
|
||||||
|
# File Manager
|
||||||
|
"org.freedesktop.FileManager1" = "talk";
|
||||||
|
# Uses legacy StatusNotifier implementation
|
||||||
|
"org.kde.*" = "own";
|
||||||
|
};
|
||||||
|
bubblewrap = {
|
||||||
|
# To trace all the home files QQ accesses, you can use the following nushell command:
|
||||||
|
# just trace-access wechat-uos
|
||||||
|
# See the Justfile in the root of this repository for more information.
|
||||||
|
bind.rw = [
|
||||||
|
# given the read write permission to the following directories.
|
||||||
|
# NOTE: sloth.mkdir is used to create the directory if it does not exist!
|
||||||
|
(sloth.mkdir (sloth.concat [sloth.homeDir "/.xwechat"]))
|
||||||
|
(sloth.mkdir (sloth.concat [sloth.xdgDocumentsDir "/xwechat_files"]))
|
||||||
|
(sloth.mkdir (sloth.concat [sloth.xdgDocumentsDir "/WeChat_Data/"]))
|
||||||
|
(sloth.mkdir (sloth.concat [sloth.xdgDownloadDir "/WeChat"]))
|
||||||
|
];
|
||||||
|
sockets = {
|
||||||
|
x11 = false;
|
||||||
|
wayland = true;
|
||||||
|
pipewire = true;
|
||||||
|
};
|
||||||
|
bind.dev = [
|
||||||
|
"/dev/shm" # Shared Memory
|
||||||
|
];
|
||||||
|
tmpfs = [
|
||||||
|
"/tmp"
|
||||||
|
];
|
||||||
|
|
||||||
|
env = {
|
||||||
|
# Hidpi scale
|
||||||
|
"QT_AUTO_SCREEN_SCALE_FACTOR" = "1";
|
||||||
|
# Only supports xcb
|
||||||
|
"QT_QPA_PLATFORM" = "kcb";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -24,6 +24,10 @@
|
|||||||
# my custom hardened packages
|
# my custom hardened packages
|
||||||
pkgs.nixpaks.qq
|
pkgs.nixpaks.qq
|
||||||
pkgs.nixpaks.qq-desktop-item
|
pkgs.nixpaks.qq-desktop-item
|
||||||
|
|
||||||
|
wechat-uos
|
||||||
|
# pkgs.nixpaks.wechat-uos
|
||||||
|
# pkgs.nixpaks.wechat-uos-desktop-item
|
||||||
];
|
];
|
||||||
|
|
||||||
# GitHub CLI tool
|
# GitHub CLI tool
|
||||||
|
|||||||
@@ -3,7 +3,13 @@
|
|||||||
# for Nvidia GPU
|
# for Nvidia GPU
|
||||||
# ===============================================================================================
|
# ===============================================================================================
|
||||||
|
|
||||||
boot.kernelParams = ["nvidia.NVreg_PreserveVideoMemoryAllocations=1"];
|
# https://wiki.hyprland.org/Nvidia/
|
||||||
|
boot.kernelParams = [
|
||||||
|
"nvidia.NVreg_PreserveVideoMemoryAllocations=1"
|
||||||
|
# Since NVIDIA does not load kernel mode setting by default,
|
||||||
|
# enabling it is required to make Wayland compositors function properly.
|
||||||
|
"nvidia-drm.fbdev=1"
|
||||||
|
];
|
||||||
services.xserver.videoDrivers = ["nvidia"]; # will install nvidia-vaapi-driver by default
|
services.xserver.videoDrivers = ["nvidia"]; # will install nvidia-vaapi-driver by default
|
||||||
hardware.nvidia = {
|
hardware.nvidia = {
|
||||||
open = false;
|
open = false;
|
||||||
@@ -15,6 +21,7 @@
|
|||||||
modesetting.enable = true;
|
modesetting.enable = true;
|
||||||
powerManagement.enable = true;
|
powerManagement.enable = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
hardware.nvidia-container-toolkit.enable = true;
|
hardware.nvidia-container-toolkit.enable = true;
|
||||||
hardware.graphics = {
|
hardware.graphics = {
|
||||||
enable = true;
|
enable = true;
|
||||||
|
|||||||
Reference in New Issue
Block a user