Merge branch 'main' into teutat3s

This commit is contained in:
teutat3s 2022-08-24 20:32:28 +02:00
commit b4c782e65a
Signed by: teutat3s
GPG key ID: 4FA1D3FA524F22C1
23 changed files with 214 additions and 77 deletions

View file

@ -3,4 +3,4 @@ authors = ["Timothy DeHerrera"]
language = "en" language = "en"
multilingual = false multilingual = false
src = "." src = "."
title = "devos docs" title = "PubSolarOS documentation"

View file

@ -9,30 +9,34 @@ in
default = false; default = false;
description = "Feature flag for iso builds"; description = "Feature flag for iso builds";
}; };
options.pub-solar.core.disk-encryption-active = mkOption { options.pub-solar.core.disk-encryption-active = mkOption {
type = types.bool; type = types.bool;
default = true; default = true;
description = "Whether it should be assumed that there is a cryptroot device"; description = "Whether it should be assumed that there is a cryptroot device";
}; };
config = { config = {
# Enable plymouth for better experience of booting boot = {
boot.plymouth.enable = true; # Enable plymouth for better experience of booting
plymouth.enable = true;
# Mount / luks device in initrd # Mount / luks device in initrd
# Allow fstrim to work on it. # Allow fstrim to work on it.
# The ! makes this enabled by default # The ! makes this enabled by default
boot.initrd = mkIf (!cfg.iso-options.enable && cfg.disk-encryption-active) { initrd = mkIf (!cfg.iso-options.enable && cfg.disk-encryption-active) {
luks.devices."cryptroot" = { luks.devices."cryptroot" = {
allowDiscards = true; allowDiscards = true;
};
}; };
loader.systemd-boot.enable = true;
# Use latest LTS linux kernel by default
kernelPackages = pkgs.linuxPackages_5_15;
# Support ntfs drives
supportedFilesystems = [ "ntfs" ];
}; };
boot.loader.systemd-boot.enable = true;
# Use latest LTS linux kernel by default
boot.kernelPackages = pkgs.linuxPackages_5_15;
# Support ntfs drives
boot.supportedFilesystems = [ "ntfs" ];
}; };
} }

View file

@ -8,6 +8,7 @@ in
{ {
imports = [ imports = [
./boot.nix ./boot.nix
./hibernation.nix
./fonts.nix ./fonts.nix
./i18n.nix ./i18n.nix
./networking.nix ./networking.nix

View file

@ -0,0 +1,38 @@
{ config, pkgs, lib, ... }:
with lib;
let
cfg = config.pub-solar.core.hibernation;
in
{
options.pub-solar.core.hibernation = {
enable = mkOption {
type = types.bool;
default = false;
description = "Whether the device can hibernate. This creates a swapfile at /swapfile.";
};
resumeDevice = mkOption {
type = types.str;
default = "/swapfile";
description = "The location of the hibernation resume swap file.";
};
resumeOffset = mkOption {
type = types.nullOr types.int;
default = null;
description = "The swap file offset. Can be found by running `filefrag -v $swap_file_location`. See https://wiki.archlinux.org/title/Power_management/Suspend_and_hibernate#Hibernation_into_swap_file";
};
};
config = {
boot = mkIf cfg.enable {
resumeDevice = cfg.resumeDevice;
kernelParams = [
"resume=${cfg.resumeDevice}"
] ++ (
if (cfg.resumeOffset == null && cfg.enable) then builtins.abort "config.pub-solar.resumeOffset has to be set if config.pub-solar.enable is true."
else [ "resume_offset=${cfg.resumeOffset}" ]
);
};
};
}

View file

@ -34,20 +34,26 @@ in
# These entries get added to /etc/hosts # These entries get added to /etc/hosts
networking.hosts = { networking.hosts = {
"127.0.0.1" = [ "cups.local" ]; "127.0.0.1" = [ "cups.local" "help.local" "caddy.local" ];
}; };
# Caddy reverse proxy for local services like cups # Caddy reverse proxy for local services like cups
services.caddy = { services.caddy = {
enable = true; enable = true;
globalConfig = '' globalConfig = ''
default_bind 127.0.0.1
auto_https off auto_https off
''; '';
extraConfig = '' extraConfig = ''
cups.local:80 cups.local:80 {
bind 127.0.0.1 request_header Host localhost:631
request_header Host localhost:631 reverse_proxy unix//run/cups/cups.sock
reverse_proxy unix//run/cups/cups.sock }
help.local:80 {
root * ${pkgs.psos-docs}/lib/html
file_server
}
''; '';
}; };
}; };

View file

@ -0,0 +1,24 @@
{ config, lib, ... }:
with lib;
let
psCfg = config.pub-solar;
cfg = config.pub-solar.paranoia;
in
{
options.pub-solar.paranoia = {
enable = mkOption {
description = ''
Only offer hibernation instead of screen locking and sleeping. This only makes sense
if your hard drive is encrypted, and ensures that the contents of your drive are
encrypted if you are not actively using the device.
'';
default = false;
type = types.bool;
};
};
config = mkIf cfg.enable {
pub-solar.core.hibernation.enable = true;
};
}

View file

@ -14,8 +14,9 @@ assign [app_id="telegramdesktop"] $ws4
# Launcher # Launcher
for_window [app_id="launcher" title="Alacritty"] floating enable, border pixel 10, sticky enable for_window [app_id="launcher" title="Alacritty"] floating enable, border pixel 10, sticky enable
for_window [app_id="pavucontrol"] floating enable, border pixel 10, sticky enable
# Floating menus # Floating menus
for_window [app_id="pavucontrol"] floating enable
for_window [app_id="blueman-manager"] floating enable for_window [app_id="blueman-manager"] floating enable
# Open specific applications in floating mode # Open specific applications in floating mode
@ -60,10 +61,14 @@ for_window [window_type="dialog"] floating enable
for_window [window_type="menu"] floating enable for_window [window_type="menu"] floating enable
for_window [title="About Mozilla Firefox"] floating enable for_window [title="About Mozilla Firefox"] floating enable
for_window [title="Password Required - Mozilla Firefox"] floating enable for_window [title="Password Required - Mozilla Firefox"] floating enable
for_window [title="Firefox — Sharing Indicator"] move to workspace $ws7, floating enable
no_focus [title="Firefox — Sharing Indicator"]
for_window [title="Extension: (Open in Browser)*"] floating enable for_window [title="Extension: (Open in Browser)*"] floating enable
# Technical media stuff happens on ws7
for_window [app_id="screen-recorder" title="Alacritty"] move to workspace $ws7, floating disable
no_focus [app_id="screen-recorder"]
for_window [title="Firefox — Sharing Indicator"] move to workspace $ws7, floating disable
no_focus [title="Firefox — Sharing Indicator"]
# qMasterPassword floating menu # qMasterPassword floating menu
for_window [title="qMasterPassword"] focus for_window [title="qMasterPassword"] focus
for_window [title="qMasterPassword"] floating enable for_window [title="qMasterPassword"] floating enable

View file

@ -13,41 +13,30 @@ bindsym $mod+Ctrl+m exec pavucontrol
################################################################################################ ################################################################################################
# Quickstart application shortcuts # Quickstart application shortcuts
bindsym $mod+F1 exec qMasterPassword bindsym $mod+F1 exec psos help
bindsym $mod+Shift+h exec psos help
bindsym $mod+F2 exec firefox bindsym $mod+F2 exec firefox
bindsym $mod+F3 exec $term -e vifm bindsym $mod+F3 exec $term -e vifm
bindsym $mod+Shift+F3 exec gksu $term -e vifm bindsym $mod+Shift+F3 exec gksu $term -e vifm
bindsym $mod+F4 exec nautilus -w bindsym $mod+F4 exec nautilus -w
bindsym $mod+Shift+F4 exec signal-desktop --use-tray-icon bindsym $mod+Shift+F4 exec signal-desktop --use-tray-icon
bindsym $mod+F5 exec $term -e 'mocp -C $XDG_CONFIG_DIR/mocp/config'
bindsym $mod+Shift+m exec mu
bindsym $mod+Shift+h exec xdg-open /usr/share/doc/manjaro/i3_help.pdf
# Notifications with swaynotificationcenter # Notifications with swaynotificationcenter
# Toggle control center # Toggle control center
bindsym $mod+Shift+n exec swaync-client -t -sw bindsym $mod+Shift+n exec swaync-client -t -sw
# Screenshots bindsym $mod+Shift+m exec qMasterPassword
# Screenshots and screen recordings
bindsym $mod+Ctrl+p exec grim -g "$(slurp -d -b \#ffffff11)" ~/Pictures/Screenshots/$(date +%Y%m%d_%Hh%Mm%Ss)_grim.png bindsym $mod+Ctrl+p exec grim -g "$(slurp -d -b \#ffffff11)" ~/Pictures/Screenshots/$(date +%Y%m%d_%Hh%Mm%Ss)_grim.png
bindsym $mod+Shift+p exec grim ~/Pictures/Screenshots/$(date +%Y%m%d_%Hh%Mm%Ss)_grim.png bindsym $mod+Shift+p exec grim ~/Pictures/Screenshots/$(date +%Y%m%d_%Hh%Mm%Ss)_grim.png
bindsym $mod+Ctrl+f exec "( pkill flameshot || true && flameshot & ) && ( sleep 0.5s && flameshot gui )" bindsym $mod+Ctrl+f exec "( pkill flameshot || true && flameshot & ) && ( sleep 0.5s && flameshot gui )"
bindsym $mod+Ctrl+r exec record-screen
# Launcher # Launcher
set $menu exec alacritty --class launcher -e env TERMINAL_COMMAND="alacritty -e" sway-launcher set $menu exec alacritty --class launcher -e env TERMINAL_COMMAND="alacritty -e" sway-launcher
bindsym $mod+Space exec $menu bindsym $mod+Space exec $menu
# Set shut down, restart and locking features
set $mode_system (l)ock, (e)xit, (s)uspend, (h)ibernate, (r)eboot, (Shift+s)hutdown
bindsym $mod+0 mode "$mode_system"
mode "$mode_system" {
bindsym l exec swaylock-bg, mode "default"
bindsym e exec systemctl --user stop graphical-session.target, mode "default"
bindsym s exec systemctl suspend, mode "default"
bindsym h exec systemctl hibernate, mode "default"
bindsym r exec systemctl reboot, mode "default"
bindsym Shift+s exec systemctl poweroff, mode "default"
# exit system mode: "Enter" or "Escape"
bindsym Return mode "default"
bindsym Escape mode "default"
}

View file

@ -0,0 +1,21 @@
{ psCfg, ... }: ''
# Set shut down, restart and locking features
set $mode_system (e)xit, (h)ibernate, (r)eboot, (Shift+s)hutdown
bindsym $mod+0 mode "$mode_system"
mode "$mode_system" {
bindsym e exec swaymsg exit, mode "default"
'' + (if !psCfg.core.hibernation.enable then ''
bindsym h exec systemctl hibernate, mode "default"
'' else "")
+ (if !psCfg.paranoia.enable then ''
bindsym l exec swaylock-bg, mode "default"
bindsym s exec systemctl suspend, mode "default"
'' else "") + ''
bindsym r exec systemctl reboot, mode "default"
bindsym Shift+s exec systemctl poweroff, mode "default"
# exit system mode: "Enter" or "Escape"
bindsym Return mode "default"
bindsym Escape mode "default"
}
''

View file

@ -50,7 +50,7 @@
floating_modifier $mod normal floating_modifier $mod normal
# Reload the configuration file # Reload the configuration file
bindsym $mod+Ctrl+r reload bindsym $mod+F5 reload
# #
# Moving around: # Moving around:

View file

@ -2,25 +2,26 @@
with lib; with lib;
let let
psCfg = config.pub-solar; psCfg = config.pub-solar;
cfg = config.pub-solar.sway;
in in
{ {
options.pub-solar.sway = { options.pub-solar.sway = {
enable = mkEnableOption "Life in boxes"; enable = mkEnableOption "Life in boxes";
};
options.pub-solar.sway.terminal = mkOption { terminal = mkOption {
type = types.nullOr types.str; type = types.nullOr types.str;
default = "alacritty"; default = "alacritty";
description = "Choose sway's default terminal"; description = "Choose sway's default terminal";
}; };
options.pub-solar.sway.v4l2loopback.enable = mkOption {
type = types.bool; v4l2loopback.enable = mkOption {
default = true; type = types.bool;
description = "WebCam streaming tool"; default = true;
description = "WebCam streaming tool";
};
}; };
config = mkIf cfg.enable (mkMerge [ config = mkIf psCfg.sway.enable (mkMerge [
(mkIf (cfg.v4l2loopback.enable) { (mkIf (psCfg.sway.v4l2loopback.enable) {
boot.extraModulePackages = with config.boot.kernelPackages; [ v4l2loopback ]; boot.extraModulePackages = with config.boot.kernelPackages; [ v4l2loopback ];
boot.kernelModules = [ "v4l2loopback" ]; boot.kernelModules = [ "v4l2loopback" ];
boot.extraModprobeConfig = '' boot.extraModprobeConfig = ''
@ -76,8 +77,8 @@ in
xsettingsd xsettingsd
ydotool ydotool
swaylock-bg
sway-launcher sway-launcher
record-screen
import-gtk-settings import-gtk-settings
s s
wcwd wcwd
@ -87,17 +88,18 @@ in
#programs.waybar.systemd.enable = true; #programs.waybar.systemd.enable = true;
systemd.user.services.swaynotificationcenter = import ./swaynotificationcenter.service.nix pkgs; systemd.user.services.swaynotificationcenter = import ./swaynotificationcenter.service.nix pkgs;
systemd.user.services.sway = import ./sway.service.nix pkgs; systemd.user.services.sway = import ./sway.service.nix { inherit pkgs psCfg; };
systemd.user.services.swayidle = import ./swayidle.service.nix pkgs; systemd.user.services.swayidle = import ./swayidle.service.nix { inherit pkgs psCfg; };
systemd.user.services.xsettingsd = import ./xsettingsd.service.nix pkgs; systemd.user.services.xsettingsd = import ./xsettingsd.service.nix { inherit pkgs psCfg; };
systemd.user.services.waybar = import ./waybar.service.nix pkgs; systemd.user.services.waybar = import ./waybar.service.nix { inherit pkgs psCfg; };
systemd.user.targets.sway-session = import ./sway-session.target.nix pkgs; systemd.user.targets.sway-session = import ./sway-session.target.nix { inherit pkgs psCfg; };
xdg.configFile."sway/config".text = import ./config/config.nix { inherit config pkgs; }; xdg.configFile."sway/config".text = import ./config/config.nix { inherit config pkgs; };
xdg.configFile."sway/config.d/colorscheme.conf".source = ./config/config.d/colorscheme.conf; xdg.configFile."sway/config.d/colorscheme.conf".source = ./config/config.d/colorscheme.conf;
xdg.configFile."sway/config.d/theme.conf".source = ./config/config.d/theme.conf; xdg.configFile."sway/config.d/theme.conf".source = ./config/config.d/theme.conf;
xdg.configFile."sway/config.d/gaps.conf".source = ./config/config.d/gaps.conf; xdg.configFile."sway/config.d/gaps.conf".source = ./config/config.d/gaps.conf;
xdg.configFile."sway/config.d/custom-keybindings.conf".source = ./config/config.d/custom-keybindings.conf; xdg.configFile."sway/config.d/custom-keybindings.conf".source = ./config/config.d/custom-keybindings.conf;
xdg.configFile."sway/config.d/mode_system.conf".text = import ./config/config.d/mode_system.conf.nix { inherit psCfg; };
xdg.configFile."sway/config.d/applications.conf".source = ./config/config.d/applications.conf; xdg.configFile."sway/config.d/applications.conf".source = ./config/config.d/applications.conf;
xdg.configFile."sway/config.d/systemd.conf".source = ./config/config.d/systemd.conf; xdg.configFile."sway/config.d/systemd.conf".source = ./config/config.d/systemd.conf;
}; };

View file

@ -1,4 +1,4 @@
pkgs: { pkgs, ... }:
{ {
Unit = { Unit = {
Description = "set color temperature of display according to time of day"; Description = "set color temperature of display according to time of day";

View file

@ -1,4 +1,4 @@
pkgs: { pkgs, ... }:
{ {
Unit = { Unit = {
Description = "Actions gestures on your touchpad using libinput"; Description = "Actions gestures on your touchpad using libinput";

View file

@ -1,4 +1,4 @@
pkgs: { pkgs, ... }:
{ {
Unit = { Unit = {
Description = "sway compositor session"; Description = "sway compositor session";

View file

@ -1,4 +1,4 @@
pkgs: { pkgs, ... }:
{ {
Unit = { Unit = {
Description = "sway - SirCmpwn's Wayland window manager"; Description = "sway - SirCmpwn's Wayland window manager";

View file

@ -1,4 +1,4 @@
pkgs: { pkgs, psCfg, ... }:
{ {
Unit = { Unit = {
Description = "Idle manager for Wayland"; Description = "Idle manager for Wayland";
@ -9,8 +9,13 @@ pkgs:
}; };
Service = { Service = {
Type = "simple"; Type = "simple";
Environment = "PATH=/run/current-system/sw/bin:${pkgs.sway}/bin:${pkgs.swaylock}/bin:${pkgs.swaylock-bg}/bin"; Environment = "PATH=/run/current-system/sw/bin:${pkgs.sway}/bin";
ExecStart = ''${pkgs.swayidle}/bin/swayidle -w \ ExecStart = if psCfg.paranoia.enable then ''
${pkgs.swayidle}/bin/swayidle -w \
timeout 120 'swaymsg "output * dpms off"' \
timeout 150 'systemctl hibernate' \
'' else ''
${pkgs.swayidle}/bin/swayidle -w \
timeout 600 'swaylock-bg' \ timeout 600 'swaylock-bg' \
timeout 900 'swaymsg "output * dpms off"' \ timeout 900 'swaymsg "output * dpms off"' \
resume 'swaymsg "output * dpms on"' \ resume 'swaymsg "output * dpms on"' \

View file

@ -1,4 +1,4 @@
pkgs: { pkgs, ... }:
{ {
Unit = { Unit = {
Description = "Highly customizable Wayland bar for Sway and Wlroots based compositors."; Description = "Highly customizable Wayland bar for Sway and Wlroots based compositors.";

View file

@ -1,4 +1,4 @@
pkgs: { pkgs, ... }:
{ {
Unit = { Unit = {
Description = "X Settings Daemon"; Description = "X Settings Daemon";

View file

@ -1,4 +1,4 @@
pkgs: { pkgs, ... }:
{ {
Unit = { Unit = {
Description = "ydotool - Generic command-line automation tool (no X!)"; Description = "ydotool - Generic command-line automation tool (no X!)";

View file

@ -11,14 +11,16 @@ with final; {
mu = writeShellScriptBin "mu" (import ./mu.nix final); mu = writeShellScriptBin "mu" (import ./mu.nix final);
notes = writeShellScriptBin "notes" (import ./notes.nix final); notes = writeShellScriptBin "notes" (import ./notes.nix final);
psos = writeShellScriptBin "psos" (import ./psos.nix final); psos = writeShellScriptBin "psos" (import ./psos.nix final);
psos-docs = import ./psos-docs.nix final;
s = writeShellScriptBin "s" (import ./s.nix final); s = writeShellScriptBin "s" (import ./s.nix final);
sway-launcher = writeScriptBin "sway-launcher" (import ./sway-launcher.nix final); sway-launcher = writeScriptBin "sway-launcher" (import ./sway-launcher.nix final);
sway-service = writeShellScriptBin "sway-service" (import ./sway-service.nix final); sway-service = writeShellScriptBin "sway-service" (import ./sway-service.nix final);
swaylock-bg = writeScriptBin "swaylock-bg" (import ./swaylock-bg.nix final); swaylock-bg = writeShellScriptBin "swaylock-bg" (import ./swaylock-bg.nix final);
toggle-kbd-layout = writeShellScriptBin "toggle-kbd-layout" (import ./toggle-kbd-layout.nix final); toggle-kbd-layout = writeShellScriptBin "toggle-kbd-layout" (import ./toggle-kbd-layout.nix final);
uhk-agent = import ./uhk-agent.nix final; uhk-agent = import ./uhk-agent.nix final;
wcwd = writeShellScriptBin "wcwd" (import ./wcwd.nix final); wcwd = writeShellScriptBin "wcwd" (import ./wcwd.nix final);
drone-docker-runner = writeShellScriptBin "drone-docker-runner" (import ./drone-docker-runner.nix final); drone-docker-runner = writeShellScriptBin "drone-docker-runner" (import ./drone-docker-runner.nix final);
record-screen = writeShellScriptBin "record-screen" (import ./record-screen.nix final);
# ps-fixes # ps-fixes
} }

26
pkgs/psos-docs.nix Normal file
View file

@ -0,0 +1,26 @@
self: with self;
stdenv.mkDerivation rec {
pname = "psos-docs";
version = "0.0.1";
buildInputs = [
mdbook
mdbook-pdf
];
src = ../docs/..; # wut
phases = [ "buildPhase" "installPhase" ];
buildPhase = ''
cp -r $src/doc ./doc
cp $src/README.md ./README.md
chmod ug+w -R .
ls -la .
mdbook build doc
'';
installPhase = ''
mkdir -p $out/lib/
cp -r doc/book $out/lib/html
'';
}

View file

@ -14,6 +14,10 @@ self: with self; ''
shift; shift;
exec nixos-option -I nixpkgs=/etc/nixos/lib/compat $@ exec nixos-option -I nixpkgs=/etc/nixos/lib/compat $@
;; ;;
help)
shift;
exec xdg-open http://help.local/
;;
*) *)
if [[ "$@" != "" ]]; then if [[ "$@" != "" ]]; then
echo "Unknown command: psos $@" echo "Unknown command: psos $@"

10
pkgs/record-screen.nix Normal file
View file

@ -0,0 +1,10 @@
self: with self; ''
mkdir -p "$HOME/Videos/Screenrecordings"
GEOMETRY="$(slurp -d -b \#ffffff11)"
RESOLUTION="$(echo $GEOMETRY | awk '{print $2}')"
FILE_LOCATION="$HOME/Videos/Screenrecordings/$(${coreutils}/bin/date +%Y%m%d_%Hh%Mm%Ss)_$RESOLUTION.mp4"
echo "Recording $GEOMETRY into $FILE_LOCATION"
${alacritty}/bin/alacritty \
--class screen-recorder \
-e ${wf-recorder}/bin/wf-recorder -g "$GEOMETRY" -f "$FILE_LOCATION"
''