From 56ebe904502a1e3b95810d6cd7a7d6921467e9b9 Mon Sep 17 00:00:00 2001 From: jhonas Date: Tue, 1 Feb 2022 02:30:23 +0100 Subject: [PATCH] make it a real flake template --- README.md | 4 +- flake.nix | 55 +++---------------- flake.lock => template/flake.lock | 0 template/flake.nix | 47 ++++++++++++++++ {pkgs => template/pkgs}/triton-utils.nix | 0 .../pkgs}/utils/cacert-2021-10-26.pem | 0 .../pkgs}/utils/triton-docker.env.sh | 0 {pkgs => template/pkgs}/utils/ttp.sh | 0 {pkgs => template/pkgs}/utils/unset-env.sh | 0 tritonshell.nix => template/tritonshell.nix | 0 10 files changed, 56 insertions(+), 50 deletions(-) rename flake.lock => template/flake.lock (100%) create mode 100644 template/flake.nix rename {pkgs => template/pkgs}/triton-utils.nix (100%) rename {pkgs => template/pkgs}/utils/cacert-2021-10-26.pem (100%) rename {pkgs => template/pkgs}/utils/triton-docker.env.sh (100%) rename {pkgs => template/pkgs}/utils/ttp.sh (100%) rename {pkgs => template/pkgs}/utils/unset-env.sh (100%) rename tritonshell.nix => template/tritonshell.nix (100%) diff --git a/README.md b/README.md index af595f0..c27d780 100644 --- a/README.md +++ b/README.md @@ -11,9 +11,9 @@ 2. Otherwise, proceed to enable flakes (still an experimental feature in `nix`): https://nixos.wiki/wiki/Flakes#Installing_flakes -2. Get this nix flake template: +2. Get this nix flake template, it will be setup in a new directory `./tritonshell` (feel free to adjust this): ``` -nix flake new 'git+https://git.greenbaum.cloud/greenbaum.cloud/tritonshell' +nix flake new --template "git+https://git.greenbaum.cloud/greenbaum.cloud/tritonshell?ref=main" ./tritonshell ``` 3. Ready to go: diff --git a/flake.nix b/flake.nix index 155a1c5..d6632d0 100644 --- a/flake.nix +++ b/flake.nix @@ -1,51 +1,10 @@ { - description = "devs & ops environment for nix'ing with triton"; + description = "nix flake template for devs & ops environment with triton"; - inputs.devshell.url = "github:numtide/devshell"; - inputs.flake-utils.url = "github:numtide/flake-utils"; - inputs.nixpkgs.url = "github:nixos/nixpkgs/release-21.11"; - inputs.nixpkgsUnstable.url = "github:nixos/nixpkgs/nixos-unstable"; - inputs.nixpkgs20-09.url = "github:nixos/nixpkgs/release-20.09"; - - outputs = { self, flake-utils, devshell, nixpkgs, nixpkgsUnstable, nixpkgs20-09 }: - flake-utils.lib.eachDefaultSystem (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 nixpkgs; inherit system; }; - - devShell = - let - pkgs = import nixpkgs { - inherit system; - - overlays = [ devshell.overlay ]; - }; - pkgsUnstable = import nixpkgsUnstable { - inherit system; - - overlays = [ devshell.overlay ]; - }; - pkgs20-09 = import nixpkgs20-09 { - inherit system; - - overlays = [ devshell.overlay ]; - }; - - # HINT: add your extra pkgs here, - # they'll get appended to devshell.packages in ./tritonshell.nix - extraDevshellPkgs = [ - pkgsUnstable.consul - pkgsUnstable.nomad - pkgsUnstable.terraform - pkgsUnstable.vault - ]; - - in - import ./tritonshell.nix { inherit extraDevshellPkgs devshell pkgs pkgsUnstable pkgs20-09 self system; }; - }) // { - # merge this into the attr set above - defaultTemplate.description = "nix flake new -t 'git+https://git.greenbaum.cloud/greenbaum.cloud/tritonshell' tritonshell"; - defaultTemplate.path = "./"; - }; + outputs = { self }: { + defaultTemplate = { + description = "nix flake new --template 'git+https://git.greenbaum.cloud/greenbaum.cloud/tritonshell?ref=main' ./tritonshell"; + path = ./template; + }; + }; } diff --git a/flake.lock b/template/flake.lock similarity index 100% rename from flake.lock rename to template/flake.lock diff --git a/template/flake.nix b/template/flake.nix new file mode 100644 index 0000000..cefb415 --- /dev/null +++ b/template/flake.nix @@ -0,0 +1,47 @@ +{ + description = "devs & ops environment for nix'ing with triton"; + + inputs.devshell.url = "github:numtide/devshell"; + inputs.flake-utils.url = "github:numtide/flake-utils"; + inputs.nixpkgs.url = "github:nixos/nixpkgs/release-21.11"; + inputs.nixpkgsUnstable.url = "github:nixos/nixpkgs/nixos-unstable"; + inputs.nixpkgs20-09.url = "github:nixos/nixpkgs/release-20.09"; + + outputs = { self, flake-utils, devshell, nixpkgs, nixpkgsUnstable, nixpkgs20-09 }: + flake-utils.lib.eachDefaultSystem (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 nixpkgs; inherit system; }; + + devShell = + let + pkgs = import nixpkgs { + inherit system; + + overlays = [ devshell.overlay ]; + }; + pkgsUnstable = import nixpkgsUnstable { + inherit system; + + overlays = [ devshell.overlay ]; + }; + pkgs20-09 = import nixpkgs20-09 { + inherit system; + + overlays = [ devshell.overlay ]; + }; + + # HINT: add your extra pkgs here, + # they'll get appended to devshell.packages in ./tritonshell.nix + extraDevshellPkgs = [ + pkgsUnstable.consul + pkgsUnstable.nomad + pkgsUnstable.terraform + pkgsUnstable.vault + ]; + + in + import ./tritonshell.nix { inherit extraDevshellPkgs devshell pkgs pkgsUnstable pkgs20-09 self system; }; + }); +} diff --git a/pkgs/triton-utils.nix b/template/pkgs/triton-utils.nix similarity index 100% rename from pkgs/triton-utils.nix rename to template/pkgs/triton-utils.nix diff --git a/pkgs/utils/cacert-2021-10-26.pem b/template/pkgs/utils/cacert-2021-10-26.pem similarity index 100% rename from pkgs/utils/cacert-2021-10-26.pem rename to template/pkgs/utils/cacert-2021-10-26.pem diff --git a/pkgs/utils/triton-docker.env.sh b/template/pkgs/utils/triton-docker.env.sh similarity index 100% rename from pkgs/utils/triton-docker.env.sh rename to template/pkgs/utils/triton-docker.env.sh diff --git a/pkgs/utils/ttp.sh b/template/pkgs/utils/ttp.sh similarity index 100% rename from pkgs/utils/ttp.sh rename to template/pkgs/utils/ttp.sh diff --git a/pkgs/utils/unset-env.sh b/template/pkgs/utils/unset-env.sh similarity index 100% rename from pkgs/utils/unset-env.sh rename to template/pkgs/utils/unset-env.sh diff --git a/tritonshell.nix b/template/tritonshell.nix similarity index 100% rename from tritonshell.nix rename to template/tritonshell.nix