dev-templates/flake.nix
2023-07-13 17:26:57 -07:00

209 lines
5.1 KiB
Nix

{
description = "Ready-made templates for easily creating flake-driven environments";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
outputs = { self, nixpkgs }:
let
overlays = [
(final: prev:
let
exec = pkg: "${prev.${pkg}}/bin/${pkg}";
in
{
format = prev.writeScriptBin "format" ''
${exec "nixpkgs-fmt"} **/*.nix
'';
dvt = prev.writeScriptBin "dvt" ''
if [ -z $1 ]; then
echo "no template specified"
exit 1
fi
TEMPLATE=$1
${exec "nix"} \
--experimental-features 'nix-command flakes' \
flake init \
--template \
"github:the-nix-way/dev-templates#''${TEMPLATE}"
'';
update = prev.writeScriptBin "update" ''
for dir in `ls -d */`; do # Iterate through all the templates
(
cd $dir
${exec "nix"} flake update # Update flake.lock
${exec "nix"} flake check # Make sure things work after the update
)
done
'';
})
];
supportedSystems = [ "x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin" ];
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
pkgs = import nixpkgs { inherit overlays system; };
});
in
{
devShells = forEachSupportedSystem ({ pkgs }: {
default = pkgs.mkShell {
packages = with pkgs; [ format update ];
};
});
packages = forEachSupportedSystem ({ pkgs }: rec {
default = dvt;
inherit (pkgs) dvt;
});
}
//
{
templates = rec {
clojure = {
path = ./clojure;
description = "Clojure development environment";
};
csharp = {
path = ./csharp;
description = "C# 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";
};
latex = {
path = ./latex;
description = "LaTeX 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";
};
php = {
path = ./php;
description = "PHP development environment";
};
protobuf = {
path = ./protobuf;
description = "Protobuf development environment";
};
purescript = {
path = ./purescript;
description = "Purescript development environment";
};
python = {
path = ./python;
description = "Python development environment";
};
ruby = {
path = ./ruby;
description = "Ruby development environment";
};
rust = {
path = ./rust;
description = "Rust development environment";
};
rust-toolchain = {
path = ./rust-toolchain;
description = "Rust development environment with Rust version defined by a rust-toolchain.toml file";
};
scala = {
path = ./scala;
description = "Scala development environment";
};
shell = {
path = ./shell;
description = "Shell script development environment";
};
zig = {
path = ./zig;
description = "Zig development environment";
};
# Aliases
rt = rust-toolchain;
};
};
}