-
Notifications
You must be signed in to change notification settings - Fork 0
/
flake.nix
96 lines (88 loc) · 2.62 KB
/
flake.nix
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
{
description = "A collection of templates";
nixConfig = {
substituters = [
"https://cache.nixos.org"
"https://nix-community.cachix.org"
];
trusted-public-keys = [
"cache.nixos.org-1:6NCHdD59X431o0gWypbMrAURkbJ16ZPMQFGspcDShjY="
"nix-community.cachix.org-1:mB9FSh9qf2dCimDSUo8Zy7bkq5CX+/rkCWyvRCYg3Fs="
];
};
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
devshell = {
url = "github:numtide/devshell";
inputs.nixpkgs.follows = "nixpkgs";
inputs.flake-utils.follows = "flake-utils";
};
};
outputs = {
self,
devshell,
flake-utils,
nixpkgs,
...
} @ inputs:
with (flake-utils.lib);
eachDefaultSystem
(system: let
pkgs = import nixpkgs {
inherit system;
overlays = [
devshell.overlay
];
};
linters = with pkgs; [
alejandra # https://github.com/kamadorueda/alejandra
gofumpt # https://github.com/mvdan/gofumpt
nodePackages.prettier # https://prettier.io/
treefmt # https://github.com/numtide/treefmt
];
# devshell command categories
pkgWithCategory = category: package: {inherit package category;};
formatter = pkgWithCategory "formatters";
util = pkgWithCategory "utils";
in {
# nix develop
devShells.default = pkgs.devshell.mkShell {
packages = with pkgs;
[
just # https://github.com/casey/just
]
++ linters;
commands = with pkgs; [
(formatter alejandra)
(formatter gofumpt)
(formatter nodePackages.prettier)
(util jq)
(util just)
];
};
# nix flake check
checks = {
format =
pkgs.runCommandNoCC "treefmt" {
nativeBuildInputs = linters;
} ''
# keep timestamps so that treefmt is able to detect mtime changes
cp --no-preserve=mode --preserve=timestamps -r ${self} source
cd source
HOME=$TMPDIR treefmt --fail-on-change
touch $out
'';
};
})
// {
# nix flake new --template github:41north/templates#<template> ./new-dir
templates = {
# nix flake new --template github:41north/templates#go ./new-project
go = {
path = ./go;
description = "This template is prepared for creating a new go-lib / go-app kind of project.";
};
};
};
}