diff --git a/.helix/languages.toml b/.helix/languages.toml new file mode 100644 index 0000000..0d90ee8 --- /dev/null +++ b/.helix/languages.toml @@ -0,0 +1,18 @@ +[[language]] +name = "nix" +language-servers = ["nixd", "typos-lsp"] + +[[language]] +name = "markdown" +language-servers = ["marksman", "markdown-oxide", "typos-lsp"] + +[[language]] +name = "toml" +language-servers = ["taplo", "typos-lsp"] + +[[language]] +name = "git-ignore" +language-servers = ["typos-lsp"] + +[language-server.typos-lsp] +command = "typos-lsp" diff --git a/.typos.toml b/.typos.toml new file mode 100644 index 0000000..e296d3d --- /dev/null +++ b/.typos.toml @@ -0,0 +1,21 @@ +[files] +ignore-global = true +ignore-parent = true +ignore-hidden = false +ignore-files = true +ignore-vcs = true +extend-exclude = ["secrets/", ".git/", "public-key.txt"] + +[default] +check-filename = true +check-file = true +unicode = true +extend-ignore-re = [ + # Line ignore with trailling `(#|//) spellchecker: disable-line` + "(?Rm)^.*(#|//)\\s*spellchecker: disable-line$", + # Line block with `# spellchecker: ` + "(?s)(#|//)\\s*spellchecker: off.*?\\n\\s*(#|//)\\s*spellchecker: on", +] +extend-ignore-identifiers-re = ["als", "Paket", "ConfiguratioN", "StructurE"] + +[default.extend-identifiers] diff --git a/codebook.toml b/codebook.toml deleted file mode 100644 index 8a78c62..0000000 --- a/codebook.toml +++ /dev/null @@ -1,18 +0,0 @@ -words = [ - "akun", - "configuratio", - "fuzzel", - "gdm", - "ghostty", - "kde", - "niri", - "nixo", - "nixos", - "nixpkgs", - "ovelrays", - "pkgs", - "sddm", - "specialisation", - "structur", - "tytonidae", -] diff --git a/flake.nix b/flake.nix index 436b222..a663bd3 100644 --- a/flake.nix +++ b/flake.nix @@ -180,6 +180,7 @@ packages = with pkgs; [ nixd typos + typos-lsp just nvfetcher ]; diff --git a/home/modules/programs/wluma.nix b/home/modules/programs/wluma.nix index 9c3d06a..061d3e7 100644 --- a/home/modules/programs/wluma.nix +++ b/home/modules/programs/wluma.nix @@ -21,7 +21,7 @@ in { example = pkgs.wluam; default = pkgs.wluma; description = '' - pakcage of wluma + package of wluma ''; }; }; diff --git a/nixos/modules/programs/juicity/template.nix b/nixos/modules/programs/juicity/template.nix index 50ae4fe..7117358 100644 --- a/nixos/modules/programs/juicity/template.nix +++ b/nixos/modules/programs/juicity/template.nix @@ -50,7 +50,7 @@ in { description = '' A file which JSON configurations for juicity client. See the {option}`settings` option for more information. - Note: this file will override {options}`settings` option, which is recommanded. + Note: this file will override {options}`settings` option, which is recommended. ''; }; allowedOpenFirewallPorts = lib.mkOption { @@ -95,7 +95,7 @@ in { description = '' A file which JSON configurations for juicity server. See the {option}`settings` option for more information. - Note: this file will override {options}`settings` option, which is recommanded. + Note: this file will override {options}`settings` option, which is recommended. ''; }; allowedOpenFirewallPorts = lib.mkOption { diff --git a/pkgs/default.nix b/pkgs/default.nix index 0c66cbb..c249653 100644 --- a/pkgs/default.nix +++ b/pkgs/default.nix @@ -4,7 +4,7 @@ ... }: let srcs = pkgs.callPackage ./_sources/generated.nix {}; - callPackage = fn: args: pkgs.lib.callPackageWith (pkgs // {inherit inputs srcs callPackage;}) fn args; + callPackage = pkgs.lib.callPackageWith (pkgs // {inherit inputs srcs callPackage;}); in { pinentry-selector = callPackage ./pinentry-selector.nix {}; diff --git a/pkgs/helix/default.nix b/pkgs/helix/default.nix index 8e85c52..5af9619 100644 --- a/pkgs/helix/default.nix +++ b/pkgs/helix/default.nix @@ -8,6 +8,7 @@ runtime = callPackage ./runtime.nix {}; runtimeInputs = ( with pkgs; [ + nixfmt-rfc-style idris2Packages.idris2Lsp lua-language-server bash-language-server diff --git a/pkgs/helix/runtime.nix b/pkgs/helix/runtime.nix index 70857b3..ce0e5ec 100644 --- a/pkgs/helix/runtime.nix +++ b/pkgs/helix/runtime.nix @@ -11,7 +11,7 @@ src = grammar.src; # sourceRoot = "source"; - dontConfigue = true; + dontConfigure = true; FLAGS = [ "-Isrc" diff --git a/templates/cxxWithXmake/flake.nix b/templates/cxxWithXmake/flake.nix index 7ccaf94..f7c2478 100644 --- a/templates/cxxWithXmake/flake.nix +++ b/templates/cxxWithXmake/flake.nix @@ -18,14 +18,38 @@ }; in { formatter = pkgs.alejandra; + checks = { + inherit (self.packages.${system}) default; + }; devShells.default = pkgs.mkShell { + inputsFrom = [] ++ (builtins.attrValues self.checks.${system}); packages = with pkgs; [ clang-tools - - gcc - xmake ]; }; + packages = rec { + cxx-demo = pkgs.stdenv.mkDerivation { + pname = "cxx-demo"; + version = "unstable"; + src = ./.; + strictDeps = true; + nativeBuildInputs = with pkgs; [ + xmake + gnumake + ]; + preConfigure = '' + xmake config -m release + xmake project -k xmakefile + ''; + env = { + INSTALLDIR = "${placeholder "out"}"; + NIX_DEBUG = 1; + V = 1; + D = 1; + }; + }; + default = cxx-demo; + }; }); nixConfig = { keepOutputs = true; diff --git a/templates/rust/.cargo/audit.toml b/templates/rust/.cargo/audit.toml new file mode 100644 index 0000000..fd7bf33 --- /dev/null +++ b/templates/rust/.cargo/audit.toml @@ -0,0 +1,25 @@ +[advisories] +ignore = [] # advisory IDs to ignore e.g. ["RUSTSEC-2019-0001", ...] +informational_warnings = [ + "unmaintained", +] # warn for categories of informational advisories +severity_threshold = "low" # CVSS severity ("none", "low", "medium", "high", "critical") + +[database] +url = "https://github.com/RustSec/advisory-db.git" +fetch = true +stale = false + +[output] +deny = ["unmaintained"] # exit on error if unmaintained dependencies are found +format = "terminal" # "terminal" (human readable report) or "json" +quiet = false # Only print information on error +show_tree = true + +[target] +arch = ["x86_64"] +os = ["linux", "windows"] + +[yanked] +enabled = true +update_index = true diff --git a/templates/rust/.envrc b/templates/rust/.envrc index 7f9c986..5e5ab08 100644 --- a/templates/rust/.envrc +++ b/templates/rust/.envrc @@ -1,3 +1,3 @@ -watch_file rust-toolchain.toml +watch_file rust-toolchain.toml nix/*.nix use flake diff --git a/templates/rust/.rustfmt.toml b/templates/rust/.rustfmt.toml new file mode 100644 index 0000000..7f8e98f --- /dev/null +++ b/templates/rust/.rustfmt.toml @@ -0,0 +1,17 @@ +edition = "2024" +merge_derives = true +newline_style = "Unix" +reorder_imports = true +reorder_modules = true +use_field_init_shorthand = true +use_try_shorthand = true +# unstable_features = true +# format_code_in_doc_comments = true +# format_macro_bodies = true +# format_strings = true +# float_literal_trailing_zero = "IfNoPostfix" +# imports_granularity = "Crate" +# overflow_delimited_expr = true +# reorder_impl_items = true +# group_imports = "StdExternalCrate" +# wrap_comments = true diff --git a/templates/rust/flake.lock b/templates/rust/flake.lock index 25d9947..2cee095 100644 --- a/templates/rust/flake.lock +++ b/templates/rust/flake.lock @@ -3,11 +3,11 @@ "advisory-db": { "flake": false, "locked": { - "lastModified": 1746689539, - "narHash": "sha256-rVUs0CjpuO7FKVHecsuMaYiUr8iKscsgeo/b2XlnPmQ=", + "lastModified": 1747937073, + "narHash": "sha256-52H8P6jAHEwRvg7rXr4Z7h1KHZivO8T1Z9tN6R0SWJg=", "owner": "rustsec", "repo": "advisory-db", - "rev": "796d034fbcb1c5bc83c0d0912dc31eb4e34458bf", + "rev": "bccf313a98c034573ac4170e6271749113343d97", "type": "github" }, "original": { @@ -18,11 +18,11 @@ }, "crane": { "locked": { - "lastModified": 1746291859, - "narHash": "sha256-DdWJLA+D5tcmrRSg5Y7tp/qWaD05ATI4Z7h22gd1h7Q=", + "lastModified": 1748047550, + "narHash": "sha256-t0qLLqb4C1rdtiY8IFRH5KIapTY/n3Lqt57AmxEv9mk=", "owner": "ipetkov", "repo": "crane", - "rev": "dfd9a8dfd09db9aad544c4d3b6c47b12562544a5", + "rev": "b718a78696060df6280196a6f992d04c87a16aef", "type": "github" }, "original": { @@ -51,11 +51,11 @@ }, "nixpkgs": { "locked": { - "lastModified": 1746300365, - "narHash": "sha256-thYTdWqCRipwPRxWiTiH1vusLuAy0okjOyzRx4hLWh4=", + "lastModified": 1747958103, + "narHash": "sha256-qmmFCrfBwSHoWw7cVK4Aj+fns+c54EBP8cGqp/yK410=", "owner": "NixOS", "repo": "nixpkgs", - "rev": "f21e4546e3ede7ae34d12a84602a22246b31f7e0", + "rev": "fe51d34885f7b5e3e7b59572796e1bcb427eccb1", "type": "github" }, "original": { @@ -81,11 +81,11 @@ ] }, "locked": { - "lastModified": 1746326315, - "narHash": "sha256-IDqSls/r6yBfdOBRSMQ/noTUoigmsKnTQ7TqpsBtN4Y=", + "lastModified": 1748140821, + "narHash": "sha256-GZcjWLQtDifSYMd1ueLDmuVTcQQdD5mONIBTqABooOk=", "owner": "oxalica", "repo": "rust-overlay", - "rev": "dd280c436961ec5adccf0135efe5b66a23d84497", + "rev": "476b2ba7dc99ddbf70b1f45357dbbdbdbdfb4422", "type": "github" }, "original": { diff --git a/templates/rust/flake.nix b/templates/rust/flake.nix index 579eab8..1e02842 100644 --- a/templates/rust/flake.nix +++ b/templates/rust/flake.nix @@ -31,12 +31,17 @@ inherit (pkgs) lib; pkgs = import nixpkgs { inherit system; - overlays = [(import rust-overlay)]; + overlays = [ + (import rust-overlay) + (final: prev: { + lib = prev.lib // (import ./nix/lib.nix prev.lib); + }) + ]; }; rustToolchain = pkgs.rust-bin.fromRustupToolchainFile ./rust-toolchain.toml; craneLib = (crane.mkLib pkgs).overrideToolchain rustToolchain; srcFilters = path: type: - builtins.any (suffix: lib.hasSuffix suffix path) [ + builtins.any (lib.flip lib.hasSuffix path) [ ".sql" ".diff" ".md" @@ -50,26 +55,24 @@ }; basicArgs = { inherit src; - pname = "rust-demo"; strictDeps = true; }; - cargoArtifacts = craneLib.buildDepsOnly basicArgs; + nativeBuildInputs = []; + buildInputs = []; + genInputs = lib.genInputsWith pkgs; commonArgs = basicArgs // { - inherit cargoArtifacts; - nativeBuildInputs = with pkgs; []; - buildInputs = - (with pkgs; []) - ++ lib.optional pkgs.stdenv.buildPlatform.isDarwin (with pkgs; [ - darwin.apple_sdk.frameworks.Security - ]); - env = {}; + cargoArtifacts = self.packages.${system}.cargo-artifacts; + buildInputs = genInputs buildInputs; + nativeBuildInputs = genInputs nativeBuildInputs; }; in { formatter = pkgs.alejandra; checks = { - inherit (self.packages.${system}) default; + package = self.packages.${system}.default.overrideAttrs { + doCheck = true; + }; clippy = craneLib.cargoClippy (commonArgs // { cargoClippyExtraArgs = "--all-targets -- --deny warnings"; @@ -84,31 +87,30 @@ // { partitions = 1; partitionType = "count"; - nativeBuildInputs = []; cargoNextestExtraArgs = "--no-tests pass"; env = { CARGO_PROFILE = "dev"; }; }); }; - packages = rec { - rust-demo = craneLib.buildPackage (commonArgs - // { - inherit - (craneLib.crateNameFromCargoToml { - cargoToml = "${toString src}/Cargo.toml"; - }) - ; - doCheck = false; - nativeBuildInputs = []; - buildInputs = []; - }); + packages = let + callPackage = lib.callPackageWith (pkgs // {inherit craneLib callPackage;}); + packageArgs = { + inherit lib basicArgs buildInputs nativeBuildInputs; + }; + importWithArgs = with lib; flip import packageArgs; + in rec { + cargo-artifacts = callPackage (importWithArgs ./nix/cargo-artifacts.nix) {}; + rust-demo = callPackage (importWithArgs ./nix/package.nix) { + cargoArtifacts = cargo-artifacts; + }; default = rust-demo; }; apps.default = flake-utils.lib.mkApp { drv = self.packages."${system}".default; }; devShells.default = craneLib.devShell { + checks = self.checks.${system}; packages = with pkgs; [ rust-analyzer cargo-audit diff --git a/templates/rust/nix/cargo-artifacts.nix b/templates/rust/nix/cargo-artifacts.nix new file mode 100644 index 0000000..df41cad --- /dev/null +++ b/templates/rust/nix/cargo-artifacts.nix @@ -0,0 +1,20 @@ +{ + lib, + basicArgs, + buildInputs, + nativeBuildInputs, +}: let + f = { + craneLib, + lib, + ... + } @ args: let + genInputs = lib.genInputsWith args; + in + craneLib.buildDepsOnly (basicArgs + // { + buildInputs = genInputs buildInputs; + nativeBuildInputs = genInputs nativeBuildInputs; + }); +in + with lib; setFunctionArgs f ((functionArgs f) // (genFunctionArgs (buildInputs ++ nativeBuildInputs))) diff --git a/templates/rust/nix/lib.nix b/templates/rust/nix/lib.nix new file mode 100644 index 0000000..f965403 --- /dev/null +++ b/templates/rust/nix/lib.nix @@ -0,0 +1,13 @@ +{ + flip, + pipe, + splitString, + head, + listToAttrs, + nameValuePair, + getAttrFromPath, + ... +}: { + genFunctionArgs = flip pipe [(map (flip pipe [(splitString ".") head (flip nameValuePair false)])) listToAttrs]; + genInputsWith = pkgs: map (flip pipe [(splitString ".") (flip getAttrFromPath pkgs)]); +} diff --git a/templates/rust/nix/package.nix b/templates/rust/nix/package.nix new file mode 100644 index 0000000..744cad2 --- /dev/null +++ b/templates/rust/nix/package.nix @@ -0,0 +1,30 @@ +{ + lib, + basicArgs, + buildInputs, + nativeBuildInputs, +}: let + f = { + craneLib, + lib, + cargoArtifacts, + ... + } @ args: let + genInputs = lib.genInputsWith args; + in + craneLib.buildPackage (basicArgs + // { + inherit + (craneLib.crateNameFromCargoToml { + cargoToml = "${toString basicArgs.src}/Cargo.toml"; + }) + pname + version + ; + inherit cargoArtifacts; + buildInputs = genInputs buildInputs; + nativeBuildInputs = genInputs nativeBuildInputs; + doCheck = false; + }); +in + with lib; setFunctionArgs f ((functionArgs f) // (genFunctionArgs (buildInputs ++ nativeBuildInputs))) diff --git a/templates/rust/rust-toolchain.toml b/templates/rust/rust-toolchain.toml index 02cb8fc..698a98c 100644 --- a/templates/rust/rust-toolchain.toml +++ b/templates/rust/rust-toolchain.toml @@ -1,3 +1,4 @@ [toolchain] channel = "stable" profile = "default" +components = ["rust-src"]