1
0
Fork 0
mirror of https://github.com/nix-community/home-manager synced 2024-11-23 03:29:45 +01:00

openstackclient: add module (#4530)

Co-authored-by: Sumner Evans <me@sumnerevans.com>
This commit is contained in:
Nicola Squartini 2023-11-15 23:25:44 +01:00 committed by GitHub
parent 280721186a
commit ab1459a1fb
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
9 changed files with 136 additions and 1 deletions

View file

@ -414,6 +414,11 @@
keys =
[{ fingerprint = "75F0 AB7C FE01 D077 AEE6 CAFD 353E 4A18 EE0F AB72"; }];
};
tensor5 = {
github = "tensor5";
githubId = 1545895;
name = "Nicola Squartini";
};
toastal = {
email = "toastal+nix@posteo.net";
matrix = "@toastal:matrix.org";

View file

@ -1116,7 +1116,7 @@ in
can control it by using the `qt5ct` and `qt6ct` applications;
- `qt.style.name = "kvantum"`: override the style by using themes
written in SVG. Supports many popular themes.
'';
'';
}
{
@ -1274,6 +1274,13 @@ in
'';
}
{
time = "2023-10-04T18:35:42+00:00";
message = ''
A new module is available: 'programs.openstackclient'.
'';
}
{
time = "2023-10-17T06:33:24+00:00";
condition = hostPlatform.isLinux;

View file

@ -165,6 +165,7 @@ let
./programs/offlineimap.nix
./programs/oh-my-posh.nix
./programs/opam.nix
./programs/openstackclient.nix
./programs/pandoc.nix
./programs/papis.nix
./programs/password-store.nix

View file

@ -0,0 +1,73 @@
{ config, lib, pkgs, ... }:
let
cfg = config.programs.openstackclient;
yamlFormat = pkgs.formats.yaml { };
in {
meta.maintainers = [ lib.hm.maintainers.tensor5 ];
options.programs.openstackclient = {
enable = lib.mkEnableOption "OpenStack command-line client";
package = lib.mkPackageOption pkgs "openstackclient" { };
clouds = lib.mkOption {
type = lib.types.submodule { freeformType = yamlFormat.type; };
default = { };
example = lib.literalExpression ''
{
my-infra = {
cloud = "example-cloud";
auth = {
project_id = "0123456789abcdef0123456789abcdef";
username = "openstack";
};
region_name = "XXX";
interface = "internal";
};
}
'';
description = ''
Configuration needed to connect to one or more clouds.
Do not include passwords here as they will be publicly readable in the Nix store.
Configuration written to {file}`$XDG_CONFIG_HOME/openstack/clouds.yaml`.
See <https://docs.openstack.org/python-openstackclient/latest/configuration/index.html#clouds-yaml>.
'';
};
publicClouds = lib.mkOption {
type = lib.types.submodule { freeformType = yamlFormat.type; };
default = { };
example = lib.literalExpression ''
{
example-cloud = {
auth = {
auth_url = "https://identity.cloud.example.com/v2.0";
};
};
};
'';
description = ''
Public information about clouds.
Configuration written to {file}`$XDG_CONFIG_HOME/openstack/clouds-public.yaml`.
See <https://docs.openstack.org/python-openstackclient/latest/configuration/index.html#clouds-public-yaml>.
'';
};
};
config = lib.mkIf cfg.enable {
home.packages = [ cfg.package ];
xdg.configFile."openstack/clouds.yaml".source = yamlFormat.generate
"openstackclient-clouds-yaml-${config.home.username}" {
clouds = cfg.clouds;
};
xdg.configFile."openstack/clouds-public.yaml".source = yamlFormat.generate
"openstackclient-clouds-public-yaml-${config.home.username}" {
public-clouds = cfg.publicClouds;
};
};
}

View file

@ -118,6 +118,7 @@ import nmt {
./modules/programs/nnn
./modules/programs/nushell
./modules/programs/oh-my-posh
./modules/programs/openstackclient
./modules/programs/pandoc
./modules/programs/papis
./modules/programs/pet

View file

@ -0,0 +1,4 @@
public-clouds:
example-cloud:
auth:
auth_url: https://identity.cloud.example.com/v2.0

View file

@ -0,0 +1,8 @@
clouds:
my-infra:
auth:
project_id: 0123456789abcdef0123456789abcdef
username: openstack
cloud: example-cloud
interface: internal
region_name: XXX

View file

@ -0,0 +1 @@
{ openstackclient = ./openstackclient.nix; }

View file

@ -0,0 +1,35 @@
{ ... }:
{
programs.openstackclient = {
enable = true;
clouds = {
my-infra = {
cloud = "example-cloud";
auth = {
project_id = "0123456789abcdef0123456789abcdef";
username = "openstack";
};
region_name = "XXX";
interface = "internal";
};
};
publicClouds = {
example-cloud = {
auth = { auth_url = "https://identity.cloud.example.com/v2.0"; };
};
};
};
test.stubs.openstackclient = { };
nmt.script = ''
assertFileExists home-files/.config/openstack/clouds.yaml
assertFileContent home-files/.config/openstack/clouds.yaml \
${./clouds.yaml}
assertFileExists home-files/.config/openstack/clouds-public.yaml
assertFileContent home-files/.config/openstack/clouds-public.yaml \
${./clouds-public.yaml}
'';
}