From 03636438a01b27ee540decbea28214eecdab6a3c Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Fri, 23 May 2025 22:28:12 +0800 Subject: [PATCH 1/9] add package for cxx template --- templates/cxxWithXmake/flake.nix | 26 +++++++++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/templates/cxxWithXmake/flake.nix b/templates/cxxWithXmake/flake.nix index 7ccaf94..4b6eda2 100644 --- a/templates/cxxWithXmake/flake.nix +++ b/templates/cxxWithXmake/flake.nix @@ -18,14 +18,34 @@ }; 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 project -k xmakefile + ''; + env = { + INSTALLDIR = "${placeholder "out"}"; + }; + }; + default = cxx-demo; + }; }); nixConfig = { keepOutputs = true; From 39e4112265b235b2a4bd70b0fc178b627ee4ad51 Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sat, 24 May 2025 08:21:51 +0800 Subject: [PATCH 2/9] set verbose mode in xmake template --- templates/cxxWithXmake/flake.nix | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/templates/cxxWithXmake/flake.nix b/templates/cxxWithXmake/flake.nix index 4b6eda2..f7c2478 100644 --- a/templates/cxxWithXmake/flake.nix +++ b/templates/cxxWithXmake/flake.nix @@ -38,10 +38,14 @@ gnumake ]; preConfigure = '' + xmake config -m release xmake project -k xmakefile ''; env = { INSTALLDIR = "${placeholder "out"}"; + NIX_DEBUG = 1; + V = 1; + D = 1; }; }; default = cxx-demo; From 8d9f566ce6b2b13544552f26387dfbe34114d0c6 Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sat, 24 May 2025 08:21:51 +0800 Subject: [PATCH 3/9] add nixfmt in helix package set --- pkgs/helix/default.nix | 1 + 1 file changed, 1 insertion(+) 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 From f3de1c79e45c88545ead767a99dd92c33323039a Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sun, 25 May 2025 14:04:21 +0800 Subject: [PATCH 4/9] use typos to check typos --- .helix/languages.toml | 18 ++++++++++++++++++ .typos.toml | 21 +++++++++++++++++++++ codebook.toml | 18 ------------------ flake.nix | 1 + home/modules/programs/wluma.nix | 2 +- nixos/modules/programs/juicity/template.nix | 4 ++-- pkgs/helix/runtime.nix | 2 +- 7 files changed, 44 insertions(+), 22 deletions(-) create mode 100644 .helix/languages.toml create mode 100644 .typos.toml delete mode 100644 codebook.toml 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/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" From ce9a8cab1d98759e5c927cd72a5db670cddb96e3 Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sun, 25 May 2025 15:28:26 +0800 Subject: [PATCH 5/9] add rustfmt config for rust template --- templates/rust/.rustfmt.toml | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 templates/rust/.rustfmt.toml 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 From 69c6e41eff57e791dbe510885a1f8b7fc3395e48 Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sun, 25 May 2025 15:35:16 +0800 Subject: [PATCH 6/9] add cargo audit config for rust template --- templates/rust/.cargo/audit.toml | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 templates/rust/.cargo/audit.toml 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 From dc5dfddf749d0f6885eb67118dc57604a7c43031 Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sun, 25 May 2025 15:38:17 +0800 Subject: [PATCH 7/9] improve rust template --- templates/rust/flake.nix | 31 ++++++++++++++++-------------- templates/rust/rust-toolchain.toml | 1 + 2 files changed, 18 insertions(+), 14 deletions(-) diff --git a/templates/rust/flake.nix b/templates/rust/flake.nix index 579eab8..e42f6ad 100644 --- a/templates/rust/flake.nix +++ b/templates/rust/flake.nix @@ -50,26 +50,29 @@ }; basicArgs = { inherit src; - pname = "rust-demo"; strictDeps = true; }; - cargoArtifacts = craneLib.buildDepsOnly basicArgs; + nativeBuildInputs = with pkgs; []; + buildInputs = + (with pkgs; []) + ++ lib.optional pkgs.stdenv.buildPlatform.isDarwin (with pkgs; [ + darwin.apple_sdk.frameworks.Security + ]); + cargoArtifacts = craneLib.buildDepsOnly (basicArgs + // { + inherit buildInputs nativeBuildInputs; + }); commonArgs = basicArgs // { - inherit cargoArtifacts; - nativeBuildInputs = with pkgs; []; - buildInputs = - (with pkgs; []) - ++ lib.optional pkgs.stdenv.buildPlatform.isDarwin (with pkgs; [ - darwin.apple_sdk.frameworks.Security - ]); - env = {}; + inherit cargoArtifacts buildInputs 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,7 +87,6 @@ // { partitions = 1; partitionType = "count"; - nativeBuildInputs = []; cargoNextestExtraArgs = "--no-tests pass"; env = { CARGO_PROFILE = "dev"; @@ -98,10 +100,10 @@ (craneLib.crateNameFromCargoToml { cargoToml = "${toString src}/Cargo.toml"; }) + pname + version ; doCheck = false; - nativeBuildInputs = []; - buildInputs = []; }); default = rust-demo; }; @@ -109,6 +111,7 @@ 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/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"] From 18bfe1ce9a8030abdbc16ad94cb268d8018ce712 Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sun, 25 May 2025 16:37:32 +0800 Subject: [PATCH 8/9] improve rust template for ensuring package overriable --- templates/rust/.envrc | 2 +- templates/rust/flake.lock | 24 ++++++------- templates/rust/flake.nix | 49 +++++++++++++------------- templates/rust/nix/cargo-artifacts.nix | 20 +++++++++++ templates/rust/nix/lib.nix | 13 +++++++ templates/rust/nix/package.nix | 30 ++++++++++++++++ 6 files changed, 100 insertions(+), 38 deletions(-) create mode 100644 templates/rust/nix/cargo-artifacts.nix create mode 100644 templates/rust/nix/lib.nix create mode 100644 templates/rust/nix/package.nix 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/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 e42f6ad..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" @@ -52,20 +57,15 @@ inherit src; strictDeps = true; }; - nativeBuildInputs = with pkgs; []; - buildInputs = - (with pkgs; []) - ++ lib.optional pkgs.stdenv.buildPlatform.isDarwin (with pkgs; [ - darwin.apple_sdk.frameworks.Security - ]); - cargoArtifacts = craneLib.buildDepsOnly (basicArgs - // { - inherit buildInputs nativeBuildInputs; - }); + nativeBuildInputs = []; + buildInputs = []; + genInputs = lib.genInputsWith pkgs; commonArgs = basicArgs // { - inherit cargoArtifacts buildInputs nativeBuildInputs; + cargoArtifacts = self.packages.${system}.cargo-artifacts; + buildInputs = genInputs buildInputs; + nativeBuildInputs = genInputs nativeBuildInputs; }; in { formatter = pkgs.alejandra; @@ -93,18 +93,17 @@ }; }); }; - packages = rec { - rust-demo = craneLib.buildPackage (commonArgs - // { - inherit - (craneLib.crateNameFromCargoToml { - cargoToml = "${toString src}/Cargo.toml"; - }) - pname - version - ; - doCheck = false; - }); + 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 { 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))) From f1e6dbb66fe7db60e01926a0ab068b7cd52c2c17 Mon Sep 17 00:00:00 2001 From: ulic-youthlic Date: Sun, 25 May 2025 19:35:16 +0800 Subject: [PATCH 9/9] remove some unnecessary arg for function in pkgs --- pkgs/default.nix | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 {};