From 76c0b03e4959d7ba8ea5b54c71de2229b41b785f Mon Sep 17 00:00:00 2001 From: mat ess Date: Tue, 3 Jan 2023 19:37:19 -0500 Subject: [PATCH] Update templates --- templates/default.nix | 6 ++++-- templates/rust/flake.nix | 28 ++++++++++++++++------------ 2 files changed, 20 insertions(+), 14 deletions(-) diff --git a/templates/default.nix b/templates/default.nix index da44b64..b3ffe82 100644 --- a/templates/default.nix +++ b/templates/default.nix @@ -1,4 +1,7 @@ -{ +let + mkTemplates = builtins.mapAttrs (name: attrs: attrs // { path = ./. + "/${name}"; }); +in +mkTemplates { rust = { description = "A rust flake template based on flake.parts"; welcomeText = '' @@ -6,6 +9,5 @@ run `direnv allow` and `cargo init` to start a new project ''; - path = ./templates/rust; }; } diff --git a/templates/rust/flake.nix b/templates/rust/flake.nix index 6b4127e..f91ac92 100644 --- a/templates/rust/flake.nix +++ b/templates/rust/flake.nix @@ -10,8 +10,8 @@ pre-commit.inputs.nixpkgs.follows = "nixpkgs"; }; - outputs = { self, flake-parts, crane, pre-commit, ... }: - flake-parts.lib.mkFlake { inherit self; } { + outputs = inputs@{ self, flake-parts, crane, pre-commit, ... }: + flake-parts.lib.mkFlake { inherit inputs; } { imports = [ pre-commit.flakeModule ]; systems = [ "aarch64-darwin" @@ -24,7 +24,7 @@ crane-lib = crane.lib.${system}; package = crane-lib.buildPackage { src = crane-lib.cleanCargoSource ./.; - nativeBuildInputs = [ pkgs.libiconv ]; + nativeBuildInputs = pkgs.lib.optionals pkgs.stdenv.isDarwin [ pkgs.libiconv ]; }; in { @@ -43,15 +43,19 @@ inputsFrom = builtins.attrValues self.checks; RUST_SRC_PATH = "${pkgs.rust.packages.stable.rustPlatform.rustLibSrc}"; - nativeBuildInputs = with pkgs; [ - cargo - rustc - ]; - buildInputs = with pkgs; [ - rust-analyzer - rustfmt - clippy - ]; + nativeBuildInputs = builtins.attrValues { + inherit (pkgs) + cargo + rustc + ; + }; + buildInputs = builtins.attrValues { + inherit (pkgs) + rust-analyzer + rustfmt + clippy + ; + }; }; }; };