Move template/* one level up to better expose nix

module options

Create new template to show how to use this flake
This commit is contained in:
jhonas 2022-10-12 14:14:05 +02:00
parent b5b6f421ed
commit 9f130ca346
Signed by: teutat3s
GPG key ID: 924889A86D0B0FEB
13 changed files with 109 additions and 83 deletions

View file

@ -67,11 +67,11 @@
}, },
"nixpkgs_2": { "nixpkgs_2": {
"locked": { "locked": {
"lastModified": 1664538465, "lastModified": 1665349835,
"narHash": "sha256-EnlC7dDKX7X1wlnXkB1gmn9rBZQ0J9+biVTZHw//8us=", "narHash": "sha256-UK4urM3iN80UXQ7EaOappDzcisYIuEURFRoGQ/yPkug=",
"owner": "nixos", "owner": "nixos",
"repo": "nixpkgs", "repo": "nixpkgs",
"rev": "10ecda252ce1b3b1d6403caeadbcc8f30d5ab796", "rev": "34c5293a71ffdb2fe054eb5288adc1882c1eb0b1",
"type": "github" "type": "github"
}, },
"original": { "original": {

View file

@ -1,6 +1,72 @@
{ {
description = "nix flake template for devs & ops environment with triton"; description = "devshell nix module for triton DevOps shell environment";
inputs.devshell.url = "github:numtide/devshell";
inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
outputs = { self, flake-utils, devshell, nixpkgs }:
flake-utils.lib.eachSystem [
"aarch64-linux"
"i686-linux"
"x86_64-darwin"
"x86_64-linux"
]
(
system:
let
pkgs = import nixpkgs {
inherit system;
overlays = [
devshell.overlay
(import ./overlay.nix)
];
};
in
{
devshellModules.tritonshell = { config, lib, ... }:
with lib;
{
options = {
environment = {
enable = mkEnableOption "triton DevOps shell environment";
# options used to set triton env vars in tritonshell
# adjust to suit your Triton Data Center setup
# take a look at ./pkgs/triton-docker-env-shell.nix to see how these get used
cnsBaseDomain = mkOption {
description = "Base domain for generated CNS domain records";
type = types.nullOr types.str;
default = "greenbaum.zone";
};
dataCenters = mkOption {
description = "List of available triton data centers";
type = types.listOf types.str;
default = [ "cgn-1" "lev-1" ];
};
mantaDomain = mkOption {
description = "Domain for manta object storage service";
type = types.nullOr types.str;
default = "eu-central.manta.greenbaum.cloud";
};
tritonApiDomain = mkOption {
description = "Domain for triton API";
type = types.nullOr types.str;
default = "api.greenbaum.cloud";
};
};
};
config =
lib.mkIf config.environment.enable
(import ./tritonshell.nix { inherit config devshell pkgs self system; });
};
# Internal utility package with shell function and env vars helper.
# These get source'd in devshell.bash.extra when starting tritonshell
packages = {
triton-utils = import ./pkgs/triton-utils.nix { inherit pkgs; };
triton-docker-env = import ./pkgs/triton-docker-env.nix { inherit pkgs; };
};
outputs = { self }: { outputs = { self }: {
defaultTemplate = { defaultTemplate = {
description = "nix flake new --template 'git+https://git.greenbaum.cloud/greenbaum.cloud/tritonshell?ref=main' ./tritonshell"; description = "nix flake new --template 'git+https://git.greenbaum.cloud/greenbaum.cloud/tritonshell?ref=main' ./tritonshell";
@ -8,3 +74,5 @@
}; };
}; };
} }
);
}

3
template/.envrc Normal file
View file

@ -0,0 +1,3 @@
# reload when these files change
watch_file flake.nix
use_flake

2
template/.gitignore vendored Normal file
View file

@ -0,0 +1,2 @@
.direnv
result

View file

@ -1,80 +1,33 @@
{ {
description = "devshell nix module for triton DevOps shell environment"; description = "Example devshell using the tritonshell nix module";
inputs.devshell.url = "github:numtide/devshell";
inputs.flake-utils.url = "github:numtide/flake-utils"; inputs.flake-utils.url = "github:numtide/flake-utils";
inputs.nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable"; inputs.devshell.url = "github:numtide/devshell";
inputs.tritonshell-module.url = "git+https://git.greenbaum.cloud/dev/tritonshell?ref=main";
outputs = { self, flake-utils, devshell, nixpkgs }: outputs = { self, flake-utils, devshell, tritonshell-module, nixpkgs }:
flake-utils.lib.eachSystem [ flake-utils.lib.simpleFlake {
"aarch64-linux" inherit self nixpkgs;
"i686-linux" name = "infra-project";
"x86_64-darwin" preOverlays = [ devshell.overlay ];
"x86_64-linux" shell = { pkgs }:
] pkgs.devshell.mkShell {
( imports = [ tritonshell-module.devshellModules.x86_64-linux.tritonshell ];
system: # Now the tritonshell environment nix module options are available
let
pkgs = import nixpkgs {
inherit system;
overlays = [
devshell.overlay
(import ./overlay.nix)
];
};
in
{
devshellModules.tritonshell = { config, lib, ... }:
with lib;
{
options = {
environment = { environment = {
enable = mkEnableOption "triton DevOps shell environment"; enable = true;
cnsBaseDomain = mkOption { # default options
description = "Base domain for generated CNS domain records";
type = types.nullOr types.str;
default = "greenbaum.zone";
};
dataCenters = mkOption {
description = "List of available triton data centers";
type = types.listOf types.str;
default = [ "cgn-1" "lev-1" ];
};
mantaDomain = mkOption {
description = "Domain for manta object storage service";
type = types.nullOr types.str;
default = "eu-central.manta.greenbaum.cloud";
};
tritonApiDomain = mkOption {
description = "Domain for triton API";
type = types.nullOr types.str;
default = "api.greenbaum.cloud";
};
};
};
config =
lib.mkIf config.environment.enable
(import ./tritonshell.nix { inherit config devshell pkgs self system; });
};
# Internal utility package with shell function and env vars helper.
# These get source'd in devshell.bash.extra when starting tritonshell
packages = {
triton-utils = import ./pkgs/triton-utils.nix { inherit pkgs; };
triton-docker-env =
#let
# # CUSTOMIZE:
# # variables used to set triton env vars in tritonshell
# # adjust to suit your Triton Data Center setup
# # take a look at ./pkgs/triton-docker-env-shell.nix to see how these get used
#cnsBaseDomain = "greenbaum.zone"; #cnsBaseDomain = "greenbaum.zone";
#dataCenters = [ "cgn-1" "lev-1" ]; #dataCenters = [ "cgn-1" "lev-1" ];
#mantaDomain = "eu-central.manta.greenbaum.cloud"; #mantaDomain = "eu-central.manta.greenbaum.cloud";
#tritonApiDomain = "api.greenbaum.cloud"; #tritonApiDomain = "api.greenbaum.cloud";
#in };
import ./pkgs/triton-docker-env.nix { inherit pkgs; };
# Add additional packages you'd like to be available in your devshell
# PATH here
devshell.packages = with pkgs; [
#nodejs
];
};
}; };
} }
);
}