Deployment and lifecycle management for Nix
0
fork

Configure Feed

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

new config works except in nix :/

+51 -68
+1
client/src/sower.rs
··· 237 237 } 238 238 239 239 pub fn info(&self) { 240 + // TODO: check if system needs to be updated 240 241 dbg!(self); 241 242 } 242 243
+15 -3
config/runtime.exs
··· 75 75 def load() do 76 76 Logger.debug("Loading configuration") 77 77 {:ok, _} = Application.ensure_all_started(:jason) 78 + {:ok, _} = Application.ensure_all_started(:logger) 78 79 79 80 config_file = System.get_env("SOWER_SERVER_CONFIG_FILE", "/etc/sower/server.json") 80 81 ··· 84 85 :ok <- ExJsonSchema.Validator.validate(ExJsonSchema.Schema.resolve(@schema), json) do 85 86 json 86 87 else 87 - {:error, err} -> 88 + {:error, _err} -> 88 89 Logger.error(~s"Failed to read configuration file #{config_file}") 89 - Logger.error(err) 90 90 Kernel.exit(1) 91 91 end 92 92 ··· 99 99 listen_address = json_config |> Map.get("listen_address", "127.0.0.1") 100 100 listen_port = json_config |> Map.get("listen_port", 4000) 101 101 102 - json_config |> Enum.map(&load_config(&1)) 102 + # set log level to atom and remove from config 103 + if Map.has_key?(json_config, "log_level") do 104 + level = Map.get(json_config, "log_level") |> String.to_existing_atom() 105 + Logger.info(~s"Overriding log level from config to #{level}") 106 + 107 + config :logger, :console, level: level 108 + end 109 + 110 + json_config = json_config |> Map.delete("log_level") 111 + 112 + json_config 113 + |> Enum.map(&load_config(&1)) 114 + 103 115 @credentials |> Enum.map(&load_credential(&1)) 104 116 105 117 # load some non-app namespaced configs
+2 -1
dev-server.json
··· 9 9 "hostname": "localhost", 10 10 "database": "sower_dev", 11 11 "port": 5432 12 - } 12 + }, 13 + "log_level": "debug" 13 14 }
+25 -59
flake.lock
··· 50 50 ] 51 51 }, 52 52 "locked": { 53 - "lastModified": 1718474113, 54 - "narHash": "sha256-UKrfy/46YF2TRnxTtKCYzqf2f5ZPRRWwKCCJb7O5X8U=", 53 + "lastModified": 1719880336, 54 + "narHash": "sha256-VnUCaGI7FEh7tLVsD6OsychPmqjDYXqJEdFG4jK86zs=", 55 55 "owner": "ipetkov", 56 56 "repo": "crane", 57 - "rev": "0095fd8ea00ae0a9e6014f39c375e40c2fbd3386", 57 + "rev": "047c929ad65d8378f18de95ca66769ca04161caf", 58 58 "type": "github" 59 59 }, 60 60 "original": { ··· 84 84 "nixpkgs-lib": "nixpkgs-lib" 85 85 }, 86 86 "locked": { 87 - "lastModified": 1717285511, 88 - "narHash": "sha256-iKzJcpdXih14qYVcZ9QC9XuZYnPc6T8YImb6dX166kw=", 87 + "lastModified": 1719877454, 88 + "narHash": "sha256-g5N1yyOSsPNiOlFfkuI/wcUjmtah+nxdImJqrSATjOU=", 89 89 "owner": "hercules-ci", 90 90 "repo": "flake-parts", 91 - "rev": "2a55567fcf15b1b1c7ed712a2c6fadaec7412ea8", 91 + "rev": "4e3583423212f9303aa1a6337f8dffb415920e4f", 92 92 "type": "github" 93 93 }, 94 94 "original": { ··· 112 112 "type": "github" 113 113 } 114 114 }, 115 - "flake-utils_2": { 116 - "inputs": { 117 - "systems": "systems" 118 - }, 119 - "locked": { 120 - "lastModified": 1705309234, 121 - "narHash": "sha256-uNRRNRKmJyCRC/8y1RqBkqWBLM034y4qN7EprSdmgyA=", 122 - "owner": "numtide", 123 - "repo": "flake-utils", 124 - "rev": "1ef2e671c3b0c19053962c07dbda38332dcebf26", 125 - "type": "github" 126 - }, 127 - "original": { 128 - "owner": "numtide", 129 - "repo": "flake-utils", 130 - "type": "github" 131 - } 132 - }, 133 115 "next-ls": { 134 116 "inputs": { 135 117 "nixpkgs": "nixpkgs_2", 136 118 "zigpkgs": "zigpkgs" 137 119 }, 138 120 "locked": { 139 - "lastModified": 1718510544, 140 - "narHash": "sha256-d/Bc/zh/JRiR6CUc/uNiqafnLIMEh6r1ixJfnHV8e6M=", 121 + "lastModified": 1720036593, 122 + "narHash": "sha256-jI7/BcS9CimCQskXd7Cq3EGPuc9l4L7Gre8hor58ags=", 141 123 "owner": "elixir-tools", 142 124 "repo": "next-ls", 143 - "rev": "cfeac271d4e4392c4dcd6f691463cb8511587a70", 125 + "rev": "fb979c3c9f9afc7b3469ca2a433be302742317db", 144 126 "type": "github" 145 127 }, 146 128 "original": { ··· 167 149 }, 168 150 "nixpkgs-lib": { 169 151 "locked": { 170 - "lastModified": 1717284937, 171 - "narHash": "sha256-lIbdfCsf8LMFloheeE6N31+BMIeixqyQWbSr2vk79EQ=", 152 + "lastModified": 1719876945, 153 + "narHash": "sha256-Fm2rDDs86sHy0/1jxTOKB1118Q0O3Uc7EC0iXvXKpbI=", 172 154 "type": "tarball", 173 - "url": "https://github.com/NixOS/nixpkgs/archive/eb9ceca17df2ea50a250b6b27f7bf6ab0186f198.tar.gz" 155 + "url": "https://github.com/NixOS/nixpkgs/archive/5daf0514482af3f97abaefc78a6606365c9108e2.tar.gz" 174 156 }, 175 157 "original": { 176 158 "type": "tarball", 177 - "url": "https://github.com/NixOS/nixpkgs/archive/eb9ceca17df2ea50a250b6b27f7bf6ab0186f198.tar.gz" 159 + "url": "https://github.com/NixOS/nixpkgs/archive/5daf0514482af3f97abaefc78a6606365c9108e2.tar.gz" 178 160 } 179 161 }, 180 162 "nixpkgs-stable": { ··· 195 177 }, 196 178 "nixpkgs_2": { 197 179 "locked": { 198 - "lastModified": 1718160348, 199 - "narHash": "sha256-9YrUjdztqi4Gz8n3mBuqvCkMo4ojrA6nASwyIKWMpus=", 180 + "lastModified": 1719075281, 181 + "narHash": "sha256-CyyxvOwFf12I91PBWz43iGT1kjsf5oi6ax7CrvaMyAo=", 200 182 "owner": "NixOS", 201 183 "repo": "nixpkgs", 202 - "rev": "57d6973abba7ea108bac64ae7629e7431e0199b6", 184 + "rev": "a71e967ef3694799d0c418c98332f7ff4cc5f6af", 203 185 "type": "github" 204 186 }, 205 187 "original": { ··· 211 193 }, 212 194 "nixpkgs_3": { 213 195 "locked": { 214 - "lastModified": 1718318537, 215 - "narHash": "sha256-4Zu0RYRcAY/VWuu6awwq4opuiD//ahpc2aFHg2CWqFY=", 196 + "lastModified": 1719848872, 197 + "narHash": "sha256-H3+EC5cYuq+gQW8y0lSrrDZfH71LB4DAf+TDFyvwCNA=", 216 198 "owner": "nixos", 217 199 "repo": "nixpkgs", 218 - "rev": "e9ee548d90ff586a6471b4ae80ae9cfcbceb3420", 200 + "rev": "00d80d13810dbfea8ab4ed1009b09100cca86ba8", 219 201 "type": "github" 220 202 }, 221 203 "original": { ··· 254 236 }, 255 237 "rust-overlay": { 256 238 "inputs": { 257 - "flake-utils": "flake-utils_2", 258 239 "nixpkgs": [ 259 240 "nixpkgs" 260 241 ] 261 242 }, 262 243 "locked": { 263 - "lastModified": 1718590793, 264 - "narHash": "sha256-92OO8XrQTvdvDtRi0BAkjTaoZXW5ORuvqdk677wW7ko=", 244 + "lastModified": 1719886738, 245 + "narHash": "sha256-6eaaoJUkr4g9J/rMC4jhj3Gv8Sa62rvlpjFe3xZaSjM=", 265 246 "owner": "oxalica", 266 247 "repo": "rust-overlay", 267 - "rev": "5265b8a1e1d2e370e8b45b557326b691aec7d163", 248 + "rev": "db12d0c6ef002f16998723b5dd619fa7b8997086", 268 249 "type": "github" 269 250 }, 270 251 "original": { ··· 275 256 }, 276 257 "services-flake": { 277 258 "locked": { 278 - "lastModified": 1718635411, 279 - "narHash": "sha256-+uSYbdm/S4DAv8I995x3/sSbUNZa7EXWyloEGFYeYO8=", 259 + "lastModified": 1719913661, 260 + "narHash": "sha256-jqPjGC5vMC0CUvRPQC6xg33D13BfZBJLVHpvWvpRU7E=", 280 261 "owner": "juspay", 281 262 "repo": "services-flake", 282 - "rev": "2a415d206328e5bfbe8d4f8ae8e02d3e58743bd0", 263 + "rev": "bf611403f7a991bed09ea3fa6d515063ff245b3c", 283 264 "type": "github" 284 265 }, 285 266 "original": { 286 267 "owner": "juspay", 287 268 "repo": "services-flake", 288 - "type": "github" 289 - } 290 - }, 291 - "systems": { 292 - "locked": { 293 - "lastModified": 1681028828, 294 - "narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=", 295 - "owner": "nix-systems", 296 - "repo": "default", 297 - "rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e", 298 - "type": "github" 299 - }, 300 - "original": { 301 - "owner": "nix-systems", 302 - "repo": "default", 303 269 "type": "github" 304 270 } 305 271 },
+1 -4
flake.nix
··· 39 39 let 40 40 beamPackages = pkgs.beam.packagesWith pkgs.erlang_27; 41 41 elixir = beamPackages.elixir_1_17; 42 - lexical = pkgs.lexical.override { inherit beamPackages elixir; }; 43 - next-ls = inputs'.next-ls.packages.default.override { }; 44 42 45 43 rustTarget = 46 44 if pkgs.stdenv.isLinux then ··· 59 57 # elixir 60 58 elixir 61 59 beamPackages.elixir-ls 62 - lexical 63 - next-ls 60 + inputs'.next-ls.packages.default 64 61 65 62 # rust 66 63 pkgs.cargo
+2
nix/nixos-server.nix
··· 105 105 Type = "oneshot"; 106 106 ExecStart = pkgs.writeShellScript "sower-init-secrets" '' 107 107 if [ ! -e /var/lib/sower/release-cookie ]; then 108 + echo "Generating release cookie" 108 109 ${pkgs.coreutils}/bin/dd if=/dev/urandom bs=1 count=16 | ${pkgs.hexdump}/bin/hexdump -e '64/1 "%02x"' > /var/lib/sower/release-cookie 109 110 fi 110 111 if [ ! -e /var/lib/sower/secret-key-base ]; then 112 + echo "Generating secret key base" 111 113 ${lib.getExe pkgs.pwgen} --capitalize --secure 64 1 | ${pkgs.coreutils}/bin/tr -d '\n' > /var/lib/sower/secret-key-base 112 114 fi 113 115 '';
+5 -1
nix/test-end-to-end.nix
··· 35 35 36 36 services.sower.server = { 37 37 enable = true; 38 + initSecrets = true; 38 39 secrets = { 39 40 bootstrap_token_file = "${pkgs.writeText "token" "aninsecuretken"}"; 40 - auth_oidc_client_id_file = "${pkgs.writeText "oidc-id" "ok"}"; 41 41 auth_oidc_client_secret_file = "${pkgs.writeText "oidc-secret" "ok"}"; 42 42 }; 43 43 44 44 settings = { 45 + public_url = "http://127.0.0.1:4000"; 46 + 45 47 database = { 46 48 socket = "/run/postgresql/.s.PGSQL.5432"; 47 49 username = "sower"; ··· 52 54 oidc_client_id = "sower"; 53 55 oidc_base_url = "http://localhost:9000"; 54 56 }; 57 + 58 + log_level = "debug"; 55 59 }; 56 60 }; 57 61 systemd.services.sower.serviceConfig.Restart = "no";