1
1
Fork 0
mirror of https://github.com/the-nix-way/dev-templates synced 2024-05-07 13:56:07 +02:00
github.com_the-nix-way_dev-.../flake.nix

266 lines
6.5 KiB
Nix
Raw Normal View History

2022-07-12 01:17:54 +02:00
{
2023-07-14 02:26:57 +02:00
description = "Ready-made templates for easily creating flake-driven environments";
inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
outputs = { self, nixpkgs }:
let
overlays = [
2024-04-15 22:19:53 +02:00
(final: prev:
let
getSystem = "SYSTEM=$(nix eval --impure --raw --expr 'builtins.currentSystem')";
forEachDir = exec: ''
for dir in */; do
2024-04-15 22:15:36 +02:00
(
cd "''${dir}"
2024-04-15 22:19:53 +02:00
${exec}
2024-04-15 22:15:36 +02:00
)
done
'';
2024-04-15 22:19:53 +02:00
in
{
format = final.writeShellApplication {
name = "format";
runtimeInputs = with final; [ nixpkgs-fmt ];
text = "nixpkgs-fmt '**/*.nix'";
};
2024-04-15 16:50:56 +02:00
2024-04-15 22:19:53 +02:00
# only run this locally, as Actions will run out of disk space
build = final.writeShellApplication {
name = "build";
text = ''
${getSystem}
2024-04-15 16:50:56 +02:00
2024-04-15 22:19:53 +02:00
${forEachDir ''
echo "building ''${dir}"
nix build ".#devShells.''${SYSTEM}.default"
''}
'';
};
2023-07-14 02:26:57 +02:00
2024-04-15 22:19:53 +02:00
check = final.writeShellApplication {
name = "check";
text = forEachDir ''
echo "checking ''${dir}"
nix flake check --all-systems --no-build
'';
};
2023-07-14 02:26:57 +02:00
2024-04-15 22:19:53 +02:00
dvt = final.writeShellApplication {
name = "dvt";
text = ''
if [ -z $1 ]; then
echo "no template specified"
exit 1
fi
2024-04-15 22:19:53 +02:00
TEMPLATE=$1
2024-04-15 22:19:53 +02:00
nix \
--experimental-features 'nix-command flakes' \
flake init \
--template \
"github:the-nix-way/dev-templates#''${TEMPLATE}"
'';
};
2024-04-15 22:19:53 +02:00
update = final.writeShellApplication {
name = "update";
text = forEachDir ''
echo "updating ''${dir}"
nix flake update
'';
};
})
2023-07-14 02:26:57 +02:00
];
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 {
2024-04-15 22:15:36 +02:00
packages = with pkgs; [ build check format update ];
2023-07-14 02:26:57 +02:00
};
});
2022-07-12 01:17:54 +02:00
2023-07-14 02:26:57 +02:00
packages = forEachSupportedSystem ({ pkgs }: rec {
default = dvt;
inherit (pkgs) dvt;
});
}
//
2022-07-28 23:20:46 +02:00
2022-07-31 23:12:51 +02:00
{
2022-10-20 16:14:56 +02:00
templates = rec {
c-cpp = {
path = ./c-cpp;
description = "C/C++ development environment";
};
2022-09-20 22:15:47 +02:00
clojure = {
path = ./clojure;
description = "Clojure development environment";
};
2023-05-25 21:23:06 +02:00
csharp = {
path = ./csharp;
description = "C# development environment";
};
2022-07-31 20:23:05 +02:00
cue = {
path = ./cue;
description = "Cue development environment";
};
2022-07-29 01:35:35 +02:00
dhall = {
path = ./dhall;
description = "Dhall development environment";
};
elixir = {
2022-07-29 01:59:25 +02:00
path = ./elixir;
2022-07-29 01:35:35 +02:00
description = "Elixir development environment";
};
2022-07-31 21:10:16 +02:00
elm = {
path = ./elm;
description = "Elm development environment";
};
empty = {
path = ./empty;
description = "Empty dev template that you can customize at will";
};
2022-07-29 00:42:22 +02:00
gleam = {
path = ./gleam;
description = "Gleam development environment";
};
2022-07-12 01:17:54 +02:00
2022-08-23 11:07:14 +02:00
go = {
path = ./go;
description = "Go (Golang) development environment";
2022-07-29 00:42:22 +02:00
};
2022-07-28 23:42:40 +02:00
2022-07-31 20:52:37 +02:00
hashi = {
path = ./hashi;
description = "HashiCorp DevOps tools development environment";
};
2022-08-01 00:00:58 +02:00
haskell = {
path = ./haskell;
description = "Haskell development environment";
};
2022-07-29 00:42:22 +02:00
java = {
path = ./java;
description = "Java development environment";
};
2022-07-29 00:14:21 +02:00
2022-07-29 01:21:18 +02:00
kotlin = {
path = ./kotlin;
description = "Kotlin development environment";
};
latex = {
path = ./latex;
description = "LaTeX development environment";
};
2022-08-01 03:04:16 +02:00
nickel = {
path = ./nickel;
description = "Nickel development environment";
};
2022-07-31 21:01:58 +02:00
nim = {
path = ./nim;
description = "Nim development environment";
};
2022-07-29 00:42:22 +02:00
nix = {
path = ./nix;
description = "Nix development environment";
};
2022-07-28 23:37:55 +02:00
2022-07-29 00:42:22 +02:00
node = {
path = ./node;
description = "Node.js development environment";
};
2022-07-28 23:20:46 +02:00
2022-07-31 21:59:08 +02:00
opa = {
path = ./opa;
description = "Open Policy Agent development environment";
};
2022-09-28 09:34:13 +02:00
php = {
path = ./php;
description = "PHP development environment";
};
2022-07-29 02:49:09 +02:00
protobuf = {
path = ./protobuf;
description = "Protobuf development environment";
2022-12-21 16:04:57 +01:00
};
2023-07-14 00:38:06 +02:00
pulumi = {
path = ./pulumi;
description = "Pulumi development environment";
};
2022-12-21 16:04:57 +01:00
purescript = {
path = ./purescript;
description = "Purescript development environment";
2022-07-29 02:49:09 +02:00
};
2022-07-31 22:33:11 +02:00
python = {
path = ./python;
description = "Python development environment";
};
2022-07-31 22:18:29 +02:00
ruby = {
path = ./ruby;
description = "Ruby development environment";
};
2022-07-29 00:42:22 +02:00
rust = {
path = ./rust;
description = "Rust development environment";
};
2022-07-28 23:54:27 +02:00
2022-10-20 16:14:56 +02:00
rust-toolchain = {
path = ./rust-toolchain;
description = "Rust development environment with Rust version defined by a rust-toolchain.toml file";
};
2022-07-29 00:42:22 +02:00
scala = {
path = ./scala;
description = "Scala development environment";
};
shell = {
path = ./shell;
description = "Shell script development environment";
};
2024-02-02 09:35:49 +01:00
vlang = {
path = ./vlang;
description = "Vlang developent environment";
};
2022-07-29 00:42:22 +02:00
zig = {
path = ./zig;
description = "Zig development environment";
};
2022-10-20 16:14:56 +02:00
# Aliases
rt = rust-toolchain;
c = c-cpp;
cpp = c-cpp;
2022-07-28 23:20:46 +02:00
};
2023-07-14 02:26:57 +02:00
};
2022-07-12 01:17:54 +02:00
}