diff --git a/flake.nix b/flake.nix index 1a2b121..22fc3da 100644 --- a/flake.nix +++ b/flake.nix @@ -4,9 +4,7 @@ rust-overlay = { url = "github:oxalica/rust-overlay"; - inputs = { - nixpkgs.follows = "nixpkgs"; - }; + inputs = { nixpkgs.follows = "nixpkgs"; }; }; nixpkgs.follows = "holochain/nixpkgs"; @@ -19,238 +17,240 @@ }; nixConfig = { - extra-substituters = [ - "https://holochain-open-dev.cachix.org" - ]; - extra-trusted-public-keys = [ - "holochain-open-dev.cachix.org-1:3Tr+9in6uo44Ga7qiuRIfOTFXog+2+YbyhwI/Z6Cp4U=" - ]; - }; - - outputs = inputs @ { ... }: - inputs.holochain.inputs.flake-parts.lib.mkFlake - { - inherit inputs; - } - { - flake = { - lib = rec { - filterByHolochainPackageType = holochainPackageType: packages: inputs.nixpkgs.lib.filterAttrs (key: value: (builtins.hasAttr "meta" value) && (builtins.hasAttr "holochainPackageType" value.meta) && value.meta.holochainPackageType == holochainPackageType) packages; - - filterZomes = filterByHolochainPackageType "zome"; - filterDnas = filterByHolochainPackageType "dna"; - filterHapps = filterByHolochainPackageType "happ"; - filterNpmPackages = filterByHolochainPackageType "npm"; + extra-substituters = [ "https://holochain-open-dev.cachix.org" ]; + extra-trusted-public-keys = [ + "holochain-open-dev.cachix.org-1:3Tr+9in6uo44Ga7qiuRIfOTFXog+2+YbyhwI/Z6Cp4U=" + ]; + }; - rustZome = { crateCargoToml, holochain, workspacePath, excludedCrates ? [] }: - let - deterministicCraneLib = let - system = "aarch64-darwin"; - pkgs = import inputs.nixpkgs { - inherit system; - overlays = [ (import inputs.rust-overlay) ]; - }; + outputs = inputs@{ ... }: + inputs.holochain.inputs.flake-parts.lib.mkFlake { inherit inputs; } { + flake = { + lib = rec { + filterByHolochainPackageType = holochainPackageType: packages: + inputs.nixpkgs.lib.filterAttrs (key: value: + (builtins.hasAttr "meta" value) + && (builtins.hasAttr "holochainPackageType" value.meta) + && value.meta.holochainPackageType == holochainPackageType) + packages; - rustToolchain = pkgs.rust-bin.stable."1.75.0".minimal.override { - # Set the build targets supported by the toolchain, - # wasm32-unknown-unknown is required for trunk. - targets = [ "wasm32-unknown-unknown" ]; - }; - in - inputs.crane.lib.${system}.overrideToolchain rustToolchain; + filterZomes = filterByHolochainPackageType "zome"; + filterDnas = filterByHolochainPackageType "dna"; + filterHapps = filterByHolochainPackageType "happ"; + filterNpmPackages = filterByHolochainPackageType "npm"; - system = holochain.devShells.holonix.system; - pkgs = import inputs.nixpkgs { - inherit system; - overlays = [ (import inputs.rust-overlay) ]; - }; + rustZome = + { crateCargoToml, holochain, workspacePath, excludedCrates ? [ ] }: + let + deterministicCraneLib = let + system = "x86_64-linux"; + pkgs = import inputs.nixpkgs { + inherit system; + overlays = [ (import inputs.rust-overlay) ]; + }; - rustToolchain = pkgs.rust-bin.stable."1.75.0".minimal.override { - # Set the build targets supported by the toolchain, - # wasm32-unknown-unknown is required for trunk. - targets = [ "wasm32-unknown-unknown" ]; - }; - craneLib = inputs.crane.lib.${system}.overrideToolchain rustToolchain; + rustToolchain = pkgs.rust-bin.stable."1.75.0".minimal.override { + # Set the build targets supported by the toolchain, + # wasm32-unknown-unknown is required for trunk. + targets = [ "wasm32-unknown-unknown" ]; + }; + in inputs.crane.lib.${system}.overrideToolchain rustToolchain; - in - pkgs.callPackage ./nix/zome.nix { - inherit deterministicCraneLib craneLib crateCargoToml excludedCrates workspacePath; - }; - sweettest = { holochain, dna, workspacePath, crateCargoToml }: - let - system = holochain.devShells.holonix.system; - pkgs = import inputs.nixpkgs { - inherit system; - overlays = [ (import inputs.rust-overlay) ]; - }; - rustToolchain = pkgs.rust-bin.stable."1.75.0".minimal.override { - # Set the build targets supported by the toolchain, - # wasm32-unknown-unknown is required for trunk. - targets = [ "wasm32-unknown-unknown" ]; - }; - craneLib = inputs.crane.lib.${system}.overrideToolchain rustToolchain; - in pkgs.callPackage ./nix/sweettest.nix { - inherit holochain dna craneLib workspacePath crateCargoToml; - }; - dna = { holochain, dnaManifest, zomes }: - let - system = holochain.devShells.holonix.system; - pkgs = import inputs.nixpkgs { - inherit system; - overlays = [ (import inputs.rust-overlay) ]; - }; - in - pkgs.callPackage ./nix/dna.nix { - inherit zomes holochain dnaManifest; - }; - happ = { holochain, happManifest, dnas }: - let - system = holochain.devShells.holonix.system; - pkgs = import inputs.nixpkgs { - inherit system; - overlays = [ (import inputs.rust-overlay) ]; - }; - in - pkgs.callPackage ./nix/happ.nix { - inherit dnas holochain happManifest; - }; - }; - }; + system = holochain.devShells.holonix.system; + pkgs = import inputs.nixpkgs { + inherit system; + overlays = [ (import inputs.rust-overlay) ]; + }; - systems = builtins.attrNames inputs.holochain.devShells; - perSystem = - { inputs' - , config - , pkgs - , system - , lib - , ... - }: rec { + rustToolchain = pkgs.rust-bin.stable."1.75.0".minimal.override { + # Set the build targets supported by the toolchain, + # wasm32-unknown-unknown is required for trunk. + targets = [ "wasm32-unknown-unknown" ]; + }; + craneLib = + inputs.crane.lib.${system}.overrideToolchain rustToolchain; - devShells.default = pkgs.mkShell { - inputsFrom = [ inputs'.holochain.devShells.holonix ]; - packages = with pkgs; [ - nodejs_20 - # more packages go here - ]; + in pkgs.callPackage ./nix/zome.nix { + inherit deterministicCraneLib craneLib crateCargoToml + excludedCrates workspacePath; + }; + sweettest = { holochain, dna, workspacePath, crateCargoToml }: + let + system = holochain.devShells.holonix.system; + pkgs = import inputs.nixpkgs { + inherit system; + overlays = [ (import inputs.rust-overlay) ]; + }; + rustToolchain = pkgs.rust-bin.stable."1.75.0".minimal.override { + # Set the build targets supported by the toolchain, + # wasm32-unknown-unknown is required for trunk. + targets = [ "wasm32-unknown-unknown" ]; + }; + craneLib = + inputs.crane.lib.${system}.overrideToolchain rustToolchain; + in pkgs.callPackage ./nix/sweettest.nix { + inherit holochain dna craneLib workspacePath crateCargoToml; + }; + dna = { holochain, dnaManifest, zomes }: + let + system = holochain.devShells.holonix.system; + pkgs = import inputs.nixpkgs { + inherit system; + overlays = [ (import inputs.rust-overlay) ]; + }; + in pkgs.callPackage ./nix/dna.nix { + inherit zomes holochain dnaManifest; }; + happ = { holochain, happManifest, dnas }: + let + system = holochain.devShells.holonix.system; + pkgs = import inputs.nixpkgs { + inherit system; + overlays = [ (import inputs.rust-overlay) ]; + }; + in pkgs.callPackage ./nix/happ.nix { + inherit dnas holochain happManifest; + }; + }; + }; - packages.npm-warning = pkgs.writeShellScriptBin "echo-npm-warning" '' - echo " ------------------ + systems = builtins.attrNames inputs.holochain.devShells; + perSystem = { inputs', config, pkgs, system, lib, ... }: rec { -WARNING: this repository is not managed with npm, but pnpm. + devShells.default = pkgs.mkShell { + inputsFrom = [ inputs'.holochain.devShells.holonix ]; + packages = with pkgs; + [ + nodejs_20 + # more packages go here + ]; + }; -Don't worry! They are really similar to each other. Here are some helpful reminders: - -If you are trying to run \`npm install\`, you can run \`pnpm install\` -If you are trying to run \`npm install some_dependency\`, you can run \`pnpm add some_dependency\` -If you are trying to run a script like \`npm run build\`, you can run \`pnpm build\` -If you are trying to run a script for a certain workspace like \`npm run build -w ui\`, you can run \`pnpm -F ui build\` + packages.npm-warning = pkgs.writeShellScriptBin "echo-npm-warning" '' + echo " + ----------------- -The npm command that you just ran will continue now, but it is recommended that you do all commands in this repository with pnpm. + WARNING: this repository is not managed with npm, but pnpm. ------------------ + Don't worry! They are really similar to each other. Here are some helpful reminders: + + If you are trying to run \`npm install\`, you can run \`pnpm install\` + If you are trying to run \`npm install some_dependency\`, you can run \`pnpm add some_dependency\` + If you are trying to run a script like \`npm run build\`, you can run \`pnpm build\` + If you are trying to run a script for a certain workspace like \`npm run build -w ui\`, you can run \`pnpm -F ui build\` -" - ''; + The npm command that you just ran will continue now, but it is recommended that you do all commands in this repository with pnpm. - devShells.synchronized-pnpm = pkgs.mkShell { - packages = [ - (pkgs.symlinkJoin { - name = "npm"; - paths = [ pkgs.nodejs_20 ]; - buildInputs = [ pkgs.makeWrapper ]; - postBuild = '' - wrapProgram $out/bin/npm \ - --run ${packages.npm-warning}/bin/echo-npm-warning - ''; - }) - pkgs.nodejs_20 - packages.pnpm - packages.sync-npm-git-dependencies-with-nix - ]; + ----------------- - shellHook = '' - sync-npm-git-dependencies-with-nix - ''; - }; + " + ''; - packages.sync-npm-git-dependencies-with-nix = - let - craneLib = inputs.crane.lib.${system}; + devShells.synchronized-pnpm = pkgs.mkShell { + packages = [ + (pkgs.symlinkJoin { + name = "npm"; + paths = [ pkgs.nodejs_20 ]; + buildInputs = [ pkgs.makeWrapper ]; + postBuild = + " wrapProgram $out/bin/npm \\\n --run ${packages.npm-warning}/bin/echo-npm-warning\n "; + }) + pkgs.nodejs_20 + packages.pnpm + packages.sync-npm-git-dependencies-with-nix + ]; - cratePath = ./crates/sync_npm_git_dependencies_with_nix; + shellHook = '' + sync-npm-git-dependencies-with-nix + ''; + }; - cargoToml = builtins.fromTOML (builtins.readFile "${cratePath}/Cargo.toml"); - crate = cargoToml.package.name; + packages.sync-npm-git-dependencies-with-nix = let + craneLib = inputs.crane.lib.${system}; + cratePath = ./crates/sync_npm_git_dependencies_with_nix; - buildInputs = (with pkgs; [ openssl inputs'.holochain.packages.opensslStatic sqlcipher ]) - ++ (lib.optionals pkgs.stdenv.isDarwin - (with pkgs.darwin.apple_sdk_11_0.frameworks; [ - AppKit - CoreFoundation - CoreServices - Security - IOKit - ])); - commonArgs = { - inherit buildInputs; - doCheck = false; - src = craneLib.cleanCargoSource (craneLib.path ./.); - nativeBuildInputs = (with pkgs; [ makeWrapper perl pkg-config inputs'.holochain.packages.goWrapper ]) - ++ lib.optionals pkgs.stdenv.isDarwin - (with pkgs; [ xcbuild libiconv ]); - }; - in - craneLib.buildPackage (commonArgs // { - pname = crate; - version = cargoToml.package.version; - }); + cargoToml = + builtins.fromTOML (builtins.readFile "${cratePath}/Cargo.toml"); + crate = cargoToml.package.name; - packages.scaffold-remote-zome = - let - craneLib = inputs.crane.lib.${system}; + buildInputs = (with pkgs; [ + openssl + inputs'.holochain.packages.opensslStatic + sqlcipher + ]) ++ (lib.optionals pkgs.stdenv.isDarwin + (with pkgs.darwin.apple_sdk_11_0.frameworks; [ + AppKit + CoreFoundation + CoreServices + Security + IOKit + ])); + commonArgs = { + inherit buildInputs; + doCheck = false; + src = craneLib.cleanCargoSource (craneLib.path ./.); + nativeBuildInputs = (with pkgs; [ + makeWrapper + perl + pkg-config + inputs'.holochain.packages.goWrapper + ]) ++ lib.optionals pkgs.stdenv.isDarwin + (with pkgs; [ xcbuild libiconv ]); + }; + in craneLib.buildPackage (commonArgs // { + pname = crate; + version = cargoToml.package.version; + }); - cratePath = ./crates/scaffold_remote_zome; + packages.scaffold-remote-zome = let + craneLib = inputs.crane.lib.${system}; - cargoToml = builtins.fromTOML (builtins.readFile "${cratePath}/Cargo.toml"); - crate = cargoToml.package.name; + cratePath = ./crates/scaffold_remote_zome; - buildInputs = (with pkgs; [ openssl inputs'.holochain.packages.opensslStatic sqlcipher ]) - ++ (lib.optionals pkgs.stdenv.isDarwin - (with pkgs.darwin.apple_sdk_11_0.frameworks; [ - AppKit - CoreFoundation - CoreServices - Security - IOKit - ])); - commonArgs = { - inherit buildInputs; - doCheck = false; - src = craneLib.cleanCargoSource (craneLib.path ./.); - nativeBuildInputs = (with pkgs; [ makeWrapper perl pkg-config inputs'.holochain.packages.goWrapper ]) - ++ lib.optionals pkgs.stdenv.isDarwin - (with pkgs; [ xcbuild libiconv ]); - }; - in - craneLib.buildPackage (commonArgs // { - pname = crate; - version = cargoToml.package.version; - }); + cargoToml = + builtins.fromTOML (builtins.readFile "${cratePath}/Cargo.toml"); + crate = cargoToml.package.name; - packages.pnpm = pkgs.stdenv.mkDerivation { - pname ="pnpm"; - version ="pnpm-9"; - buildInputs = [ pkgs.nodejs_20 ]; - phases = ["installPhase"]; - installPhase = '' - mkdir -p $out/bin - corepack enable pnpm --install-directory=$out/bin - ''; - }; + buildInputs = (with pkgs; [ + openssl + inputs'.holochain.packages.opensslStatic + sqlcipher + ]) ++ (lib.optionals pkgs.stdenv.isDarwin + (with pkgs.darwin.apple_sdk_11_0.frameworks; [ + AppKit + CoreFoundation + CoreServices + Security + IOKit + ])); + commonArgs = { + inherit buildInputs; + doCheck = false; + src = craneLib.cleanCargoSource (craneLib.path ./.); + nativeBuildInputs = (with pkgs; [ + makeWrapper + perl + pkg-config + inputs'.holochain.packages.goWrapper + ]) ++ lib.optionals pkgs.stdenv.isDarwin + (with pkgs; [ xcbuild libiconv ]); }; + in craneLib.buildPackage (commonArgs // { + pname = crate; + version = cargoToml.package.version; + }); + + packages.pnpm = pkgs.stdenv.mkDerivation { + pname = "pnpm"; + version = "pnpm-9"; + buildInputs = [ pkgs.nodejs_20 ]; + phases = [ "installPhase" ]; + installPhase = '' + mkdir -p $out/bin + corepack enable pnpm --install-directory=$out/bin + ''; + }; }; + }; }