chore: initial commit

This commit is contained in:
D. Moonfire 2024-01-28 14:32:33 -06:00
commit 20f4493a0d
13 changed files with 643 additions and 0 deletions

28
.editorconfig Normal file
View file

@ -0,0 +1,28 @@
root = true
["*"]
charset = "utf-8"
curly_bracket_next_line = true
end_of_line = "lf"
indent_brace_style = "K&R"
indent_size = 4
indent_style = "space"
insert_final_newline = true
max_line_length = 80
tab_width = 4
trim_trailing_whitespace = true
["*.md"]
max_line_length = "off"
["package.json"]
indent_size = 2
indent_style = "space"
tab_width = 2
["{LICENSES/**,LICENSE}"]
charset = "unset"
end_of_line = "unset"
indent_size = "unset"
indent_style = "unset"
insert_final_newline = "unset"
trim_trailing_whitespace = "unset"

1
.envrc Normal file
View file

@ -0,0 +1 @@
use flake || use nix

7
.gitignore vendored Normal file
View file

@ -0,0 +1,7 @@
.direnv/
# nixago: ignore-linked-files
/treefmt.toml
/.prettierrc.json
/lefthook.yml
/.conform.yaml

376
flake.lock Normal file
View file

@ -0,0 +1,376 @@
{
"nodes": {
"flake-utils": {
"locked": {
"lastModified": 1653893745,
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_2": {
"locked": {
"lastModified": 1653893745,
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_3": {
"locked": {
"lastModified": 1653893745,
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_4": {
"locked": {
"lastModified": 1653893745,
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_5": {
"locked": {
"lastModified": 1653893745,
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_6": {
"locked": {
"lastModified": 1653893745,
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_7": {
"locked": {
"lastModified": 1653893745,
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_8": {
"locked": {
"lastModified": 1653893745,
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"flake-utils_9": {
"locked": {
"lastModified": 1653893745,
"narHash": "sha256-0jntwV3Z8//YwuOjzhV2sgJJPt+HY6KhU7VZUL0fKZQ=",
"owner": "numtide",
"repo": "flake-utils",
"rev": "1ed9fb1935d260de5fe1c2f7ee0ebaae17ed2fa1",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "flake-utils",
"type": "github"
}
},
"nixago": {
"inputs": {
"flake-utils": "flake-utils",
"nixago-exts": "nixago-exts",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1687381756,
"narHash": "sha256-IUMIlYfrvj7Yli4H2vvyig8HEPpfCeMaE6+kBGPzFyk=",
"owner": "jmgilman",
"repo": "nixago",
"rev": "dacceb10cace103b3e66552ec9719fa0d33c0dc9",
"type": "github"
},
"original": {
"owner": "jmgilman",
"repo": "nixago",
"type": "github"
}
},
"nixago-exts": {
"inputs": {
"flake-utils": "flake-utils_2",
"nixago": "nixago_2",
"nixpkgs": [
"nixago",
"nixpkgs"
]
},
"locked": {
"lastModified": 1676070308,
"narHash": "sha256-QaJ65oc2l8iwQIGWUJ0EKjCeSuuCM/LqR8RauxZUUkc=",
"owner": "nix-community",
"repo": "nixago-extensions",
"rev": "e5380cb0456f4ea3c86cf94e3039eb856bf07d0b",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixago-extensions",
"type": "github"
}
},
"nixago-exts_2": {
"inputs": {
"flake-utils": "flake-utils_4",
"nixago": "nixago_3",
"nixpkgs": [
"nixago",
"nixago-exts",
"nixago",
"nixpkgs"
]
},
"locked": {
"lastModified": 1655508669,
"narHash": "sha256-BDDdo5dZQMmwNH/GNacy33nPBnCpSIydWFPZs0kkj/g=",
"owner": "nix-community",
"repo": "nixago-extensions",
"rev": "3022a932ce109258482ecc6568c163e8d0b426aa",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixago-extensions",
"type": "github"
}
},
"nixago-exts_3": {
"inputs": {
"flake-utils": "flake-utils_6",
"nixago": "nixago_4",
"nixpkgs": [
"nixpkgs"
]
},
"locked": {
"lastModified": 1676070308,
"narHash": "sha256-QaJ65oc2l8iwQIGWUJ0EKjCeSuuCM/LqR8RauxZUUkc=",
"owner": "nix-community",
"repo": "nixago-extensions",
"rev": "e5380cb0456f4ea3c86cf94e3039eb856bf07d0b",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixago-extensions",
"type": "github"
}
},
"nixago-exts_4": {
"inputs": {
"flake-utils": "flake-utils_8",
"nixago": "nixago_5",
"nixpkgs": [
"nixago-exts",
"nixago",
"nixpkgs"
]
},
"locked": {
"lastModified": 1655508669,
"narHash": "sha256-BDDdo5dZQMmwNH/GNacy33nPBnCpSIydWFPZs0kkj/g=",
"owner": "nix-community",
"repo": "nixago-extensions",
"rev": "3022a932ce109258482ecc6568c163e8d0b426aa",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixago-extensions",
"type": "github"
}
},
"nixago_2": {
"inputs": {
"flake-utils": "flake-utils_3",
"nixago-exts": "nixago-exts_2",
"nixpkgs": [
"nixago",
"nixago-exts",
"nixpkgs"
]
},
"locked": {
"lastModified": 1676070010,
"narHash": "sha256-iYzJIWptE1EUD8VINAg66AAMUajizg8JUYN3oBmb8no=",
"owner": "nix-community",
"repo": "nixago",
"rev": "d480ba6c0c16e2c5c0bd2122852d6a0c9ad1ed0e",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "rename-config-data",
"repo": "nixago",
"type": "github"
}
},
"nixago_3": {
"inputs": {
"flake-utils": "flake-utils_5",
"nixpkgs": [
"nixago",
"nixago-exts",
"nixago",
"nixago-exts",
"nixpkgs"
]
},
"locked": {
"lastModified": 1655405483,
"narHash": "sha256-Crd49aZWNrpczlRTOwWGfwBMsTUoG9vlHDKQC7cx264=",
"owner": "nix-community",
"repo": "nixago",
"rev": "e6a9566c18063db5b120e69e048d3627414e327d",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixago",
"type": "github"
}
},
"nixago_4": {
"inputs": {
"flake-utils": "flake-utils_7",
"nixago-exts": "nixago-exts_4",
"nixpkgs": [
"nixago-exts",
"nixpkgs"
]
},
"locked": {
"lastModified": 1676070010,
"narHash": "sha256-iYzJIWptE1EUD8VINAg66AAMUajizg8JUYN3oBmb8no=",
"owner": "nix-community",
"repo": "nixago",
"rev": "d480ba6c0c16e2c5c0bd2122852d6a0c9ad1ed0e",
"type": "github"
},
"original": {
"owner": "nix-community",
"ref": "rename-config-data",
"repo": "nixago",
"type": "github"
}
},
"nixago_5": {
"inputs": {
"flake-utils": "flake-utils_9",
"nixpkgs": [
"nixago-exts",
"nixago",
"nixago-exts",
"nixpkgs"
]
},
"locked": {
"lastModified": 1655405483,
"narHash": "sha256-Crd49aZWNrpczlRTOwWGfwBMsTUoG9vlHDKQC7cx264=",
"owner": "nix-community",
"repo": "nixago",
"rev": "e6a9566c18063db5b120e69e048d3627414e327d",
"type": "github"
},
"original": {
"owner": "nix-community",
"repo": "nixago",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1706098335,
"narHash": "sha256-r3dWjT8P9/Ah5m5ul4WqIWD8muj5F+/gbCdjiNVBKmU=",
"rev": "a77ab169a83a4175169d78684ddd2e54486ac651",
"revCount": 554858,
"type": "tarball",
"url": "https://api.flakehub.com/f/pinned/NixOS/nixpkgs/0.2311.554858%2Brev-a77ab169a83a4175169d78684ddd2e54486ac651/018d46f0-798f-71dc-a8c5-4689c46f7d12/source.tar.gz"
},
"original": {
"type": "tarball",
"url": "https://flakehub.com/f/NixOS/nixpkgs/%2A.tar.gz"
}
},
"root": {
"inputs": {
"nixago": "nixago",
"nixago-exts": "nixago-exts_3",
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

49
flake.nix Normal file
View file

@ -0,0 +1,49 @@
{
description = "Common setup for many projects that use a variety of languages.";
inputs = {
nixpkgs.url = "https://flakehub.com/f/NixOS/nixpkgs/*.tar.gz";
nixago.url = "github:jmgilman/nixago";
nixago.inputs.nixpkgs.follows = "nixpkgs";
nixago-exts.url = "github:nix-community/nixago-extensions";
nixago-exts.inputs.nixpkgs.follows = "nixpkgs";
};
outputs = inputs @ { self, nixpkgs, nixago, nixago-exts, ... }:
let
# Helpers for producing system-specific outputs
supportedSystems = [ "x86_64-linux" ];
forEachSupportedSystem = f: nixpkgs.lib.genAttrs supportedSystems (system: f {
inherit system;
pkgs = import nixpkgs { inherit system; };
});
in
{
# Expose the configuration options for setup.
nixosModules = {
mfgames-project-setup = import ./src/modules/default.nix;
default = self.nixosModules.mfgames-project-setup;
};
# Set up the developer shell.
# Development environments
devShells = forEachSupportedSystem ({ system, pkgs }:
let
configs = import ./src/configs/default.nix { inherit system pkgs nixago nixago-exts; };
in
{
# Shell
default = pkgs.mkShell {
shellHook = ''
${configs.shellHook}
lefthook install
'';
};
});
# Formatting for the Nix files
formatter = forEachSupportedSystem ({ pkgs, ... }: pkgs.nixpkgs-fmt);
};
}

22
src/configs/conform.nix Normal file
View file

@ -0,0 +1,22 @@
inputs @ { system, nixago, nixago-exts, ... }:
nixago-exts.conform.${system} {
commit = {
header = { length = 89; };
conventional = {
types = [
"build"
"chore"
"ci"
"docs"
"feat"
"fix"
"perf"
"refactor"
"style"
"test"
];
scopes = [ "cli" ];
};
};
}

9
src/configs/default.nix Normal file
View file

@ -0,0 +1,9 @@
inputs:
inputs.nixago.lib.${inputs.system}.makeAll [
(import ./conform.nix (inputs))
(import ./editorconfig.nix (inputs))
(import ./lefthook.nix (inputs))
(import ./prettier.nix (inputs))
#(import ./rustfmt.nix (inputs))
(import ./treefmt.nix (inputs))
]

View file

@ -0,0 +1,44 @@
inputs:
let
data = {
root = true;
"*" = {
end_of_line = "lf";
insert_final_newline = true;
trim_trailing_whitespace = true;
charset = "utf-8";
indent_style = "space";
indent_size = 4;
indent_brace_style = "K&R";
max_line_length = 80;
tab_width = 4;
curly_bracket_next_line = true;
};
"*.md" = {
max_line_length = "off";
};
"package.json" = {
indent_style = "space";
indent_size = 2;
tab_width = 2;
};
"{LICENSES/**,LICENSE}" = {
end_of_line = "unset";
insert_final_newline = "unset";
trim_trailing_whitespace = "unset";
charset = "unset";
indent_style = "unset";
indent_size = "unset";
};
};
in
{
inherit data;
hook.mode = "copy";
output = ".editorconfig";
format = "toml";
}

21
src/configs/lefthook.nix Normal file
View file

@ -0,0 +1,21 @@
inputs @ { system, pkgs, nixago, nixago-exts, ... }:
nixago-exts.lefthook.${system} {
commit-msg = {
commands = {
# Runs conform on commit-msg hook to ensure commit messages are
# compliant.
conform = {
run = "${pkgs.conform}/bin/conform enforce --commit-msg-file {1}";
};
};
};
pre-commit = {
commands = {
# Runs treefmt on pre-commit hook to ensure checked-in source code is
# properly formatted.
treefmt = {
run = "${pkgs.treefmt}/bin/treefmt {staged_files} && git add {staged_files}";
};
};
};
}

7
src/configs/prettier.nix Normal file
View file

@ -0,0 +1,7 @@
inputs @ { system, nixago, nixago-exts, ... }:
nixago-exts.prettier.${system} {
data = {
printWidth = 80;
proseWrap = "always";
};
}

17
src/configs/rustfmt.nix Normal file
View file

@ -0,0 +1,17 @@
inputs:
let
data = {
brace_style = "AlwaysNextLine";
indent_style = "Block";
reorder_imports = true;
imports_layout = "HorizontalVertical";
max_width = 80;
group_imports = "StdExternalCrate";
imports_granularity = "Module";
};
in
{
inherit data;
output = "rustfmt.toml";
format = "toml";
}

39
src/configs/treefmt.nix Normal file
View file

@ -0,0 +1,39 @@
inputs @ { pkgs, ... }:
let
data = {
formatter = {
nix = {
command = "nixpkgs-fmt";
includes = [ "*.nix" ];
};
prettier = {
command = "${pkgs.nodePackages.prettier}/bin/prettier";
options = [ "--write" ];
includes = [
"*.css"
"*.html"
"*.js"
"*.json"
"*.jsx"
"*.md"
"*.mdx"
"*.scss"
"*.ts"
"*.yaml"
];
excludes = [ "**.min.js" ];
};
rust = {
command = "rustfmt";
options = [ "--edition" "2021" ];
includes = [ "*.rs" ];
};
};
};
in
{
inherit data;
output = "treefmt.toml";
}

23
src/modules/default.nix Normal file
View file

@ -0,0 +1,23 @@
{ config, lib, pkgs, ... }:
let
cfg = config.mfgames-project-setup;
secretType = types.submodule ({ config, ... }: {
options = {
rust = mkOption {
type = types.bool;
default = false;
};
};
});
in
{
options.mfgames-project-setup = {
rust = mkOption {
type = types.bool;
default = true;
description = ''
Enabling this option including tools for handling Rust projects.
'';
};
};
}