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:
parent
b5b6f421ed
commit
9f130ca346
|
@ -67,11 +67,11 @@
|
|||
},
|
||||
"nixpkgs_2": {
|
||||
"locked": {
|
||||
"lastModified": 1664538465,
|
||||
"narHash": "sha256-EnlC7dDKX7X1wlnXkB1gmn9rBZQ0J9+biVTZHw//8us=",
|
||||
"lastModified": 1665349835,
|
||||
"narHash": "sha256-UK4urM3iN80UXQ7EaOappDzcisYIuEURFRoGQ/yPkug=",
|
||||
"owner": "nixos",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "10ecda252ce1b3b1d6403caeadbcc8f30d5ab796",
|
||||
"rev": "34c5293a71ffdb2fe054eb5288adc1882c1eb0b1",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
82
flake.nix
82
flake.nix
|
@ -1,10 +1,78 @@
|
|||
{
|
||||
description = "nix flake template for devs & ops environment with triton";
|
||||
description = "devshell nix module for triton DevOps shell environment";
|
||||
|
||||
outputs = { self }: {
|
||||
defaultTemplate = {
|
||||
description = "nix flake new --template 'git+https://git.greenbaum.cloud/greenbaum.cloud/tritonshell?ref=main' ./tritonshell";
|
||||
path = ./template;
|
||||
};
|
||||
};
|
||||
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 }: {
|
||||
defaultTemplate = {
|
||||
description = "nix flake new --template 'git+https://git.greenbaum.cloud/greenbaum.cloud/tritonshell?ref=main' ./tritonshell";
|
||||
path = ./template;
|
||||
};
|
||||
};
|
||||
}
|
||||
);
|
||||
}
|
||||
|
|
3
template/.envrc
Normal file
3
template/.envrc
Normal file
|
@ -0,0 +1,3 @@
|
|||
# reload when these files change
|
||||
watch_file flake.nix
|
||||
use_flake
|
2
template/.gitignore
vendored
Normal file
2
template/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
|||
.direnv
|
||||
result
|
|
@ -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.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 }:
|
||||
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)
|
||||
];
|
||||
outputs = { self, flake-utils, devshell, tritonshell-module, nixpkgs }:
|
||||
flake-utils.lib.simpleFlake {
|
||||
inherit self nixpkgs;
|
||||
name = "infra-project";
|
||||
preOverlays = [ devshell.overlay ];
|
||||
shell = { pkgs }:
|
||||
pkgs.devshell.mkShell {
|
||||
imports = [ tritonshell-module.devshellModules.x86_64-linux.tritonshell ];
|
||||
# Now the tritonshell environment nix module options are available
|
||||
environment = {
|
||||
enable = true;
|
||||
# default options
|
||||
#cnsBaseDomain = "greenbaum.zone";
|
||||
#dataCenters = [ "cgn-1" "lev-1" ];
|
||||
#mantaDomain = "eu-central.manta.greenbaum.cloud";
|
||||
#tritonApiDomain = "api.greenbaum.cloud";
|
||||
};
|
||||
in
|
||||
{
|
||||
devshellModules.tritonshell = { config, lib, ... }:
|
||||
with lib;
|
||||
{
|
||||
options = {
|
||||
environment = {
|
||||
enable = mkEnableOption "triton DevOps shell environment";
|
||||
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 =
|
||||
#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";
|
||||
# dataCenters = [ "cgn-1" "lev-1" ];
|
||||
# mantaDomain = "eu-central.manta.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
|
||||
];
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue