Deployment and lifecycle management for Nix
0
fork

Configure Feed

Select the types of activity you want to include in your feed.

feat(server): client bootstrap script knows sower url

+65 -42
+19 -19
Cargo.lock
··· 192 192 193 193 [[package]] 194 194 name = "cc" 195 - version = "1.0.104" 195 + version = "1.1.0" 196 196 source = "registry+https://github.com/rust-lang/crates.io-index" 197 - checksum = "74b6a57f98764a267ff415d50a25e6e166f3831a5071af4995296ea97d210490" 197 + checksum = "eaff6f8ce506b9773fa786672d63fc7a191ffea1be33f72bbd4aeacefca9ffc8" 198 198 199 199 [[package]] 200 200 name = "cfg-if" ··· 210 210 211 211 [[package]] 212 212 name = "clap" 213 - version = "4.5.8" 213 + version = "4.5.9" 214 214 source = "registry+https://github.com/rust-lang/crates.io-index" 215 - checksum = "84b3edb18336f4df585bc9aa31dd99c036dfa5dc5e9a2939a722a188f3a8970d" 215 + checksum = "64acc1846d54c1fe936a78dc189c34e28d3f5afc348403f28ecf53660b9b8462" 216 216 dependencies = [ 217 217 "clap_builder", 218 218 "clap_derive", ··· 220 220 221 221 [[package]] 222 222 name = "clap_builder" 223 - version = "4.5.8" 223 + version = "4.5.9" 224 224 source = "registry+https://github.com/rust-lang/crates.io-index" 225 - checksum = "c1c09dd5ada6c6c78075d6fd0da3f90d8080651e2d6cc8eb2f1aaa4034ced708" 225 + checksum = "6fb8393d67ba2e7bfaf28a23458e4e2b543cc73a99595511eb207fdb8aede942" 226 226 dependencies = [ 227 227 "anstream", 228 228 "anstyle", ··· 828 828 [[package]] 829 829 name = "phoenix_channels_client" 830 830 version = "0.9.0" 831 - source = "git+https://github.com/liveview-native/phoenix-channels-client.git#fe5fde8349c2a59a90f61bcf05f6de7fd1143ded" 831 + source = "git+https://github.com/liveview-native/phoenix-channels-client.git#466f635b4467fd545bd868cd59151711ec30684b" 832 832 dependencies = [ 833 833 "arc-swap", 834 834 "atomic-take", ··· 1132 1132 1133 1133 [[package]] 1134 1134 name = "serde" 1135 - version = "1.0.203" 1135 + version = "1.0.204" 1136 1136 source = "registry+https://github.com/rust-lang/crates.io-index" 1137 - checksum = "7253ab4de971e72fb7be983802300c30b5a7f0c2e56fab8abfc6a214307c0094" 1137 + checksum = "bc76f558e0cbb2a839d37354c575f1dc3fdc6546b5be373ba43d95f231bf7c12" 1138 1138 dependencies = [ 1139 1139 "serde_derive", 1140 1140 ] 1141 1141 1142 1142 [[package]] 1143 1143 name = "serde_derive" 1144 - version = "1.0.203" 1144 + version = "1.0.204" 1145 1145 source = "registry+https://github.com/rust-lang/crates.io-index" 1146 - checksum = "500cbc0ebeb6f46627f50f3f5811ccf6bf00643be300b4c3eabc0ef55dc5b5ba" 1146 + checksum = "e0cd7e117be63d3c3678776753929474f3b04a43a080c744d6b0ae2a8c28e222" 1147 1147 dependencies = [ 1148 1148 "proc-macro2", 1149 1149 "quote", ··· 1327 1327 1328 1328 [[package]] 1329 1329 name = "syn" 1330 - version = "2.0.68" 1330 + version = "2.0.70" 1331 1331 source = "registry+https://github.com/rust-lang/crates.io-index" 1332 - checksum = "901fa70d88b9d6c98022e23b4136f9f3e54e4662c3bc1bd1d84a42a9a0f0c1e9" 1332 + checksum = "2f0209b68b3613b093e0ec905354eccaedcfe83b8cb37cbdeae64026c3064c16" 1333 1333 dependencies = [ 1334 1334 "proc-macro2", 1335 1335 "quote", ··· 1395 1395 1396 1396 [[package]] 1397 1397 name = "tinyvec" 1398 - version = "1.7.0" 1398 + version = "1.8.0" 1399 1399 source = "registry+https://github.com/rust-lang/crates.io-index" 1400 - checksum = "ce6b6a2fb3a985e99cebfaefa9faa3024743da73304ca1c683a36429613d3d22" 1400 + checksum = "445e881f4f6d382d5f27c034e25eb92edd7c784ceab92a0937db7f2e9471b938" 1401 1401 dependencies = [ 1402 1402 "tinyvec_macros", 1403 1403 ] ··· 1544 1544 1545 1545 [[package]] 1546 1546 name = "toml_edit" 1547 - version = "0.22.14" 1547 + version = "0.22.15" 1548 1548 source = "registry+https://github.com/rust-lang/crates.io-index" 1549 - checksum = "f21c7aaf97f1bd9ca9d4f9e73b0a6c74bd5afef56f2bc931943a6e1c37e04e38" 1549 + checksum = "d59a3a72298453f564e2b111fa896f8d07fabb36f51f06d7e875fc5e0b5a3ef1" 1550 1550 dependencies = [ 1551 1551 "indexmap", 1552 1552 "serde", ··· 1788 1788 1789 1789 [[package]] 1790 1790 name = "uuid" 1791 - version = "1.9.1" 1791 + version = "1.10.0" 1792 1792 source = "registry+https://github.com/rust-lang/crates.io-index" 1793 - checksum = "5de17fd2f7da591098415cff336e12965a28061ddace43b59cb3c430179c9439" 1793 + checksum = "81dfa00651efa65069b0b6b651f4aaa31ba9e3c3ce0137aaad053604ee7e0314" 1794 1794 dependencies = [ 1795 1795 "getrandom", 1796 1796 ]
+1 -1
client/Cargo.toml
··· 7 7 8 8 [dependencies] 9 9 anyhow = "1.0.86" 10 - clap = { version = "4.5.1", features = ["derive", "color"] } 10 + clap = { version = "4.5.1", features = ["derive", "color", "env"] } 11 11 hmac = "0.12.1" 12 12 jwt = "0.16.0" 13 13 nix = { version = "0.28.0", features = ["hostname"] }
+7 -1
client/src/main.rs
··· 35 35 )] 36 36 seed_type: Option<SeedType>, 37 37 38 - #[arg(short, long, global = true, value_name = "SOWER_URL")] 38 + #[arg( 39 + short, 40 + long, 41 + global = true, 42 + value_name = "SOWER_URL", 43 + env = "SOWER_URL" 44 + )] 39 45 url: Option<String>, 40 46 } 41 47
+1 -1
dev-server.json
··· 21 21 ], 22 22 "clients": { 23 23 "x86_64-linux": { 24 - "path": "/nix/store/2qlsz08lajq99nlacwyijb7dlmvf39g2-sower-0.3.1" 24 + "path": "/nix/store/gxb1rq39sw4389cy5b3hcwbjbq9q1w89-sower-0.3.1" 25 25 } 26 26 }, 27 27 "log_level": "debug",
+17 -13
lib/sower_web/controllers/app_controller.ex
··· 4 4 action_fallback SowerWeb.AppFallbackController 5 5 6 6 def client_script(conn, _params) do 7 - case Application.fetch_env(:sower, :clients) do 8 - {:ok, clients} -> 9 - conn 10 - |> assign(:clients, clients) 11 - |> assign(:nix_caches, Application.fetch_env!(:sower, :nix_caches)) 12 - |> put_root_layout(false) 13 - |> render(:client_script, layout: false) 7 + with {:ok, nix_caches} <- Application.fetch_env(:sower, :nix_caches), 8 + {:ok, sower_url} <- Application.fetch_env(:sower, :public_url) do 9 + case Application.fetch_env(:sower, :clients) do 10 + {:ok, clients} -> 11 + conn 12 + |> assign(:clients, clients) 13 + |> assign(:nix_caches, nix_caches) 14 + |> assign(:sower_url, sower_url) 15 + |> put_root_layout(false) 16 + |> render(:client_script, layout: false) 14 17 15 - :error -> 16 - conn 17 - |> Plug.Conn.put_status(404) 18 - |> put_root_layout(false) 19 - |> Plug.Conn.halt() 20 - |> html("echo 'Error: client paths not configured on sower server'") 18 + :error -> 19 + conn 20 + |> Plug.Conn.put_status(404) 21 + |> put_root_layout(false) 22 + |> Plug.Conn.halt() 23 + |> html("echo 'Error: client paths not configured on sower server'; exit 1") 24 + end 21 25 end 22 26 end 23 27 end
+13
lib/sower_web/controllers/app_fallback_controller.ex
··· 1 + defmodule SowerWeb.AppFallbackController do 2 + use Phoenix.Controller 3 + 4 + require Logger 5 + 6 + def call(conn, :error) do 7 + conn 8 + |> Plug.Conn.put_status(404) 9 + |> put_root_layout(false) 10 + |> Plug.Conn.halt() 11 + |> html("echo 'Error: failure rendering client script'; exit 1") 12 + end 13 + end
+7 -7
lib/sower_web/controllers/app_html/client_script.sh.heex
··· 1 1 #!/usr/bin/env bash 2 2 3 - # TODO: bootstrap a host by overriding cache URL and key 4 - 5 3 arch=$(uname -m) 6 - os=$(uname -s | tr [:upper:] [:lower:]) 4 + os=$(uname -s | tr '[:upper:]' '[:lower:]') 7 5 8 6 if [[ "$os" == "darwin" && "$arch" == "arm64" ]]; then 9 - arch="aarch64" 7 + arch="aarch64" 10 8 fi 11 9 12 - system="${arch}-linux" 10 + system="${arch}-${os}" 11 + echo ":: Found system ${system}" 12 + 13 13 cache_args="<.cache_args nix_caches={@nix_caches} />" 14 - echo ":: Found system ${system}" 14 + export SOWER_URL="<%= @sower_url %>" 15 15 16 16 case "$system" in 17 17 <%= for {arch, props} <- @clients do %> 18 - <.case_arch arch={arch} path={props |> Keyword.get(:path)} /> 18 + <.case_arch arch={arch} path={props |> Keyword.get(:path)} /> 19 19 <% end %> 20 20 *) 21 21 echo "!! Unsupported system!"