From 6857f9e01caf0def1bd61940d0ff0d0e9a7db413 Mon Sep 17 00:00:00 2001 From: Sridhar Ratnakumar Date: Wed, 2 Aug 2023 15:51:37 -0400 Subject: [PATCH] use upstream flake-module --- flake.lock | 17 +++++++ flake.nix | 5 +- nix/flake-module.nix | 112 ------------------------------------------- 3 files changed, 21 insertions(+), 113 deletions(-) delete mode 100644 nix/flake-module.nix diff --git a/flake.lock b/flake.lock index 577200bf..29cd911c 100644 --- a/flake.lock +++ b/flake.lock @@ -93,6 +93,22 @@ "type": "github" } }, + "leptos-fullstack": { + "flake": false, + "locked": { + "lastModified": 1690995177, + "narHash": "sha256-5BZlcW3llJo3KZsSY/HFRIg43a/bylVHln9c4my2zNY=", + "owner": "srid", + "repo": "leptos-fullstack", + "rev": "d76465079a20775d020c1215f5151ac386bbb0e3", + "type": "github" + }, + "original": { + "owner": "srid", + "repo": "leptos-fullstack", + "type": "github" + } + }, "nixpkgs": { "locked": { "lastModified": 1690031011, @@ -163,6 +179,7 @@ "inputs": { "crane": "crane", "flake-parts": "flake-parts", + "leptos-fullstack": "leptos-fullstack", "nixpkgs": "nixpkgs", "rust-overlay": "rust-overlay_2", "systems": "systems_3", diff --git a/flake.nix b/flake.nix index 2cf140ba..81f88273 100644 --- a/flake.nix +++ b/flake.nix @@ -8,6 +8,9 @@ crane.url = "github:ipetkov/crane"; crane.inputs.nixpkgs.follows = "nixpkgs"; treefmt-nix.url = "github:numtide/treefmt-nix"; + + leptos-fullstack.url = "github:srid/leptos-fullstack"; + leptos-fullstack.flake = false; }; outputs = inputs: @@ -15,7 +18,7 @@ systems = import inputs.systems; imports = [ inputs.treefmt-nix.flakeModule - ./nix/flake-module.nix + (inputs.leptos-fullstack + /nix/flake-module.nix) ]; perSystem = { config, self', pkgs, lib, system, ... }: { _module.args.pkgs = import inputs.nixpkgs { diff --git a/nix/flake-module.nix b/nix/flake-module.nix deleted file mode 100644 index b4eba767..00000000 --- a/nix/flake-module.nix +++ /dev/null @@ -1,112 +0,0 @@ -{ self, lib, inputs, flake-parts-lib, ... }: - -let - inherit (flake-parts-lib) - mkPerSystemOption; - inherit (lib) - mkOption - types; -in -{ - options = { - perSystem = mkPerSystemOption - ({ config, self', inputs', pkgs, system, ... }: { - config = - let - cargoToml = builtins.fromTOML (builtins.readFile (self + /Cargo.toml)); - inherit (cargoToml.package) name version; - - rustToolchain = (pkgs.rust-bin.fromRustupToolchainFile (self + /rust-toolchain.toml)).override { - extensions = [ - "rust-src" - "rust-analyzer" - ]; - }; - craneLib = (inputs.crane.mkLib pkgs).overrideToolchain rustToolchain; - - # When filtering sources, we want to allow assets other than .rs files - src = lib.cleanSourceWith { - src = self; # The original, unfiltered source - filter = path: type: - (lib.hasSuffix "\.html" path) || - (lib.hasSuffix "tailwind.config.js" path) || - # Example of a folder for images, icons, etc - (lib.hasInfix "/assets/" path) || - (lib.hasInfix "/css/" path) || - # Default filter from crane (allow .rs files) - (craneLib.filterCargoSources path type) - ; - }; - - craneBuild = rec { - args = { - inherit src; - pname = name; - version = version; - buildInputs = [ - pkgs.cargo-leptos - pkgs.binaryen # Provides wasm-opt - tailwindcss - ]; - }; - cargoArtifacts = craneLib.buildDepsOnly args; - package = craneLib.buildPackage (args // { - inherit cargoArtifacts; - buildPhaseCargoCommand = "cargo leptos build --release -vvv"; - doCheck = false; # FIXME: https://github.com/benwis/benwis_leptos/issues/2 - nativeBuildInputs = [ - pkgs.makeWrapper - ]; - installPhaseCommand = '' - mkdir -p $out/bin - cp target/server/release/${name} $out/bin/ - cp -r target/site $out/bin/ - wrapProgram $out/bin/${name} \ - --set LEPTOS_SITE_ROOT $out/bin/site - ''; - }); - }; - - rustDevShell = pkgs.mkShell { - shellHook = '' - # For rust-analyzer 'hover' tooltips to work. - export RUST_SRC_PATH="${rustToolchain}/lib/rustlib/src/rust/library"; - ''; - buildInputs = [ - pkgs.libiconv - ]; - nativeBuildInputs = [ - rustToolchain - ]; - }; - - tailwindcss = pkgs.nodePackages.tailwindcss.overrideAttrs - (oa: { - plugins = [ - pkgs.nodePackages."@tailwindcss/aspect-ratio" - pkgs.nodePackages."@tailwindcss/forms" - pkgs.nodePackages."@tailwindcss/language-server" - pkgs.nodePackages."@tailwindcss/line-clamp" - pkgs.nodePackages."@tailwindcss/typography" - ]; - }); - in - { - # Rust package - packages.${name} = craneBuild.package; - - # Rust dev environment - devShells.${name} = pkgs.mkShell { - inputsFrom = [ - rustDevShell - ]; - nativeBuildInputs = with pkgs; [ - tailwindcss - cargo-leptos - binaryen # Provides wasm-opt - ]; - }; - }; - }); - }; -}