feat: init
This commit is contained in:
commit
2ba65c62ce
16 changed files with 3817 additions and 0 deletions
5
flake.nix
Normal file
5
flake.nix
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
outputs = _: {
|
||||
templates.default.path = ./templates/default;
|
||||
};
|
||||
}
|
12
templates/default/.envrc
Normal file
12
templates/default/.envrc
Normal file
|
@ -0,0 +1,12 @@
|
|||
#!/usr/bin/env bash
|
||||
# Used by https://direnv.net
|
||||
|
||||
# Automatically reload when this file changes
|
||||
watch_file ./nix/devshells/default.nix
|
||||
watch_file ./nix/*.nix
|
||||
|
||||
# Load `nix develop`
|
||||
use flake .#rust
|
||||
|
||||
# Extend the environment with per-user overrides
|
||||
source_env_if_exists .envrc.local
|
24
templates/default/.gitignore
vendored
Normal file
24
templates/default/.gitignore
vendored
Normal file
|
@ -0,0 +1,24 @@
|
|||
# direnv
|
||||
.direnv/
|
||||
.env
|
||||
.envrc.local
|
||||
|
||||
# nix
|
||||
result
|
||||
result-*
|
||||
|
||||
# rust
|
||||
target/
|
||||
|
||||
# nixago: ignore-linked-files
|
||||
/treefmt.toml
|
||||
|
||||
# nats
|
||||
rust/*/tmp
|
||||
rust/*/jwt
|
||||
rust/*/*/test_leaf_server.conf
|
||||
rust/*/*/leaf_server.conf
|
||||
rust/*/*/resolver.conf
|
||||
leaf_server.conf
|
||||
.local
|
||||
|
18
templates/default/.vscode/settings.json
vendored
Normal file
18
templates/default/.vscode/settings.json
vendored
Normal file
|
@ -0,0 +1,18 @@
|
|||
{
|
||||
"editor.defaultFormatter": "ibecker.treefmt-vscode",
|
||||
"direnv.restart.automatic": true,
|
||||
"[nix]": {
|
||||
"editor.defaultFormatter": "jnoortheen.nix-ide",
|
||||
"editor.formatOnSave": true
|
||||
},
|
||||
"nix.enableLanguageServer": true,
|
||||
"nix.serverPath": "nil",
|
||||
"nix.serverSettings": {
|
||||
// settings for 'nil' LSP
|
||||
"nil": {
|
||||
"formatting": {
|
||||
"command": ["treefmt-nix", "--stdin", "neverexists.nix"]
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
3062
templates/default/Cargo.lock
generated
Normal file
3062
templates/default/Cargo.lock
generated
Normal file
File diff suppressed because it is too large
Load diff
28
templates/default/Cargo.toml
Normal file
28
templates/default/Cargo.toml
Normal file
|
@ -0,0 +1,28 @@
|
|||
[workspace]
|
||||
resolver = "2"
|
||||
package.version = "0.1.0"
|
||||
metadata.crane.name = "holo-host-workspace"
|
||||
|
||||
members = [
|
||||
"rust/hpos-hal",
|
||||
"rust/clients/host_agent",
|
||||
"rust/services/workload",
|
||||
"rust/util_libs",
|
||||
]
|
||||
|
||||
[workspace.dependencies]
|
||||
async-nats = { version = "0.38.0", features = ["service"] }
|
||||
tokio = { version = "1", features = ["full"] }
|
||||
futures = "0.3.31"
|
||||
anyhow = "1.0"
|
||||
serde = "1.0.215"
|
||||
serde_json = "1.0.133"
|
||||
dotenv = "0.15.0"
|
||||
env_logger = "0.11.0"
|
||||
log = "0.4.17"
|
||||
|
||||
[profile.dev]
|
||||
opt-level = "z"
|
||||
|
||||
[profile.release]
|
||||
opt-level = "z"
|
25
templates/default/README.md
Normal file
25
templates/default/README.md
Normal file
|
@ -0,0 +1,25 @@
|
|||
# rust workspace template
|
||||
|
||||
This is an experiment to contain the code for all components in a single repository, also known as a monorepository.
|
||||
|
||||
## Repository Layout
|
||||
|
||||
The code is grouped by language or framework name.
|
||||
|
||||
### Nix
|
||||
|
||||
```
|
||||
/flake.nix
|
||||
/flake.lock
|
||||
/nix/ /* [blueprint](https://github.com/numtide/blueprint) set up underneath here. */
|
||||
```
|
||||
|
||||
### Rust
|
||||
|
||||
```
|
||||
/Cargo.toml
|
||||
/Cargo.lock
|
||||
/rust/ # all rust code lives here
|
||||
/rust/common/Cargo.toml
|
||||
/rust/common/src/lib.rs
|
||||
```
|
377
templates/default/flake.lock
generated
Normal file
377
templates/default/flake.lock
generated
Normal file
|
@ -0,0 +1,377 @@
|
|||
{
|
||||
"nodes": {
|
||||
"blueprint": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
],
|
||||
"systems": "systems"
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1733562445,
|
||||
"narHash": "sha256-gLmqbX40Qos+EeBvmlzvntWB3NrdiDaFxhr3VAmhrf4=",
|
||||
"owner": "numtide",
|
||||
"repo": "blueprint",
|
||||
"rev": "97ef7fba3a6eec13e12a108ce4b3473602eb424f",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "blueprint",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"crane": {
|
||||
"locked": {
|
||||
"lastModified": 1734324364,
|
||||
"narHash": "sha256-omYTR59TdH0AumP1cfh49fBnWZ52HjfdNfaLzCMZBx0=",
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"rev": "60d7623f1320470bf2fdb92fd2dca1e9a27b98ce",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "ipetkov",
|
||||
"repo": "crane",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"disko": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1733168902,
|
||||
"narHash": "sha256-8dupm9GfK+BowGdQd7EHK5V61nneLfr9xR6sc5vtDi0=",
|
||||
"owner": "nix-community",
|
||||
"repo": "disko",
|
||||
"rev": "785c1e02c7e465375df971949b8dcbde9ec362e5",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "disko",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"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"
|
||||
}
|
||||
},
|
||||
"nixago": {
|
||||
"inputs": {
|
||||
"flake-utils": "flake-utils",
|
||||
"nixago-exts": "nixago-exts",
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1714086354,
|
||||
"narHash": "sha256-yKVQMxL9p7zCWUhnGhDzRVT8sDgHoI3V595lBK0C2YA=",
|
||||
"owner": "jmgilman",
|
||||
"repo": "nixago",
|
||||
"rev": "5133633e9fe6b144c8e00e3b212cdbd5a173b63d",
|
||||
"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_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"
|
||||
}
|
||||
},
|
||||
"nixpkgs": {
|
||||
"locked": {
|
||||
"lastModified": 1733550349,
|
||||
"narHash": "sha256-NcGumB4Lr6KSDq+nIqXtNA8QwAQKDSZT7N9OTGWbTrs=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "e2605d0744c2417b09f8bf850dfca42fcf537d34",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-24.11",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"nixpkgs-unstable": {
|
||||
"locked": {
|
||||
"lastModified": 1733581040,
|
||||
"narHash": "sha256-Qn3nPMSopRQJgmvHzVqPcE3I03zJyl8cSbgnnltfFDY=",
|
||||
"owner": "NixOS",
|
||||
"repo": "nixpkgs",
|
||||
"rev": "22c3f2cf41a0e70184334a958e6b124fb0ce3e01",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "NixOS",
|
||||
"ref": "nixos-unstable",
|
||||
"repo": "nixpkgs",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"root": {
|
||||
"inputs": {
|
||||
"blueprint": "blueprint",
|
||||
"crane": "crane",
|
||||
"disko": "disko",
|
||||
"nixago": "nixago",
|
||||
"nixpkgs": "nixpkgs",
|
||||
"nixpkgs-unstable": "nixpkgs-unstable",
|
||||
"rust-overlay": "rust-overlay",
|
||||
"srvos": "srvos",
|
||||
"treefmt-nix": "treefmt-nix"
|
||||
}
|
||||
},
|
||||
"rust-overlay": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1734489114,
|
||||
"narHash": "sha256-dKBBZr2pw7KDI/7GeiN5qPccqqtvnK2jqAMcMo4rVvU=",
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"rev": "b2e385f8e5c1d7c0d9ce738d650955c2e94555ae",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "oxalica",
|
||||
"repo": "rust-overlay",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"srvos": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1733706349,
|
||||
"narHash": "sha256-+V546s1ivi6epTinVhKhdx8h0r9Oiq2Lx4q+KDDqTTw=",
|
||||
"owner": "nix-community",
|
||||
"repo": "srvos",
|
||||
"rev": "aa9ae0b6b140410704e064b88d1f23a285bfd03e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-community",
|
||||
"repo": "srvos",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"systems": {
|
||||
"locked": {
|
||||
"lastModified": 1681028828,
|
||||
"narHash": "sha256-Vy1rq5AaRuLzOxct8nz4T6wlgyUR7zLU309k9mBC768=",
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"rev": "da67096a3b9bf56a91d16901293e51ba5b49a27e",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "nix-systems",
|
||||
"repo": "default",
|
||||
"type": "github"
|
||||
}
|
||||
},
|
||||
"treefmt-nix": {
|
||||
"inputs": {
|
||||
"nixpkgs": [
|
||||
"nixpkgs"
|
||||
]
|
||||
},
|
||||
"locked": {
|
||||
"lastModified": 1733761991,
|
||||
"narHash": "sha256-s4DalCDepD22jtKL5Nw6f4LP5UwoMcPzPZgHWjAfqbQ=",
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"rev": "0ce9d149d99bc383d1f2d85f31f6ebd146e46085",
|
||||
"type": "github"
|
||||
},
|
||||
"original": {
|
||||
"owner": "numtide",
|
||||
"repo": "treefmt-nix",
|
||||
"type": "github"
|
||||
}
|
||||
}
|
||||
},
|
||||
"root": "root",
|
||||
"version": 7
|
||||
}
|
33
templates/default/flake.nix
Normal file
33
templates/default/flake.nix
Normal file
|
@ -0,0 +1,33 @@
|
|||
{
|
||||
description = "holo-host monorepository";
|
||||
|
||||
inputs = {
|
||||
nixpkgs.url = "github:NixOS/nixpkgs?ref=nixos-24.11";
|
||||
nixpkgs-unstable.url = "github:NixOS/nixpkgs?ref=nixos-unstable";
|
||||
blueprint.url = "github:numtide/blueprint";
|
||||
blueprint.inputs.nixpkgs.follows = "nixpkgs";
|
||||
treefmt-nix.url = "github:numtide/treefmt-nix";
|
||||
treefmt-nix.inputs.nixpkgs.follows = "nixpkgs";
|
||||
nixago.url = "github:jmgilman/nixago";
|
||||
nixago.inputs.nixpkgs.follows = "nixpkgs";
|
||||
|
||||
srvos.url = "github:nix-community/srvos";
|
||||
srvos.inputs.nixpkgs.follows = "nixpkgs";
|
||||
disko.url = "github:nix-community/disko";
|
||||
disko.inputs.nixpkgs.follows = "nixpkgs";
|
||||
|
||||
crane.url = "github:ipetkov/crane";
|
||||
rust-overlay = {
|
||||
url = "github:oxalica/rust-overlay";
|
||||
inputs.nixpkgs.follows = "nixpkgs";
|
||||
};
|
||||
};
|
||||
|
||||
outputs =
|
||||
inputs:
|
||||
inputs.blueprint {
|
||||
inherit inputs;
|
||||
prefix = "nix/";
|
||||
nixpkgs.config.allowUnfree = true;
|
||||
};
|
||||
}
|
27
templates/default/nix/devshells/default.nix
Normal file
27
templates/default/nix/devshells/default.nix
Normal file
|
@ -0,0 +1,27 @@
|
|||
{
|
||||
pkgs,
|
||||
flake,
|
||||
system,
|
||||
}:
|
||||
pkgs.mkShell {
|
||||
# Add build dependencies
|
||||
packages = [
|
||||
flake.formatter.${system}
|
||||
pkgs.jq
|
||||
];
|
||||
|
||||
# Add environment variables
|
||||
env = { };
|
||||
|
||||
# Load custom bash code
|
||||
shellHook =
|
||||
# TODO(blocked/upstream): remove this once https://github.com/isbecker/treefmt-vscode/issues/3 is resolved
|
||||
(flake.inputs.nixago.lib.${system}.make {
|
||||
data = flake.formatter.${system}.settings;
|
||||
output = "treefmt.toml";
|
||||
format = "toml";
|
||||
}).shellHook
|
||||
+ ''
|
||||
echo $(git rev-parse --show-toplevel)
|
||||
'';
|
||||
}
|
34
templates/default/nix/devshells/rust.nix
Normal file
34
templates/default/nix/devshells/rust.nix
Normal file
|
@ -0,0 +1,34 @@
|
|||
{
|
||||
flake,
|
||||
system,
|
||||
pkgs,
|
||||
...
|
||||
}:
|
||||
let
|
||||
craneLib = flake.lib.mkCraneLib { inherit pkgs system; };
|
||||
in
|
||||
craneLib.devShell {
|
||||
inputsFrom =
|
||||
[
|
||||
flake.devShells.${system}.default
|
||||
]
|
||||
# Inherit inputs from rust-workspace on the platforms it's available.
|
||||
++ (pkgs.lib.lists.optionals
|
||||
(pkgs.lib.meta.availableOn pkgs.stdenv.hostPlatform flake.packages.${system}.rust-workspace)
|
||||
(
|
||||
[
|
||||
flake.packages.${system}.rust-workspace
|
||||
|
||||
]
|
||||
++ (builtins.attrValues flake.packages.${system}.rust-workspace.passthru.tests)
|
||||
)
|
||||
);
|
||||
|
||||
# Additional dev-shell environment variables can be set directly
|
||||
# MY_CUSTOM_DEVELOPMENT_VAR = "something else";
|
||||
|
||||
# Extra inputs can be added here; cargo and rustc are provided by default.
|
||||
packages = [
|
||||
pkgs.natscli
|
||||
];
|
||||
}
|
70
templates/default/nix/formatter.nix
Normal file
70
templates/default/nix/formatter.nix
Normal file
|
@ -0,0 +1,70 @@
|
|||
{
|
||||
pkgs,
|
||||
inputs,
|
||||
perSystem,
|
||||
...
|
||||
}:
|
||||
let
|
||||
settingsNix = {
|
||||
package = perSystem.nixpkgs.treefmt2;
|
||||
|
||||
projectRootFile = ".git/config";
|
||||
|
||||
programs = {
|
||||
nixfmt.enable = true;
|
||||
deadnix = {
|
||||
enable = true;
|
||||
no-underscore = true;
|
||||
};
|
||||
statix.enable = true;
|
||||
|
||||
rustfmt.enable = true;
|
||||
|
||||
gofmt.enable = true;
|
||||
|
||||
shfmt.enable = true;
|
||||
|
||||
prettier.enable = true;
|
||||
} // pkgs.lib.optionalAttrs (pkgs.system != "riscv64-linux") { shellcheck.enable = true; };
|
||||
|
||||
settings = {
|
||||
global.excludes = [
|
||||
"LICENSE"
|
||||
# unsupported extensions
|
||||
"*.{gif,png,svg,tape,mts,lock,mod,sum,toml,env,envrc,gitignore}"
|
||||
];
|
||||
|
||||
formatter = {
|
||||
deadnix = {
|
||||
priority = 1;
|
||||
};
|
||||
|
||||
nixfmt = {
|
||||
priority = 2;
|
||||
};
|
||||
|
||||
statix = {
|
||||
priority = 3;
|
||||
};
|
||||
|
||||
prettier = {
|
||||
options = [
|
||||
"--tab-width"
|
||||
"2"
|
||||
];
|
||||
includes = [ "*.{css,html,js,json,jsx,md,mdx,scss,ts,yaml}" ];
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
|
||||
treefmtEval = inputs.treefmt-nix.lib.evalModule pkgs settingsNix;
|
||||
|
||||
in
|
||||
treefmtEval.config.build.wrapper.overrideAttrs (_: {
|
||||
passthru = {
|
||||
inherit (treefmtEval.config) package settings;
|
||||
inherit (treefmtEval) config;
|
||||
inherit settingsNix;
|
||||
};
|
||||
})
|
13
templates/default/nix/lib/default.nix
Normal file
13
templates/default/nix/lib/default.nix
Normal file
|
@ -0,0 +1,13 @@
|
|||
{ inputs, flake, ... }:
|
||||
|
||||
{
|
||||
mkCraneLib =
|
||||
{ pkgs, system }:
|
||||
let
|
||||
craneLib = inputs.crane.mkLib pkgs;
|
||||
toolchain = (inputs.rust-overlay.lib.mkRustBin { } pkgs).fromRustupToolchainFile (
|
||||
flake + "/rust-toolchain.toml"
|
||||
);
|
||||
in
|
||||
craneLib.overrideToolchain toolchain;
|
||||
}
|
83
templates/default/nix/packages/rust-workspace.nix
Normal file
83
templates/default/nix/packages/rust-workspace.nix
Normal file
|
@ -0,0 +1,83 @@
|
|||
/*
|
||||
This exposes all crates in the workspace as a single package attribute.
|
||||
It also enforces various tests.
|
||||
|
||||
Losely following the tutorial at https://crane.dev/examples/quick-start-workspace.html
|
||||
*/
|
||||
|
||||
{
|
||||
flake,
|
||||
pkgs,
|
||||
system,
|
||||
...
|
||||
}:
|
||||
let
|
||||
craneLib = flake.lib.mkCraneLib { inherit pkgs system; };
|
||||
src = craneLib.cleanCargoSource flake;
|
||||
commonArgs = {
|
||||
inherit src;
|
||||
strictDeps = true;
|
||||
|
||||
buildInputs = pkgs.lib.optionals pkgs.stdenv.isDarwin [
|
||||
# Additional darwin specific inputs can be set here
|
||||
pkgs.libiconv
|
||||
];
|
||||
|
||||
# Additional environment variables can be set directly
|
||||
# MY_CUSTOM_VAR = "some value";
|
||||
|
||||
meta.platforms = pkgs.lib.platforms.linux;
|
||||
};
|
||||
|
||||
# Build *just* the cargo dependencies (of the entire workspace),
|
||||
# so we can reuse all of that work (e.g. via cachix) when running in CI
|
||||
# It is *highly* recommended to use something like cargo-hakari to avoid
|
||||
# cache misses when building individual top-level-crates
|
||||
cargoArtifacts = craneLib.buildDepsOnly commonArgs;
|
||||
in
|
||||
craneLib.cargoBuild (
|
||||
commonArgs
|
||||
// {
|
||||
inherit cargoArtifacts;
|
||||
|
||||
# NB: we disable tests since we'll run them all via cargo-nextest
|
||||
doCheck = false;
|
||||
|
||||
passthru.tests = {
|
||||
clippy = craneLib.cargoClippy (
|
||||
commonArgs
|
||||
// {
|
||||
inherit cargoArtifacts;
|
||||
cargoClippyExtraArgs = "--all-targets -- --deny warnings";
|
||||
}
|
||||
);
|
||||
|
||||
doc = craneLib.cargoDoc (
|
||||
commonArgs
|
||||
// {
|
||||
inherit cargoArtifacts;
|
||||
}
|
||||
);
|
||||
|
||||
# Audit licenses
|
||||
deny = craneLib.cargoDeny {
|
||||
inherit src;
|
||||
};
|
||||
|
||||
nextest = craneLib.cargoNextest (
|
||||
commonArgs
|
||||
// {
|
||||
inherit cargoArtifacts;
|
||||
|
||||
nativeBuildInputs = [
|
||||
# native test binaries go here
|
||||
];
|
||||
partitions = 1;
|
||||
partitionType = "count";
|
||||
}
|
||||
);
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
)
|
5
templates/default/rust-toolchain.toml
Normal file
5
templates/default/rust-toolchain.toml
Normal file
|
@ -0,0 +1,5 @@
|
|||
[toolchain]
|
||||
channel = "1.83.0"
|
||||
components = [ "cargo","llvm-tools", "rustc", "clippy", "rust-src" ]
|
||||
targets = [ ]
|
||||
profile = "minimal"
|
1
templates/default/treefmt.toml
Symbolic link
1
templates/default/treefmt.toml
Symbolic link
|
@ -0,0 +1 @@
|
|||
/nix/store/2q0p32grc9y40gilz6z9ck5nmq5ypx4n-treefmt.toml
|
Loading…
Add table
Add a link
Reference in a new issue