at master 2.2 kB view raw
1{ config, lib, ... }: 2 3{ 4 name = "glance"; 5 6 nodes = { 7 machine_default = 8 { ... }: 9 { 10 services.glance = { 11 enable = true; 12 }; 13 }; 14 15 machine_configured = 16 { pkgs, ... }: 17 let 18 # Do not use this in production. This will make the secret world-readable 19 # in the Nix store 20 secrets.glance-location.path = builtins.toString ( 21 pkgs.writeText "location-secret" "Nivelles, Belgium" 22 ); 23 in 24 { 25 services.glance = { 26 enable = true; 27 settings = { 28 server.port = 5678; 29 pages = [ 30 { 31 name = "Home"; 32 columns = [ 33 { 34 size = "full"; 35 widgets = [ 36 { type = "calendar"; } 37 { 38 type = "weather"; 39 location = { 40 _secret = secrets.glance-location.path; 41 }; 42 } 43 ]; 44 } 45 ]; 46 } 47 ]; 48 }; 49 }; 50 }; 51 }; 52 53 extraPythonPackages = 54 p: with p; [ 55 beautifulsoup4 56 pyyaml 57 types-pyyaml 58 types-beautifulsoup4 59 ]; 60 61 testScript = '' 62 from bs4 import BeautifulSoup 63 import yaml 64 65 machine_default.start() 66 machine_default.wait_for_unit("glance.service") 67 machine_default.wait_for_open_port(8080) 68 69 machine_configured.start() 70 machine_configured.wait_for_unit("glance.service") 71 machine_configured.wait_for_open_port(5678) 72 73 soup = BeautifulSoup(machine_default.succeed("curl http://localhost:8080")) 74 expected_version = "v${config.nodes.machine_default.services.glance.package.version}" 75 assert any(a.text == expected_version for a in soup.select(".footer a")) 76 77 yaml_contents = machine_configured.succeed("cat /run/glance/glance.yaml") 78 yaml_parsed = yaml.load(yaml_contents, Loader=yaml.FullLoader) 79 location = yaml_parsed["pages"][0]["columns"][0]["widgets"][1]["location"] 80 assert location == "Nivelles, Belgium" 81 ''; 82 83 meta.maintainers = [ ]; 84}