dev-templates/flake.nix
2022-09-20 22:16:01 +02:00

149 lines
3.5 KiB
Nix

{
description =
"Ready-made templates for easily creating flake-driven environments";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
};
outputs = { self, flake-utils, nixpkgs }:
{
templates = {
clojure = {
path = ./clojure;
description = "Clojure development environment";
};
cue = {
path = ./cue;
description = "Cue development environment";
};
dhall = {
path = ./dhall;
description = "Dhall development environment";
};
elixir = {
path = ./elixir;
description = "Elixir development environment";
};
elm = {
path = ./elm;
description = "Elm development environment";
};
gleam = {
path = ./gleam;
description = "Gleam development environment";
};
go = {
path = ./go;
description = "Go (Golang) development environment";
};
hashi = {
path = ./hashi;
description = "HashiCorp DevOps tools development environment";
};
haskell = {
path = ./haskell;
description = "Haskell development environment";
};
java = {
path = ./java;
description = "Java development environment";
};
kotlin = {
path = ./kotlin;
description = "Kotlin development environment";
};
nickel = {
path = ./nickel;
description = "Nickel development environment";
};
nim = {
path = ./nim;
description = "Nim development environment";
};
nix = {
path = ./nix;
description = "Nix development environment";
};
node = {
path = ./node;
description = "Node.js development environment";
};
opa = {
path = ./opa;
description = "Open Policy Agent development environment";
};
protobuf = {
path = ./protobuf;
description = "Protobuf development environment";
};
python = {
path = ./python;
description = "Python development environment";
};
ruby = {
path = ./ruby;
description = "Ruby development environment";
};
rust = {
path = ./rust;
description = "Rust development environment";
};
scala = {
path = ./scala;
description = "Scala development environment";
};
zig = {
path = ./zig;
description = "Zig development environment";
};
};
} // flake-utils.lib.eachDefaultSystem (system:
let
pkgs = import nixpkgs { inherit system; };
inherit (pkgs) mkShell writeScriptBin;
exec = pkg: "${pkgs.${pkg}}/bin/${pkg}";
format = writeScriptBin "format" ''
${exec "nixpkgs-fmt"} **/*.nix
'';
update = writeScriptBin "update" ''
for dir in `ls -d */`; do # Iterate through all the templates
(
cd $dir
${exec "nix"} flake update # Update flake.lock
${
exec "direnv"
} reload # Make sure things work after the update
)
done
'';
in
{
devShells = { default = mkShell { buildInputs = [ format update ]; }; };
});
}