Deployment and lifecycle management for Nix
0
fork

Configure Feed

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

server: setup s3 access

+134 -4
+54
apps/sower/lib/sower/config.ex
··· 54 54 } 55 55 } 56 56 }, 57 + s3: %Schema{ 58 + type: :object, 59 + properties: %{ 60 + endpoint: %Schema{type: :string, format: :uri}, 61 + region: %Schema{type: :string}, 62 + access_key_id: %Schema{type: :string}, 63 + secret_access_key_file: %Schema{type: :string} 64 + }, 65 + required: [:endpoint] 66 + }, 57 67 listen_address: %Schema{ 58 68 anyOf: [ 59 69 %Schema{type: :string, format: :ipv4}, ··· 161 171 Kernel.exit(1) 162 172 end 163 173 174 + # s3 secret access key 175 + json_config = 176 + with {:ok, s3} <- json_config |> Keyword.fetch(:s3), 177 + {:ok, secret_access_key_file} <- s3 |> Keyword.fetch(:secret_access_key_file), 178 + {:ok, secret_access_key} <- read_credential(secret_access_key_file) do 179 + json_config 180 + |> Keyword.put(:s3, s3 |> Keyword.put(:secret_access_key, secret_access_key)) 181 + else 182 + {:error, err} -> 183 + Logger.warning( 184 + msg: "Failed to load secret_access_key from secret file", 185 + error: err 186 + ) 187 + 188 + Kernel.exit(1) 189 + 190 + :error -> 191 + Logger.debug("Configuration is missing `s3.secret_access_key_file`.") 192 + json_config 193 + end 194 + 164 195 Logger.debug("Final configuration:") 165 196 Logger.debug(json_config) 166 197 ··· 203 234 require_pkce: true 204 235 } 205 236 ] 237 + 238 + config :ex_aws, 239 + region: get_in(json_config, [:s3, :region]), 240 + host: get_in(json_config, [:s3, :host]), 241 + access_key_id: [ 242 + get_in(json_config, [:s3, :access_key_id]), 243 + # json_config |> Keyword.fetch!(:s3) |> Keyword 244 + {:system, "AWS_ACCESS_KEY_ID"}, 245 + {:system, "SOWER_AWS_ACCESS_KEY_ID"} 246 + ], 247 + secret_access_key: [ 248 + get_in(json_config, [:s3, :secret_access_key]), 249 + {:system, "AWS_SECRET_ACCESS_KEY"}, 250 + {:system, "SOWER_AWS_SECRET_ACCESS_KEY"} 251 + ] 252 + 253 + %URI{scheme: scheme, host: host, port: port} = 254 + URI.parse(get_in(json_config, [:s3, :endpoint])) 255 + 256 + config :ex_aws, :s3, 257 + scheme: scheme <> "://", 258 + host: host, 259 + port: port 206 260 207 261 Logger.info("Finished loading configuration.") 208 262 end
+3
apps/sower/mix.exs
··· 34 34 {:ecto_sql, "~> 3.11"}, 35 35 {:esbuild, "~> 0.8", runtime: Mix.env() == :dev}, 36 36 {:open_api_spex, "~> 3.22"}, 37 + {:ex_aws, "~> 2.6"}, 38 + {:ex_aws_s3, "~> 2.5"}, 37 39 {:faker, "~> 0.18", only: :test}, 38 40 {:finch, "~> 0.13"}, 39 41 {:floki, ">= 0.30.0", only: :test}, ··· 58 60 {:req, ">= 0.5.8"}, 59 61 {:shortuuid, "~> 4.0"}, 60 62 {:sower_client, in_umbrella: true}, 63 + {:sweet_xml, "~> 0.7.5"}, 61 64 {:systemd, 62 65 github: "hauleth/erlang-systemd", ref: "62723b2a99afca491cc5c8f15c7f72d108e84f4b"}, 63 66 {:tailwind, "~> 0.4.0", runtime: Mix.env() == :dev},
+2 -2
apps/sower_agent/lib/sower_agent/admin.ex
··· 13 13 end 14 14 15 15 def deploy(seed_type) when is_atom(seed_type) do 16 - seed_type |> String.to_existing_atom() |> deploy() 17 - end 16 + seed_type |> String.to_existing_atom() |> deploy() 17 + end 18 18 19 19 def deploy(seed_type) when is_seed_type?(seed_type) do 20 20 case subs(seed_type) do
+3
config/config.exs
··· 62 62 config :elixir, time_zone_database: Zoneinfo.TimeZoneDatabase 63 63 config :zoneinfo, tzpath: "/etc/zoneinfo" 64 64 65 + config :ex_aws, http_client: ExAws.Request.Req 66 + config :ex_aws_s3, :content_hash_algorithm, :sha256 67 + 65 68 # Import environment specific config. This must remain at the bottom 66 69 # of this file so it overrides the configuration defined above. 67 70 import_config "#{config_env()}.exs"
+4 -2
flake.nix
··· 78 78 pkgs.attic-client 79 79 pkgs.nushell 80 80 81 + # dev tools 82 + pkgs.entr 81 83 pkgs.just 82 84 pkgs.mix2nix 83 85 pkgs.nix-eval-jobs 84 86 pkgs.nvfetcher 85 - pkgs.process-compose 86 87 pkgs.postgresql 88 + pkgs.process-compose 89 + pkgs.s5cmd 87 90 pkgs.sd-switch 88 - pkgs.entr 89 91 ] 90 92 ++ lib.optionals pkgs.stdenv.isLinux [ 91 93 # elixir
+1
justfile
··· 43 43 curl https://converter.swagger.io/api/convert?url=https://raw.githubusercontent.com/lxc/incus/refs/heads/main/doc/rest-api.yaml | jq . > apps/incus_client/priv/incus-rest-api.json 44 44 45 45 mix-nix-lock: 46 + mix deps.get 46 47 mix deps.nix --output nix/packages/deps.nix 47 48 48 49 mix-clean:
+3
mix.lock
··· 18 18 "erlex": {:hex, :erlex, "0.2.8", "cd8116f20f3c0afe376d1e8d1f0ae2452337729f68be016ea544a72f767d9c12", [:mix], [], "hexpm", "9d66ff9fedf69e49dc3fd12831e12a8a37b76f8651dd21cd45fcf5561a8a7590"}, 19 19 "erlexec": {:hex, :erlexec, "2.2.2", "edb9f1a7d821a9df4efdc82bd11817ab5249dbd294d5c54ec249bd905f10e804", [:rebar3], [], "hexpm", "5e8e3c3773113785361b3b55218d92f7e91509cc9d679bf67c5c3703b394c900"}, 20 20 "esbuild": {:hex, :esbuild, "0.10.0", "b0aa3388a1c23e727c5a3e7427c932d89ee791746b0081bbe56103e9ef3d291f", [:mix], [{:jason, "~> 1.4", [hex: :jason, repo: "hexpm", optional: false]}], "hexpm", "468489cda427b974a7cc9f03ace55368a83e1a7be12fba7e30969af78e5f8c70"}, 21 + "ex_aws": {:hex, :ex_aws, "2.6.1", "194582c7b09455de8a5ab18a0182e6dd937d53df82be2e63c619d01bddaccdfa", [:mix], [{:configparser_ex, "~> 5.0", [hex: :configparser_ex, repo: "hexpm", optional: true]}, {:hackney, "~> 1.16", [hex: :hackney, repo: "hexpm", optional: true]}, {:jason, "~> 1.1", [hex: :jason, repo: "hexpm", optional: true]}, {:jsx, "~> 2.8 or ~> 3.0", [hex: :jsx, repo: "hexpm", optional: true]}, {:mime, "~> 1.2 or ~> 2.0", [hex: :mime, repo: "hexpm", optional: false]}, {:req, "~> 0.5.10 or ~> 0.6 or ~> 1.0", [hex: :req, repo: "hexpm", optional: true]}, {:sweet_xml, "~> 0.7", [hex: :sweet_xml, repo: "hexpm", optional: true]}, {:telemetry, "~> 0.4.3 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "67842a08c90a1d9a09dbe4ac05754175c7ca253abe4912987c759395d4bd9d26"}, 22 + "ex_aws_s3": {:hex, :ex_aws_s3, "2.5.9", "862b7792f2e60d7010e2920d79964e3fab289bc0fd951b0ba8457a3f7f9d1199", [:mix], [{:ex_aws, "~> 2.0", [hex: :ex_aws, repo: "hexpm", optional: false]}, {:sweet_xml, ">= 0.0.0", [hex: :sweet_xml, repo: "hexpm", optional: true]}], "hexpm", "a480d2bb2da64610014021629800e1e9457ca5e4a62f6775bffd963360c2bf90"}, 21 23 "ex_nar": {:hex, :ex_nar, "0.3.0", "3136d019241afc97a5da8e43613a56ac0ae30dad12df5d3bc66547e55e7453e0", [:mix], [], "hexpm", "cbb42d047764feac6c411efddcadc31866e9a998dd6e2bc1eb428cec1c49fdcd"}, 22 24 "expo": {:hex, :expo, "1.1.1", "4202e1d2ca6e2b3b63e02f69cfe0a404f77702b041d02b58597c00992b601db5", [:mix], [], "hexpm", "5fb308b9cb359ae200b7e23d37c76978673aa1b06e2b3075d814ce12c5811640"}, 23 25 "exsync": {:hex, :exsync, "0.4.1", "0a14fe4bfcb80a509d8a0856be3dd070fffe619b9ba90fec13c58b316c176594", [:mix], [{:file_system, "~> 0.2 or ~> 1.0", [hex: :file_system, repo: "hexpm", optional: false]}], "hexpm", "cefb22aa805ec97ffc5b75a4e1dc54bcaf781e8b32564bf74abbe5803d1b5178"}, ··· 69 71 "slipstream": {:hex, :slipstream, "1.2.2", "6b07124ac5f62a50327aa38c84edd0284920ac8aba548e04738827838f233ed0", [:mix], [{:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:mint_web_socket, "~> 0.2 or ~> 1.0", [hex: :mint_web_socket, repo: "hexpm", optional: false]}, {:nimble_options, "~> 0.1 or ~> 1.0", [hex: :nimble_options, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}], "hexpm", "ccb873ddb21aadb37c5c7745014febe6da0aa2cef0c4e73e7d08ce11d18aacd0"}, 70 72 "sourceror": {:hex, :sourceror, "1.11.0", "df2cdaffdc323e804009ff50b50bb31e6f2d6e116d936ccf22981f592594d624", [:mix], [], "hexpm", "6e26f572bdfc21d7ad397f596b4cfbbf31d7112126fe3e902c120947073231a8"}, 71 73 "spitfire": {:hex, :spitfire, "0.3.7", "d6051f94f554d33d038ab3c1d7e017293ae30429cc6b267b08cb6ad69e35e9a3", [:mix], [], "hexpm", "798ff97db02477b05fa3db8e2810cebda6ed5d90c6de6b21aa65abd577599744"}, 74 + "sweet_xml": {:hex, :sweet_xml, "0.7.5", "803a563113981aaac202a1dbd39771562d0ad31004ddbfc9b5090bdcd5605277", [:mix], [], "hexpm", "193b28a9b12891cae351d81a0cead165ffe67df1b73fe5866d10629f4faefb12"}, 72 75 "systemd": {:git, "https://github.com/hauleth/erlang-systemd.git", "62723b2a99afca491cc5c8f15c7f72d108e84f4b", [ref: "62723b2a99afca491cc5c8f15c7f72d108e84f4b"]}, 73 76 "tailwind": {:hex, :tailwind, "0.4.1", "e7bcc222fe96a1e55f948e76d13dd84a1a7653fb051d2a167135db3b4b08d3e9", [:mix], [], "hexpm", "6249d4f9819052911120dbdbe9e532e6bd64ea23476056adb7f730aa25c220d1"}, 74 77 "telemetry": {:hex, :telemetry, "1.3.0", "fedebbae410d715cf8e7062c96a1ef32ec22e764197f70cda73d82778d61e7a2", [:rebar3], [], "hexpm", "7015fc8919dbe63764f4b4b87a95b7c0996bd539e0d499be6ec9d7f3875b79e6"},
+64
nix/packages/deps.nix
··· 441 441 in 442 442 drv; 443 443 444 + ex_aws = 445 + let 446 + version = "2.6.1"; 447 + drv = buildMix { 448 + inherit version; 449 + name = "ex_aws"; 450 + appConfigPath = ../../config; 451 + 452 + src = fetchHex { 453 + inherit version; 454 + pkg = "ex_aws"; 455 + sha256 = "67842a08c90a1d9a09dbe4ac05754175c7ca253abe4912987c759395d4bd9d26"; 456 + }; 457 + 458 + beamDeps = [ 459 + jason 460 + mime 461 + req 462 + sweet_xml 463 + telemetry 464 + ]; 465 + }; 466 + in 467 + drv; 468 + 469 + ex_aws_s3 = 470 + let 471 + version = "2.5.9"; 472 + drv = buildMix { 473 + inherit version; 474 + name = "ex_aws_s3"; 475 + appConfigPath = ../../config; 476 + 477 + src = fetchHex { 478 + inherit version; 479 + pkg = "ex_aws_s3"; 480 + sha256 = "a480d2bb2da64610014021629800e1e9457ca5e4a62f6775bffd963360c2bf90"; 481 + }; 482 + 483 + beamDeps = [ 484 + ex_aws 485 + sweet_xml 486 + ]; 487 + }; 488 + in 489 + drv; 490 + 444 491 expo = 445 492 let 446 493 version = "1.1.1"; ··· 1217 1264 nimble_options 1218 1265 telemetry 1219 1266 ]; 1267 + }; 1268 + in 1269 + drv; 1270 + 1271 + sweet_xml = 1272 + let 1273 + version = "0.7.5"; 1274 + drv = buildMix { 1275 + inherit version; 1276 + name = "sweet_xml"; 1277 + appConfigPath = ../../config; 1278 + 1279 + src = fetchHex { 1280 + inherit version; 1281 + pkg = "sweet_xml"; 1282 + sha256 = "193b28a9b12891cae351d81a0cead165ffe67df1b73fe5866d10629f4faefb12"; 1283 + }; 1220 1284 }; 1221 1285 in 1222 1286 drv;