dev-templates/flake.nix

171 lines
3.9 KiB
Nix
Raw Normal View History

2022-07-11 16:17:54 -07:00
{
2022-07-28 15:11:05 -07:00
description =
"Ready-made templates for easily creating flake-driven environments";
2022-07-11 16:17:54 -07:00
2022-07-28 15:42:22 -07:00
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs";
flake-utils.url = "github:numtide/flake-utils";
};
2022-07-28 14:20:46 -07:00
2022-07-28 15:42:22 -07:00
outputs = { self, nixpkgs, flake-utils }:
2022-07-31 14:12:51 -07:00
{
2022-07-28 15:42:22 -07:00
templates = {
2022-07-31 11:23:05 -07:00
cue = {
path = ./cue;
description = "Cue development environment";
};
2022-07-28 16:35:35 -07:00
dhall = {
path = ./dhall;
description = "Dhall development environment";
};
elixir = {
2022-07-28 16:59:25 -07:00
path = ./elixir;
2022-07-28 16:35:35 -07:00
description = "Elixir development environment";
};
2022-07-31 12:10:16 -07:00
elm = {
path = ./elm;
description = "Elm development environment";
};
2022-07-28 15:42:22 -07:00
gleam = {
path = ./gleam;
description = "Gleam development environment";
};
2022-07-11 16:17:54 -07:00
2022-07-28 17:22:04 -07:00
go1_17 = {
2022-07-28 15:42:22 -07:00
path = ./go1.17;
description = "Go 1.17 development environment";
};
2022-07-11 17:01:42 -07:00
2022-07-28 17:22:04 -07:00
go1_18 = {
2022-07-28 15:42:22 -07:00
path = ./go1.18;
description = "Go 1.18 development environment";
};
2022-07-28 14:42:40 -07:00
2022-07-31 11:52:37 -07:00
hashi = {
path = ./hashi;
description = "HashiCorp DevOps tools development environment";
};
2022-07-31 15:00:58 -07:00
haskell = {
path = ./haskell;
description = "Haskell development environment";
};
2022-07-28 15:42:22 -07:00
java = {
path = ./java;
description = "Java development environment";
};
2022-07-28 15:14:21 -07:00
2022-07-28 16:21:18 -07:00
kotlin = {
path = ./kotlin;
description = "Kotlin development environment";
};
2022-07-31 18:04:16 -07:00
nickel = {
path = ./nickel;
description = "Nickel development environment";
};
2022-07-31 12:01:58 -07:00
nim = {
path = ./nim;
description = "Nim development environment";
};
2022-07-28 15:42:22 -07:00
nix = {
path = ./nix;
description = "Nix development environment";
};
2022-07-28 14:37:55 -07:00
2022-07-28 15:42:22 -07:00
node = {
path = ./node;
description = "Node.js development environment";
};
2022-07-28 14:20:46 -07:00
2022-07-31 12:59:08 -07:00
opa = {
path = ./opa;
description = "Open Policy Agent development environment";
};
2022-07-28 17:49:09 -07:00
protobuf = {
path = ./protobuf;
description = "Protobuf development environment";
};
2022-07-31 13:33:11 -07:00
python = {
path = ./python;
description = "Python development environment";
};
2022-07-31 13:18:29 -07:00
ruby = {
path = ./ruby;
description = "Ruby development environment";
};
2022-07-28 15:42:22 -07:00
rust = {
path = ./rust;
description = "Rust development environment";
};
2022-07-28 14:54:27 -07:00
2022-07-28 15:42:22 -07:00
scala = {
path = ./scala;
description = "Scala development environment";
};
zig = {
path = ./zig;
description = "Zig development environment";
};
2022-07-28 14:20:46 -07:00
};
2022-07-31 14:12:51 -07:00
lib = let
pkgs = nixpkgs;
inherit (pkgs.lib) optionals;
inherit (pkgs.stdenv) isDarwin isLinux;
in {
inherit flake-utils nixpkgs;
};
} // flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
inherit (pkgs) mkShell writeScriptBin;
run = pkg: "${pkgs.${pkg}}/bin/${pkg}";
format = writeScriptBin "format" ''
${run "nixfmt"} **/*.nix
'';
2022-08-02 03:52:51 -07:00
2022-07-31 14:12:51 -07:00
update = writeScriptBin "update" ''
# Update root
2022-08-02 23:17:50 -07:00
${run "nix"} flake update
2022-07-31 14:12:51 -07:00
for dir in `ls -d */`; do # Iterate through all the templates
(
cd $dir
${run "nix"} flake update # Update flake.lock
${run "direnv"} reload # Make sure things work after the update
)
done
'';
visit = writeScriptBin "visit" ''
for dir in `ls -d */`; do
(
cd $dir
${run "direnv"} reload
)
done
'';
in {
devShells = {
default = mkShell {
buildInputs = [ format update visit ];
};
};
}
);
2022-07-11 16:17:54 -07:00
}