Files
nixpkgs/nixos/tests/glance.nix
NAHO a2ed7e8d88 nixos: remove optional builtins prefixes from prelude functions
Remove optional builtins prefixes from prelude functions by running:

    builtins=(
      abort
      baseNameOf
      break
      derivation
      derivationStrict
      dirOf
      false
      fetchGit
      fetchMercurial
      fetchTarball
      fetchTree
      fromTOML
      import
      isNull
      map
      null
      placeholder
      removeAttrs
      scopedImport
      throw
      toString
      true
    )

    fd \
      --exclude doc/manual/release-notes \
      --type file \
      . \
      nixos \
      --exec-batch sed --in-place --regexp-extended "
        s/\<builtins\.($(
          printf '%s\n' "${builtins[@]}" |
            paste --delimiter '|' --serial -
        ))\>/\1/g
      "

    nix fmt
2026-01-15 16:07:55 +01:00

83 lines
2.1 KiB
Nix

{ config, lib, ... }:
{
name = "glance";
nodes = {
machine_default =
{ ... }:
{
services.glance = {
enable = true;
};
};
machine_configured =
{ pkgs, ... }:
let
# Do not use this in production. This will make the secret world-readable
# in the Nix store
secrets.glance-location.path = toString (pkgs.writeText "location-secret" "Nivelles, Belgium");
in
{
services.glance = {
enable = true;
settings = {
server.port = 5678;
pages = [
{
name = "Home";
columns = [
{
size = "full";
widgets = [
{ type = "calendar"; }
{
type = "weather";
location = {
_secret = secrets.glance-location.path;
};
}
];
}
];
}
];
};
};
};
};
extraPythonPackages =
p: with p; [
beautifulsoup4
pyyaml
types-pyyaml
types-beautifulsoup4
];
testScript = ''
from bs4 import BeautifulSoup
import yaml
machine_default.start()
machine_default.wait_for_unit("glance.service")
machine_default.wait_for_open_port(8080)
machine_configured.start()
machine_configured.wait_for_unit("glance.service")
machine_configured.wait_for_open_port(5678)
soup = BeautifulSoup(machine_default.succeed("curl http://localhost:8080"))
expected_version = "v${config.nodes.machine_default.services.glance.package.version}"
assert any(a.text == expected_version for a in soup.select(".footer a"))
yaml_contents = machine_configured.succeed("cat /run/glance/glance.yaml")
yaml_parsed = yaml.load(yaml_contents, Loader=yaml.FullLoader)
location = yaml_parsed["pages"][0]["columns"][0]["widgets"][1]["location"]
assert location == "Nivelles, Belgium"
'';
meta.maintainers = [ ];
}