Skip to content

Commit

Permalink
std/templates/minimal: get it to work with latest code
Browse files Browse the repository at this point in the history
  • Loading branch information
nazarewk committed Feb 6, 2024
1 parent 5ce7c94 commit 1727951
Show file tree
Hide file tree
Showing 6 changed files with 62 additions and 157 deletions.
4 changes: 2 additions & 2 deletions src/std/templates/minimal/.envrc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/bin/sh

# shellcheck disable=SC1090
. "$(fetchurl "https://raw.githubusercontent.com/paisano-nix/direnv/main/lib" "sha256-R3K8Flvbovj4IOvdlWNtQKLMMSQV464WjG9eU29ixHk=")"
. "$(fetchurl "https://github.com/paisano-nix/direnv/raw/bd36f51b9d566d8a36e230dab638abf3074625c3/lib" "sha256-IgQhKK7UHL1AfCUntJO2KCaIDJQotRnK2qC4Daxk+wI=")"

use envreload //repo/shells:default //repo/config
use envreload //repo/shells/default //repo/config
2 changes: 1 addition & 1 deletion src/std/templates/minimal/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ direnv allow
### Change Contribution Environment

```console
$EDITOR ./nix/repo/config.nix
$EDITOR ./nix/repo/configs.nix
direnv reload
```

Expand Down
11 changes: 4 additions & 7 deletions src/std/templates/minimal/book.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,8 @@ src = "docs"
title = "CONFIGURE-ME"

[build]
build-dir = "docs/build"
build-dir = "docs/book"

[output]
[output.html]

[output.linkcheck]

[preprocessor]
[preprocessor.paisano-preprocessor]
before = ["links"]
registry = ".#__std.init"
4 changes: 3 additions & 1 deletion src/std/templates/minimal/flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@

inputs.std.url = "github:divnix/std";
inputs.nixpkgs.follows = "std/nixpkgs";
inputs.std.inputs.devshell.url = "github:numtide/devshell";
inputs.std.inputs.nixago.url = "github:nix-community/nixago";

outputs = {std, ...} @ inputs:
outputs = { std, ... } @ inputs:
std.growOn {
inherit inputs;
cellsFrom = ./nix;
Expand Down
162 changes: 31 additions & 131 deletions src/std/templates/minimal/nix/repo/configs.nix
Original file line number Diff line number Diff line change
@@ -1,124 +1,45 @@
/*
This file holds configuration data for repo dotfiles.
This file holds configuration data for repo dotfiles.
Q: Why not just put the put the file there?
Q: Why not just put the put the file there?
A: (1) dotfile proliferation
(2) have all the things in one place / fromat
A:
(1) dotfile proliferation
(2) have all the things in one place / format
(3) potentially share / re-use configuration data - keeping it in sync
*/
{ inputs
, cell
,
}:
let
inherit (inputs.std.data) configs;
inherit (inputs.std.lib.dev) mkNixago;
in
{
inputs,
cell,
}: {
# Tool Homepage: https://editorconfig.org/
editorconfig = {
data = {
root = true;

"*" = {
end_of_line = "lf";
insert_final_newline = true;
trim_trailing_whitespace = true;
charset = "utf-8";
indent_style = "space";
indent_size = 2;
};

"*.{diff,patch}" = {
end_of_line = "unset";
insert_final_newline = "unset";
trim_trailing_whitespace = "unset";
indent_size = "unset";
};

"*.md" = {
max_line_length = "off";
trim_trailing_whitespace = false;
};

"{LICENSES/**,LICENSE}" = {
end_of_line = "unset";
insert_final_newline = "unset";
trim_trailing_whitespace = "unset";
charset = "unset";
indent_style = "unset";
indent_size = "unset";
};
};
editorconfig = (mkNixago configs.editorconfig) {
# see defaults at https://github.com/divnix/std/blob/5ce7c9411337af3cb299bc9b6cc0dc88f4c1ee0e/src/data/configs/editorconfig.nix
data = { };
};

# Tool Homepage: https://numtide.github.io/treefmt/
treefmt = {
packages = [
inputs.nixpkgs.alejandra
inputs.nixpkgs.nodePackages.prettier
inputs.nixpkgs.nodePackages.prettier-plugin-toml
inputs.nixpkgs.shfmt
];
devshell.startup.prettier-plugin-toml = inputs.nixpkgs.lib.stringsWithDeps.noDepEntry ''
export NODE_PATH=${inputs.nixpkgs.nodePackages.prettier-plugin-toml}/lib/node_modules:''${NODE_PATH-}
'';
data = {
formatter = {
nix = {
command = "alejandra";
includes = ["*.nix"];
};
prettier = {
command = "prettier";
options = ["--plugin" "prettier-plugin-toml" "--write"];
includes = [
"*.css"
"*.html"
"*.js"
"*.json"
"*.jsx"
"*.md"
"*.mdx"
"*.scss"
"*.ts"
"*.yaml"
"*.toml"
];
};
shell = {
command = "shfmt";
options = ["-i" "2" "-s" "-w"];
includes = ["*.sh"];
};
};
};
treefmt = (mkNixago configs.treefmt) {
# see defaults at https://github.com/divnix/std/blob/5ce7c9411337af3cb299bc9b6cc0dc88f4c1ee0e/src/data/configs/treefmt.nix
data = { };
};

# Tool Homepage: https://github.com/evilmartians/lefthook
lefthook = {
data = {
commit-msg = {
commands = {
conform = {
# allow WIP, fixup!/squash! commits locally
run = ''
[[ "$(head -n 1 {1})" =~ ^WIP(:.*)?$|^wip(:.*)?$|fixup\!.*|squash\!.* ]] ||
conform enforce --commit-msg-file {1}'';
skip = ["merge" "rebase"];
};
};
};
pre-commit = {
commands = {
treefmt = {
run = "treefmt --fail-on-change {staged_files}";
skip = ["merge" "rebase"];
};
};
};
};
conform = (mkNixago configs.conform) {
data = { inherit (inputs) cells; };
};

# Tool Hompeage: https://github.com/apps/settings
# Install Setting App in your repo to enable it
githubsettings = {
# Tool Homepage: https://github.com/evilmartians/lefthook
lefthook = (mkNixago configs.lefthook) {
# see defaults at https://github.com/divnix/std/blob/5ce7c9411337af3cb299bc9b6cc0dc88f4c1ee0e/src/data/configs/lefthook.nix
data = { };
};
githubsettings = (mkNixago configs.githubsettings) {
# see defaults at https://github.com/divnix/std/blob/5ce7c9411337af3cb299bc9b6cc0dc88f4c1ee0e/src/data/configs/githubsettings.nix
data = {
repository = {
name = "CONFIGURE-ME";
Expand All @@ -138,30 +59,9 @@ A: (1) dotfile proliferation
};
};
};

# Tool Homepage: https://rust-lang.github.io/mdBook/
mdbook = {
# add preprocessor packages here
packages = [
inputs.nixpkgs.mdbook-linkcheck
];
data = {
# Configuration Reference: https://rust-lang.github.io/mdBook/format/configuration/index.html
book = {
language = "en";
multilingual = false;
title = "CONFIGURE-ME";
src = "docs";
};
build.build-dir = "docs/build";
preprocessor = {};
output = {
html = {};
# Tool Homepage: https://github.com/Michael-F-Bryan/mdbook-linkcheck
linkcheck = {};
};
};
output = "book.toml";
hook.mode = "copy"; # let CI pick it up outside of devshell
mdbook = (mkNixago configs.mdbook) {
# see defaults at https://github.com/divnix/std/blob/5ce7c9411337af3cb299bc9b6cc0dc88f4c1ee0e/src/data/configs/mdbook.nix
data = { };
};
}
36 changes: 21 additions & 15 deletions src/std/templates/minimal/nix/repo/shells.nix
Original file line number Diff line number Diff line change
@@ -1,28 +1,34 @@
/*
This file holds reproducible shells with commands in them.
This file holds reproducible shells with commands in them.
They conveniently also generate config files in their startup hook.
They conveniently also generate config files in their startup hook.
*/
{
inputs,
cell,
}: let
inherit (inputs.std) lib;
in {
{ inputs
, cell
,
}:
let
inherit (inputs.std) lib std;
in
builtins.mapAttrs (_: lib.dev.mkShell) {
# Tool Homepage: https://numtide.github.io/devshell/
default = lib.dev.mkShell {
default = {
name = "CONFIGURE-ME";

imports = [
std.devshellProfiles.default
];

# Tool Homepage: https://nix-community.github.io/nixago/
# This is Standard's devshell integration.
# It runs the startup hook when entering the shell.
nixago = [
lib.cfg.conform
(lib.cfg.treefmt cell.configs.treefmt)
(lib.cfg.editorconfig cell.configs.editorconfig)
(lib.cfg.githubsettings cell.configs.githubsettings)
(lib.cfg.lefthook cell.configs.lefthook)
(lib.cfg.mdbook cell.configs.mdbook)
cell.configs.conform
cell.configs.editorconfig
cell.configs.githubsettings
cell.configs.lefthook
cell.configs.mdbook
cell.configs.treefmt
];

commands = [
Expand Down

0 comments on commit 1727951

Please sign in to comment.