Compare

72d1c1aae5c6ef87a88e81111a74d7b041c57a22pres · 8 commits

merge base 10c71dfa653b…

Changed files

Commits

HashSubjectAuthorDate
abd25d60 changed pass to guix version Ryan Schanzenbacher
c294bf1a added pin shortcut and border color to signify Ryan Schanzenbacher
9a6ae200 final (\?) changes for the presentation demo Ryan Schanzenbacher
c33fb8d0 getting ready for pres Ryan Schanzenbacher
2afb419d Merge branch 'main' into pres Ryan Schanzenbacher
0bf0473f changed priority Ryan Schanzenbacher
c1a8a9ba test for presentation Ryan Schanzenbacher
ef0b451a updated Ryan Schanzenbacher
diff --git a/deploy.sh b/deploy.sh
index f27d6c9..4d9df96 100755
--- a/deploy.sh
+++ b/deploy.sh
@@ -61,12 +61,14 @@ copy_and_prepare() {
# Install the non-guix signing keys
echo "Installing non-guix signing keys for substitutes..."
curl -o sign-key.pub https://substitutes.nonguix.org/signing-key.pub
+ curl -o sign-key-r.pub http://129.21.94.53:8000/signing-key.pub
guix archive --authorize < sign-key.pub
+ guix archive --authorize < sign-key-r.pub
}
install_system() {
echo "Beginning install!"
- guix time-machine -C ./channels.scm -- system -L ./modules --substitute-urls='https://substitutes.nonguix.org https://bordeaux.guix.gnu.org https://ci.guix.gnu.org' init $install_hostname.scm /mnt
+ guix time-machine -C ./channels.scm -- system -L ./modules --substitute-urls='http://129.21.94.53:8080/ https://substitutes.nonguix.org https://bordeaux.guix.gnu.org https://ci.guix.gnu.org' init $install_hostname.scm /mnt
}
install_user_env() {
@@ -84,10 +86,64 @@ install_user_env() {
}
+if [[ $* == *-p ]]
+then
+ echo "Installing non-guix signing keys for substitutes..."
+ curl -o sign-key.pub https://substitutes.nonguix.org/signing-key.pub
+ curl -o sign-key-r.pub http://129.21.94.53:8000/signing-key.pub
+ guix archive --authorize < sign-key.pub
+ guix archive --authorize < sign-key-r.pub
+ guix time-machine -C ./channels.scm -- pull
+ exit 0
+elif [[ $* == *-i ]]
+then
+ gather_env
+ # Associate devs with uuids
+ root_uuid=`blkid $root_dev | awk -F\" '{print $2}'`
+ boot_uuid=`blkid $boot_dev | awk -F\" '{print $2}'`
+ swap_uuid=`blkid $swap_dev | awk -F\" '{print $2}'`
+ # Let's a go!
+ echo "Information gathered. Deploying Guix on $root_dev ($root_uuid) with boot on $boot_dev ($boot_uuid) and swap on $swap_dev ($swap_uuid)"
+ echo -n "Proceed? (y/n): "
+ read install_choice
+
+ if [ "$install_choice" != "y" ]
+ then
+ echo "Bailing!"
+ exit 1
+ fi
+
+ # We are installing!
+ # Copy template to root of repo
+ if [ "$install_type" == "e" ]
+ then
+ cp ./modules/ryan-config/deploy-templates/HostTemplateEncrypted ./$install_hostname.scm
+ elif [ "$install_type" == "d" ]
+ then
+ cp ./modules/ryan-config/deploy-templates/HostTemplate ./$install_hostname.scm
+ else
+ echo "Invalid install type (not d or e), bailing!"
+ exit 1
+ fi
+
+ # Correct the information
+ sed -i "s/ChangeMe_ROOT/$root_uuid/" ./$install_hostname.scm
+ sed -i "s/ChangeMe_BOOTEFI/$boot_uuid/" ./$install_hostname.scm
+ sed -i "s/ChangeMe_SWAP/$swap_uuid/" ./$install_hostname.scm
+ sed -i "s/ChangeMe_HOST/$install_hostname/" ./$install_hostname.scm
+
+ # Install!
+ echo "Mounting /gnu/store to destination disk..."
+ herd start cow-store /mnt
+ install_system
+ install_user_env
+ exit 0
+fi
+
gather_env
copy_and_prepare
install_system
install_user_env
# Reboot the machine at this point!
-reboot
+#reboot
diff --git a/home-config/home-configuration.scm b/home-config/home-configuration.scm
index d1e05db..d590e4d 100644
--- a/home-config/home-configuration.scm
+++ b/home-config/home-configuration.scm
@@ -94,6 +94,7 @@
"tcpdump"
"pamixer"
"git"
+ "password-store"
"node"
"git-lfs"))
(list my-neovim wl-mirror firefox-wayland-new)))
@@ -119,6 +120,7 @@
("waybar" ,(local-file "waybar" #:recursive? #t))
("alacritty" ,(local-file "alacritty" #:recursive? #t))
("aerc" ,(local-file "aerc" #:recursive? #t))
+ ("mpv" ,(local-file "mpv" #:recursive? #t))
("home-manager" ,(local-file "nix-home-manager" #:recursive? #t)) ))
(service home-files-service-type
`((".local/share/nvim/site/autoload/plug.vim" ,(local-file "nvim/plugin-manager/plug.vim"))
diff --git a/home-config/hypr/hyprland.conf b/home-config/hypr/hyprland.conf
index 66afdbb..dc07b33 100644
--- a/home-config/hypr/hyprland.conf
+++ b/home-config/hypr/hyprland.conf
@@ -119,6 +119,7 @@ bind = $mainMod, Return, exec, alacritty
bind = $mainMod SHIFT, Q, killactive
bind = $mainMod SHIFT, E, exit
bind = $mainMod SHIFT, Space, togglefloating
+bind = $mainMod SHIFT, Return, pin, active
bind = $mainMod, D, exec, fuzzel --width=35 --font='Hack:weight=bold:size=12' --background-color='282a36fa' --selection-color='3d4460fa' --line-height=20 --border-radius=20
bind = $mainMod, P, pseudo, # dwindle
bind = $mainMod, J, togglesplit, # dwindle
@@ -214,6 +215,9 @@ windowrulev2 = nofullscreenrequest, class:^(firefox)$, title:^(Firefox — Shari
windowrulev2 = float,class:^(ala-wttr)$
windowrulev2 = size 740 712, class:^(ala-wttr)$
+# Change color of pinned windows
+windowrulev2 = bordercolor rgba(bf0000ee) rgba(ab00adee) 45deg,pinned:1
+
exec-once = ~/.config/hypr/autostart.sh
misc {
diff --git a/home-config/mpv/scripts/easycrop.lua b/home-config/mpv/scripts/easycrop.lua
new file mode 100644
index 0000000..b3a84a7
--- /dev/null
+++ b/home-config/mpv/scripts/easycrop.lua
@@ -0,0 +1,253 @@
+local msg = require('mp.msg')
+local assdraw = require('mp.assdraw')
+
+local script_name = "easycrop"
+
+-- Number of crop points currently chosen (0 to 2)
+local points = {}
+-- True if in cropping selection mode
+local cropping = false
+-- Original value of osc property
+local osc_prop = false
+
+-- Helper that converts two points to top-left and bottom-right
+local swizzle_points = function (p1, p2)
+ if p1.x > p2.x then p1.x, p2.x = p2.x, p1.x end
+ if p1.y > p2.y then p1.y, p2.y = p2.y, p1.y end
+end
+
+local clamp = function (val, min, max)
+ assert(min <= max)
+ if val < min then return min end
+ if val > max then return max end
+ return val
+end
+
+local video_space_from_screen_space = function (ssp)
+ -- Video native dimensions and screen size
+ local vid_w = mp.get_property("width")
+ local vid_h = mp.get_property("height")
+ local osd_w = mp.get_property("osd-width")
+ local osd_h = mp.get_property("osd-height")
+
+ -- Factor by which the video is scaled to fit the screen
+ local scale = math.min(osd_w/vid_w, osd_h/vid_h)
+
+ -- Size video takes up in screen
+ local vid_sw, vid_sh = scale*vid_w, scale*vid_h
+
+ -- Video offset within screen
+ local off_x = math.floor((osd_w - vid_sw)/2)
+ local off_y = math.floor((osd_h - vid_sh)/2)
+
+ local vsp = {}
+
+ -- Move the point to within the video
+ vsp.x = clamp(ssp.x, off_x, off_x + vid_sw)
+ vsp.y = clamp(ssp.y, off_y, off_y + vid_sh)
+
+ -- Convert screen-space to video-space
+ vsp.x = math.floor((vsp.x - off_x) / scale)
+ vsp.y = math.floor((vsp.y - off_y) / scale)
+
+ return vsp
+end
+
+local screen_space_from_video_space = function (vsp)
+ -- Video native dimensions and screen size
+ local vid_w = mp.get_property("width")
+ local vid_h = mp.get_property("height")
+ local osd_w = mp.get_property("osd-width")
+ local osd_h = mp.get_property("osd-height")
+
+ -- Factor by which the video is scaled to fit the screen
+ local scale = math.min(osd_w/vid_w, osd_h/vid_h)
+
+ -- Size video takes up in screen
+ local vid_sw, vid_sh = scale*vid_w, scale*vid_h
+
+ -- Video offset within screen
+ local off_x = math.floor((osd_w - vid_sw)/2)
+ local off_y = math.floor((osd_h - vid_sh)/2)
+
+ local ssp = {}
+ ssp.x = vsp.x * scale + off_x
+ ssp.y = vsp.y * scale + off_y
+ return ssp
+end
+
+-- Wrapper that converts RRGGBB / RRGGBBAA to ASS format
+local ass_set_color = function (idx, color)
+ assert(color:len() == 8 or color:len() == 6)
+ local ass = ""
+
+ -- Set alpha value (if present)
+ if color:len() == 8 then
+ local alpha = 0xff - tonumber(color:sub(7, 8), 16)
+ ass = ass .. string.format("\\%da&H%X&", idx, alpha)
+ end
+
+ -- Swizzle RGB to BGR and build ASS string
+ color = color:sub(5, 6) .. color:sub(3, 4) .. color:sub(1, 2)
+ return "{" .. ass .. string.format("\\%dc&H%s&", idx, color) .. "}"
+end
+
+local draw_rect = function (p1, p2)
+ local osd_w, osd_h = mp.get_property("osd-width"), mp.get_property("osd-height")
+
+ ass = assdraw.ass_new()
+
+ -- Draw overlay over surrounding unselected region
+
+ ass:draw_start()
+ ass:pos(0, 0)
+
+ ass:append(ass_set_color(1, "000000aa"))
+ ass:append(ass_set_color(3, "00000000"))
+
+ local l = math.min(p1.x, p2.x)
+ local r = math.max(p1.x, p2.x)
+ local u = math.min(p1.y, p2.y)
+ local d = math.max(p1.y, p2.y)
+
+ ass:rect_cw(0, 0, l, osd_h)
+ ass:rect_cw(r, 0, osd_w, osd_h)
+ ass:rect_cw(l, 0, r, u)
+ ass:rect_cw(l, d, r, osd_h)
+
+ ass:draw_stop()
+
+ -- Draw border around selected region
+
+ ass:new_event()
+ ass:draw_start()
+ ass:pos(0, 0)
+
+ ass:append(ass_set_color(1, "00000000"))
+ ass:append(ass_set_color(3, "000000ff"))
+ ass:append("{\\bord2}")
+
+ ass:rect_cw(p1.x, p1.y, p2.x, p2.y)
+
+ ass:draw_stop()
+
+ mp.set_osd_ass(osd_w, osd_h, ass.text)
+end
+
+local draw_fill = function ()
+ local osd_w, osd_h = mp.get_property("osd-width"), mp.get_property("osd-height")
+
+ ass = assdraw.ass_new()
+ ass:draw_start()
+ ass:pos(0, 0)
+
+ ass:append(ass_set_color(1, "000000aa"))
+ ass:append(ass_set_color(3, "00000000"))
+ ass:rect_cw(0, 0, osd_w, osd_h)
+
+ ass:draw_stop()
+ mp.set_osd_ass(osd_w, osd_h, ass.text)
+end
+
+local draw_clear = function ()
+ local osd_w, osd_h = mp.get_property("osd-width"), mp.get_property("osd-height")
+ mp.set_osd_ass(osd_w, osd_h, "")
+end
+
+local draw_cropper = function ()
+ if #points == 1 then
+ local p1 = screen_space_from_video_space(points[1])
+ local p2 = {}
+ p2.x, p2.y = mp.get_mouse_pos()
+ draw_rect(p1, p2)
+ end
+end
+
+local uncrop = function ()
+ mp.command("no-osd vf del @" .. script_name .. ":crop")
+end
+
+local crop = function(p1, p2)
+ swizzle_points(p1, p2)
+
+ local w = p2.x - p1.x
+ local h = p2.y - p1.y
+ local ok, err = mp.command(string.format(
+ "no-osd vf add @%s:crop=%s:%s:%s:%s", script_name, w, h, p1.x, p1.y))
+
+ if not ok then
+ mp.osd_message("Cropping failed")
+ points = {}
+ end
+end
+
+local easycrop_stop = function ()
+ mp.set_property("osc", osc_prop)
+ cropping = false
+ mp.remove_key_binding("easycrop_mouse_btn0")
+ draw_clear()
+end
+
+local mouse_btn0_cb = function ()
+ if not cropping then
+ return
+ end
+
+ local mx, my = mp.get_mouse_pos()
+ table.insert(points, video_space_from_screen_space({ x = mx, y = my }))
+
+ if #points == 2 then
+ crop(points[1], points[2])
+ easycrop_stop()
+ end
+end
+
+local easycrop_start = function ()
+ -- Cropping requires swdec or hwdec with copy-back
+ local hwdec = mp.get_property("hwdec-current")
+ if hwdec == nil then
+ return mp.msg.error("Cannot determine current hardware decoder mode")
+ end
+ -- Check whitelist of ok values
+ local valid_hwdec = {
+ ["no"] = true, -- software decoding
+ -- Taken from mpv manual
+ ["videotoolbox-co"] = true,
+ ["vaapi-copy"] = true,
+ ["dxva2-copy"] = true,
+ ["d3d11va-copy"] = true,
+ ["mediacodec"] = true
+ }
+ if not valid_hwdec[hwdec] then
+ return mp.osd_message("Cropping requires swdec or hwdec with copy-back (see mpv manual)")
+ end
+
+ -- Just clear the current crop and return, if there is one
+ if #points ~= 0 then
+ uncrop()
+ points = {}
+ return
+ end
+
+ -- Hide OSC
+ osc_prop = mp.get_property("osc")
+ mp.set_property("osc", "no")
+
+ cropping = true
+ mp.add_forced_key_binding("mouse_btn0", "easycrop_mouse_btn0", mouse_btn0_cb)
+ draw_fill()
+end
+
+local easycrop_activate = function ()
+ if cropping then
+ easycrop_stop()
+ else
+ easycrop_start()
+ end
+end
+
+mp.add_key_binding("mouse_move", draw_cropper)
+mp.observe_property("osd-width", "native", draw_cropper)
+mp.observe_property("osd-height", "native", draw_cropper)
+
+mp.add_key_binding("c", "easy_crop", easycrop_activate)
diff --git a/home-config/nix-home-manager/home.nix b/home-config/nix-home-manager/home.nix
index 8a37125..292f8ba 100644
--- a/home-config/nix-home-manager/home.nix
+++ b/home-config/nix-home-manager/home.nix
@@ -28,8 +28,7 @@
# # "Hello, world!" when run.
# pkgs.hello
yt-dlp
- xdg-desktop-portal-hyprland
- pass
+ #pass
rustup
gcc
pkg-config
diff --git a/modules/ryan-config/base-system.scm b/modules/ryan-config/base-system.scm
index bf16141..c6e5d0e 100644
--- a/modules/ryan-config/base-system.scm
+++ b/modules/ryan-config/base-system.scm
@@ -186,7 +186,7 @@
(guix-configuration
(inherit config)
(substitute-urls
- (append (list "https://substitutes.nonguix.org")
+ (append (list "https://substitutes.nonguix.org" "http://129.21.94.53:8080")
%default-substitute-urls))
(authorized-keys
(cons* (plain-file "non-guix.pub"
@@ -195,7 +195,12 @@
(curve Ed25519)
(q #C1FD53E5D4CE971933EC50C9F307AE2171A2D3B52C804642A7A35F84F3A4EA98#)
)
- )" ) %default-authorized-guix-keys))))
+ )" )
+ (plain-file "ryan-key.pub"
+ "(public-key
+ (ecc
+ (curve Ed25519)
+ (q #24ED64A7C001DAC05D47F586623EAC4C1F4BD2D267686D5781A9098808160ADC#)))" ) %default-authorized-guix-keys))))
(udev-service-type config =>
(udev-configuration
(inherit config)
diff --git a/modules/ryan-packages/web-server.scm b/modules/ryan-packages/web-server.scm
new file mode 100644
index 0000000..eb1c539
--- /dev/null
+++ b/modules/ryan-packages/web-server.scm
@@ -0,0 +1,63 @@
+(define-module (ryan-packages web-server)
+ #:use-module (guix download)
+ #:use-module (guix packages)
+ #:use-module (guix gexp)
+ #:use-module (gnu packages)
+ #:use-module ((guix licenses) #:prefix license:)
+ #:use-module (guix build-system go)
+ #:use-module (guix git-download)
+ #:use-module (gnu packages golang)
+ #:use-module (guix utils))
+
+(define-public go-github-com-caddy-certmagic
+ (package
+ (name "certmagic")
+ (version "0.19.2")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/caddyserver/certmagic")
+ (commit (string-append "v" version))))
+ (sha256
+ (base32
+ "0jgbkj0azkbs828vsd3gycpab8pycgf55vrxkvnfmwfjpdiq1551"))))
+ (build-system go-build-system)
+ (arguments
+ (list #:tests? #f
+ #:go go-1.20
+ #:import-path "github.com/caddyserver/certmagic"))
+ (home-page "https://github.com/caddyserver/certmagic")
+ (synopsis "Certbot ACME")
+ (description "Automagic certificate management in Caddy")
+ (license license:expat)))
+
+(define-public caddy
+ (package
+ (name "Caddy")
+ (version "2.7.4")
+ (source (origin
+ (method git-fetch)
+ (uri (git-reference
+ (url "https://github.com/caddyserver/caddy")
+ (commit (string-append "v" version))))
+ (sha256
+ (base32
+ "0jgbkj0azkbs828vsd3gycpab8pycgf55vrxkvnfmwfjpdiq1551"))))
+ (build-system go-build-system)
+ (native-inputs (list go-github-com-google-uuid
+ go-go-uber-org-zap
+ go-github-com-caddy-certmagic
+ go-github-com-prometheus-client-golang
+ go-golang-org-x-term
+ go-golang-org-x-sys))
+ (arguments
+ (list #:tests? #f
+ #:go go-1.20
+ ;#:unpack-path "github.com/caddyserver/caddy"
+ #:import-path "github.com/caddyserver/caddy"))
+ (home-page "https://github.com/caddyserver/caddy")
+ (synopsis "Web server")
+ (description "This package serves the web")
+ (license license:expat)))
+
+caddy