Add treefmt-nix for formatting all the files

This commit is contained in:
ulic-youthlic 2025-06-06 11:02:49 +08:00
parent 1a9a4243fe
commit ceecc82aae
Signed by: youthlic
GPG key ID: 63E86C3C14A0D721
11 changed files with 151 additions and 52 deletions

View file

@ -4,9 +4,10 @@ ignore-parent = true
ignore-hidden = false ignore-hidden = false
ignore-files = true ignore-files = true
ignore-vcs = true ignore-vcs = true
extend-exclude = ["secrets/", ".git/", "public-key.txt"] extend-exclude = ["secrets/*", ".git/*", "**/public-key.txt"]
[default] [default]
binary = false
check-filename = true check-filename = true
check-file = true check-file = true
unicode = true unicode = true

View file

@ -1,2 +1 @@
{ {}
}

View file

Before

Width:  |  Height:  |  Size: 212 KiB

After

Width:  |  Height:  |  Size: 212 KiB

Before After
Before After

View file

Before

Width:  |  Height:  |  Size: 3.2 MiB

After

Width:  |  Height:  |  Size: 3.2 MiB

Before After
Before After

37
flake.lock generated
View file

@ -605,6 +605,22 @@
"type": "github" "type": "github"
} }
}, },
"nixpkgs_3": {
"locked": {
"lastModified": 1747958103,
"narHash": "sha256-qmmFCrfBwSHoWw7cVK4Aj+fns+c54EBP8cGqp/yK410=",
"owner": "nixos",
"repo": "nixpkgs",
"rev": "fe51d34885f7b5e3e7b59572796e1bcb427eccb1",
"type": "github"
},
"original": {
"owner": "nixos",
"ref": "nixpkgs-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nur": { "nur": {
"inputs": { "inputs": {
"flake-parts": [ "flake-parts": [
@ -665,7 +681,8 @@
"nixpkgs": "nixpkgs_2", "nixpkgs": "nixpkgs_2",
"nur-rycee": "nur-rycee", "nur-rycee": "nur-rycee",
"sops-nix": "sops-nix", "sops-nix": "sops-nix",
"stylix": "stylix" "stylix": "stylix",
"treefmt-nix": "treefmt-nix_2"
} }
}, },
"rust-overlay": { "rust-overlay": {
@ -904,6 +921,24 @@
"type": "github" "type": "github"
} }
}, },
"treefmt-nix_2": {
"inputs": {
"nixpkgs": "nixpkgs_3"
},
"locked": {
"lastModified": 1748243702,
"narHash": "sha256-9YzfeN8CB6SzNPyPm2XjRRqSixDopTapaRsnTpXUEY8=",
"owner": "numtide",
"repo": "treefmt-nix",
"rev": "1f3f7b784643d488ba4bf315638b2b0a4c5fb007",
"type": "github"
},
"original": {
"owner": "numtide",
"repo": "treefmt-nix",
"type": "github"
}
},
"xwayland-satellite-stable": { "xwayland-satellite-stable": {
"flake": false, "flake": false,
"locked": { "locked": {

View file

@ -133,6 +133,12 @@
utils.follows = "flake-utils"; utils.follows = "flake-utils";
}; };
}; };
treefmt-nix = {
type = "github";
owner = "numtide";
repo = "treefmt-nix";
};
}; };
outputs = { outputs = {
self, self,
@ -153,6 +159,7 @@
systems = flake-utils.lib.defaultSystems; systems = flake-utils.lib.defaultSystems;
imports = [ imports = [
inputs.home-manager.flakeModules.home-manager inputs.home-manager.flakeModules.home-manager
inputs.treefmt-nix.flakeModule
nixos nixos
home home
deploy deploy
@ -169,11 +176,10 @@
allowUnfree = true; allowUnfree = true;
}; };
}; };
formatter = pkgs.alejandra;
packages = import ./pkgs ( packages = import ./pkgs (
args args
// { // {
inherit inputs; inherit inputs rootPath;
} }
); );
devShells.default = pkgs.mkShell { devShells.default = pkgs.mkShell {
@ -185,6 +191,62 @@
nvfetcher nvfetcher
]; ];
}; };
treefmt = {
programs = {
alejandra = {
enable = true;
excludes = ["pkgs/_sources/*.nix"];
};
biome = {
enable = true;
includes = ["*.json"];
excludes = ["pkgs/_sources/*.json"];
settings = {
javascript.formatter.enabled = false;
css.formatter.enabled = false;
};
};
dprint = {
enable = true;
includes = ["*.md" "*.toml" "*.yaml"];
excludes = ["secrets/*.yaml"];
settings = {
plugins = pkgs.dprint-plugins.getPluginList (plugins:
with plugins; [
dprint-plugin-toml
dprint-plugin-markdown
g-plane-pretty_yaml
]);
};
};
just = {
enable = true;
includes = [".justfile"];
};
typos = let
config = ./.typos.toml |> builtins.readFile |> builtins.fromTOML;
in {
enable = true;
includes = ["*"];
excludes = ["assets/*"] ++ config.files.extend-exclude;
configFile = "${toString ./.typos.toml}";
# Disable all extra option in treefmt module.
# Use config file.
sort = false;
isolated = false;
hidden = false;
noIgnore = false;
noIgnoreDot = false;
noIgnoreGlobal = false;
noIgnoreParent = false;
noIgnoreVCS = false;
binary = false;
noCheckFilenames = false;
noCheckFiles = false;
noUnicode = false;
};
};
};
}; };
flake = { flake = {
overlays = { overlays = {

View file

@ -51,7 +51,6 @@ repo_root_style = "bold green"
use_os_path_sep = false use_os_path_sep = false
read_only = " 󰌾" read_only = " 󰌾"
[aws] [aws]
symbol = " " symbol = " "
@ -210,4 +209,3 @@ symbol = " "
[zig] [zig]
symbol = " " symbol = " "

View file

@ -1,10 +1,11 @@
{ {
pkgs, pkgs,
inputs, inputs,
rootPath,
... ...
}: let }: let
srcs = pkgs.callPackage ./_sources/generated.nix {}; srcs = pkgs.callPackage ./_sources/generated.nix {};
callPackage = pkgs.lib.callPackageWith (pkgs // {inherit inputs srcs callPackage;}); callPackage = pkgs.lib.callPackageWith (pkgs // {inherit inputs srcs callPackage rootPath;});
in in
{ {
pinentry-selector = callPackage ./pinentry-selector.nix {}; pinentry-selector = callPackage ./pinentry-selector.nix {};
@ -13,7 +14,7 @@ in
rime-ice = callPackage ./rime-ice.nix {}; rime-ice = callPackage ./rime-ice.nix {};
dioxionary = callPackage ./dioxionary.nix {}; dioxionary = callPackage ./dioxionary.nix {};
spotifyx = callPackage ./spotifyx.nix {}; spotifyx = callPackage ./spotifyx.nix {};
radicle-explorer = callPackage ./radicle-explorer {}; radicle-explorer = callPackage ./radicle-explorer.nix {};
TrackersListCollection = callPackage ./TrackersListCollection.nix {}; TrackersListCollection = callPackage ./TrackersListCollection.nix {};
wshowkeys-mao = callPackage ./wshowkeys-mao.nix {}; wshowkeys-mao = callPackage ./wshowkeys-mao.nix {};
OuterWildsTextAdventure = callPackage ./OuterWildsTextAdventure.nix {}; OuterWildsTextAdventure = callPackage ./OuterWildsTextAdventure.nix {};

View file

@ -1,4 +1,7 @@
{pkgs}: {
pkgs,
rootPath,
}:
(pkgs.radicle-explorer.withConfig { (pkgs.radicle-explorer.withConfig {
preferredSeeds = [ preferredSeeds = [
{ {
@ -26,7 +29,7 @@
postInstall = postInstall =
(prev.postInstall or "") (prev.postInstall or "")
+ '' + ''
ln -s ${./youthlic-seed-header.png} $out/images/youthlic-seed-header.png ln -s ${rootPath + "/assets/radicle-explorer/youthlic-seed-header.png"} $out/images/youthlic-seed-header.png
ln -s ${./youthlic-seed-avatar.jpg} $out/images/youthlic-seed-avatar.jpg ln -s ${rootPath + "/assets/radicle-explorer/youthlic-seed-avatar.jpg"} $out/images/youthlic-seed-avatar.jpg
''; '';
}) })

View file

@ -12,8 +12,8 @@ stale = false
[output] [output]
deny = ["unmaintained"] # exit on error if unmaintained dependencies are found deny = ["unmaintained"] # exit on error if unmaintained dependencies are found
format = "terminal" # "terminal" (human readable report) or "json" format = "terminal" # "terminal" (human readable report) or "json"
quiet = false # Only print information on error quiet = false # Only print information on error
show_tree = true show_tree = true
[target] [target]

View file

@ -25,11 +25,11 @@
targets = [ targets = [
# The triple can be any string, but only the target triples built in to # The triple can be any string, but only the target triples built in to
# rustc (as of 1.40) can be checked against actual config expressions # rustc (as of 1.40) can be checked against actual config expressions
#"x86_64-unknown-linux-musl", # "x86_64-unknown-linux-musl",
# You can also specify which target_features you promise are enabled for a # You can also specify which target_features you promise are enabled for a
# particular target. target_features are currently not validated against # particular target. target_features are currently not validated against
# the actual valid features supported by the target architecture. # the actual valid features supported by the target architecture.
#{ triple = "wasm32-unknown-unknown", features = ["atomics"] }, # { triple = "wasm32-unknown-unknown", features = ["atomics"] },
] ]
# When creating the dependency graph used as the source of truth when checks are # When creating the dependency graph used as the source of truth when checks are
# executed, this field can be used to prune crates from the graph, removing them # executed, this field can be used to prune crates from the graph, removing them
@ -38,7 +38,7 @@ targets = [
# they are connected to another crate in the graph that hasn't been pruned, # they are connected to another crate in the graph that hasn't been pruned,
# so it should be used with care. The identifiers are [Package ID Specifications] # so it should be used with care. The identifiers are [Package ID Specifications]
# (https://doc.rust-lang.org/cargo/reference/pkgid-spec.html) # (https://doc.rust-lang.org/cargo/reference/pkgid-spec.html)
#exclude = [] # exclude = []
# If true, metadata will be collected with `--all-features`. Note that this can't # If true, metadata will be collected with `--all-features`. Note that this can't
# be toggled off if true, if you want to conditionally enable `--all-features` it # be toggled off if true, if you want to conditionally enable `--all-features` it
# is recommended to pass `--all-features` on the cmd line instead # is recommended to pass `--all-features` on the cmd line instead
@ -48,7 +48,7 @@ all-features = false
no-default-features = false no-default-features = false
# If set, these feature will be enabled when collecting metadata. If `--features` # If set, these feature will be enabled when collecting metadata. If `--features`
# is specified on the cmd line they will take precedence over this option. # is specified on the cmd line they will take precedence over this option.
#features = [] # features = []
# The output table provides options for how/if diagnostics are outputted # The output table provides options for how/if diagnostics are outputted
[output] [output]
@ -64,22 +64,22 @@ feature-depth = 1
# https://embarkstudios.github.io/cargo-deny/checks/advisories/cfg.html # https://embarkstudios.github.io/cargo-deny/checks/advisories/cfg.html
[advisories] [advisories]
# The path where the advisory databases are cloned/fetched into # The path where the advisory databases are cloned/fetched into
#db-path = "$CARGO_HOME/advisory-dbs" # db-path = "$CARGO_HOME/advisory-dbs"
# The url(s) of the advisory databases to use # The url(s) of the advisory databases to use
#db-urls = ["https://github.com/rustsec/advisory-db"] # db-urls = ["https://github.com/rustsec/advisory-db"]
# A list of advisory IDs to ignore. Note that ignored advisories will still # A list of advisory IDs to ignore. Note that ignored advisories will still
# output a note when they are encountered. # output a note when they are encountered.
ignore = [ ignore = [
#"RUSTSEC-0000-0000", # "RUSTSEC-0000-0000",
#{ id = "RUSTSEC-0000-0000", reason = "you can specify a reason the advisory is ignored" }, # { id = "RUSTSEC-0000-0000", reason = "you can specify a reason the advisory is ignored" },
#"a-crate-that-is-yanked@0.1.1", # you can also ignore yanked crate versions if you wish # "a-crate-that-is-yanked@0.1.1", # you can also ignore yanked crate versions if you wish
#{ crate = "a-crate-that-is-yanked@0.1.1", reason = "you can specify why you are ignoring the yanked crate" }, # { crate = "a-crate-that-is-yanked@0.1.1", reason = "you can specify why you are ignoring the yanked crate" },
] ]
# If this is true, then cargo deny will use the git executable to fetch advisory database. # If this is true, then cargo deny will use the git executable to fetch advisory database.
# If this is false, then it uses a built-in git library. # If this is false, then it uses a built-in git library.
# Setting this to true can be helpful if you have special authentication requirements that cargo-deny does not support. # Setting this to true can be helpful if you have special authentication requirements that cargo-deny does not support.
# See Git Authentication for more information about setting up git authentication. # See Git Authentication for more information about setting up git authentication.
#git-fetch-with-cli = true # git-fetch-with-cli = true
# This section is considered when running `cargo deny check licenses` # This section is considered when running `cargo deny check licenses`
# More documentation for the licenses section can be found here: # More documentation for the licenses section can be found here:
@ -90,9 +90,9 @@ ignore = [
# [possible values: any SPDX 3.11 short identifier (+ optional exception)]. # [possible values: any SPDX 3.11 short identifier (+ optional exception)].
allow = [ allow = [
"MIT", "MIT",
#"Apache-2.0", # "Apache-2.0",
#"Apache-2.0 WITH LLVM-exception", # "Apache-2.0 WITH LLVM-exception",
"GPL-3.0" "GPL-3.0",
] ]
# The confidence threshold for detecting a license from license text. # The confidence threshold for detecting a license from license text.
# The higher the value, the more closely the license text must be to the # The higher the value, the more closely the license text must be to the
@ -104,26 +104,26 @@ confidence-threshold = 0.8
exceptions = [ exceptions = [
# Each entry is the crate and version constraint, and its specific allow # Each entry is the crate and version constraint, and its specific allow
# list # list
#{ allow = ["Zlib"], crate = "adler32" }, # { allow = ["Zlib"], crate = "adler32" },
] ]
# Some crates don't have (easily) machine readable licensing information, # Some crates don't have (easily) machine readable licensing information,
# adding a clarification entry for it allows you to manually specify the # adding a clarification entry for it allows you to manually specify the
# licensing information # licensing information
#[[licenses.clarify]] # [[licenses.clarify]]
# The package spec the clarification applies to # The package spec the clarification applies to
#crate = "ring" # crate = "ring"
# The SPDX expression for the license requirements of the crate # The SPDX expression for the license requirements of the crate
#expression = "MIT AND ISC AND OpenSSL" # expression = "MIT AND ISC AND OpenSSL"
# One or more files in the crate's source used as the "source of truth" for # One or more files in the crate's source used as the "source of truth" for
# the license expression. If the contents match, the clarification will be used # the license expression. If the contents match, the clarification will be used
# when running the license check, otherwise the clarification will be ignored # when running the license check, otherwise the clarification will be ignored
# and the crate will be checked normally, which may produce warnings or errors # and the crate will be checked normally, which may produce warnings or errors
# depending on the rest of your configuration # depending on the rest of your configuration
#license-files = [ # license-files = [
# Each entry is a crate relative path, and the (opaque) hash of its contents # Each entry is a crate relative path, and the (opaque) hash of its contents
#{ path = "LICENSE", hash = 0xbd0eed23 } # { path = "LICENSE", hash = 0xbd0eed23 }
#] # ]
[licenses.private] [licenses.private]
# If true, ignores workspace crates that aren't published, or are only # If true, ignores workspace crates that aren't published, or are only
@ -135,7 +135,7 @@ ignore = false
# is only published to private registries, and ignore is true, the crate will # is only published to private registries, and ignore is true, the crate will
# not have its license(s) checked # not have its license(s) checked
registries = [ registries = [
#"https://sekretz.com/registry # "https://sekretz.com/registry
] ]
# This section is considered when running `cargo deny check bans`. # This section is considered when running `cargo deny check bans`.
@ -162,27 +162,27 @@ workspace-default-features = "allow"
external-default-features = "allow" external-default-features = "allow"
# List of crates that are allowed. Use with care! # List of crates that are allowed. Use with care!
allow = [ allow = [
#"ansi_term@0.11.0", # "ansi_term@0.11.0",
#{ crate = "ansi_term@0.11.0", reason = "you can specify a reason it is allowed" }, # { crate = "ansi_term@0.11.0", reason = "you can specify a reason it is allowed" },
] ]
# List of crates to deny # List of crates to deny
deny = [ deny = [
#"ansi_term@0.11.0", # "ansi_term@0.11.0",
#{ crate = "ansi_term@0.11.0", reason = "you can specify a reason it is banned" }, # { crate = "ansi_term@0.11.0", reason = "you can specify a reason it is banned" },
# Wrapper crates can optionally be specified to allow the crate when it # Wrapper crates can optionally be specified to allow the crate when it
# is a direct dependency of the otherwise banned crate # is a direct dependency of the otherwise banned crate
#{ crate = "ansi_term@0.11.0", wrappers = ["this-crate-directly-depends-on-ansi_term"] }, # { crate = "ansi_term@0.11.0", wrappers = ["this-crate-directly-depends-on-ansi_term"] },
] ]
# List of features to allow/deny # List of features to allow/deny
# Each entry the name of a crate and a version range. If version is # Each entry the name of a crate and a version range. If version is
# not specified, all versions will be matched. # not specified, all versions will be matched.
#[[bans.features]] # [[bans.features]]
#crate = "reqwest" # crate = "reqwest"
# Features to not allow # Features to not allow
#deny = ["json"] # deny = ["json"]
# Features to allow # Features to allow
#allow = [ # allow = [
# "rustls", # "rustls",
# "__rustls", # "__rustls",
# "__tls", # "__tls",
@ -192,23 +192,23 @@ deny = [
# "rustls-tls-webpki-roots", # "rustls-tls-webpki-roots",
# "tokio-rustls", # "tokio-rustls",
# "webpki-roots", # "webpki-roots",
#] # ]
# If true, the allowed features must exactly match the enabled feature set. If # If true, the allowed features must exactly match the enabled feature set. If
# this is set there is no point setting `deny` # this is set there is no point setting `deny`
#exact = true # exact = true
# Certain crates/versions that will be skipped when doing duplicate detection. # Certain crates/versions that will be skipped when doing duplicate detection.
skip = [ skip = [
#"ansi_term@0.11.0", # "ansi_term@0.11.0",
#{ crate = "ansi_term@0.11.0", reason = "you can specify a reason why it can't be updated/removed" }, # { crate = "ansi_term@0.11.0", reason = "you can specify a reason why it can't be updated/removed" },
] ]
# Similarly to `skip` allows you to skip certain crates during duplicate # Similarly to `skip` allows you to skip certain crates during duplicate
# detection. Unlike skip, it also includes the entire tree of transitive # detection. Unlike skip, it also includes the entire tree of transitive
# dependencies starting at the specified crate, up to a certain depth, which is # dependencies starting at the specified crate, up to a certain depth, which is
# by default infinite. # by default infinite.
skip-tree = [ skip-tree = [
#"ansi_term@0.11.0", # will be skipped along with _all_ of its direct and transitive dependencies # "ansi_term@0.11.0", # will be skipped along with _all_ of its direct and transitive dependencies
#{ crate = "ansi_term@0.11.0", depth = 20 }, # { crate = "ansi_term@0.11.0", depth = 20 },
] ]
# This section is considered when running `cargo deny check sources`. # This section is considered when running `cargo deny check sources`.