diff --git a/overlays/mill-flows/fetch-mill-deps.nix b/overlays/mill-flows/fetch-mill-deps.nix index b989f1e..e0905dd 100644 --- a/overlays/mill-flows/fetch-mill-deps.nix +++ b/overlays/mill-flows/fetch-mill-deps.nix @@ -15,62 +15,51 @@ }@args: let - self = stdenvNoCC.mkDerivation (lib.recursiveUpdate - { - name = "${name}-mill-deps"; - inherit src; + buildAttr = { + name = "${name}-mill-deps"; + inherit src; - nativeBuildInputs = [ - mill - configure-mill-home-hook - ] ++ (args.nativeBuildInputs or [ ]); + propagatedBuildInputs = [ + mill + configure-mill-home-hook + lndir + ] ++ (args.propagatedBuildInputs or [ ]); - impureEnvVars = [ "JAVA_OPTS" ]; + impureEnvVars = [ "JAVA_OPTS" ]; - buildPhase = '' - runHook preBuild + buildPhase = '' + runHook preBuild - # Use "https://repo1.maven.org/maven2/" only to keep dependencies integrity - export COURSIER_REPOSITORIES="ivy2local|central" + # Use "https://repo1.maven.org/maven2/" only to keep dependencies integrity + export COURSIER_REPOSITORIES="ivy2local|central" - mill -i __.prepareOffline - mill -i __.scalaCompilerClasspath + mill -i __.prepareOffline + mill -i __.scalaCompilerClasspath - runHook postBuild - ''; + runHook postBuild + ''; - installPhase = '' - runHook preInstall + installPhase = '' + runHook preInstall - mkdir -p $out/.cache - mv "$NIX_MILL_HOME"/.cache/coursier $out/.cache/coursier + mkdir -p $out/.cache + mv "$NIX_MILL_HOME"/.cache/coursier $out/.cache/coursier - runHook postInstall - ''; + mkdir -p $out/nix-support + cp ${./setup-mill-deps.sh} $out/nix-support/setup-hook + recordPropagatedDependencies - outputHashAlgo = "sha256"; - outputHashMode = "recursive"; - outputHash = millDepsHash; + runHook postInstall + ''; - dontShrink = true; - dontPatchELF = true; + outputHashAlgo = "sha256"; + outputHashMode = "recursive"; + outputHash = millDepsHash; - passthru.setupHook = makeSetupHook - { - name = "mill-setup-hook.sh"; - propagatedBuildInputs = [ mill configure-mill-home-hook ]; - } - (writeText "mill-setup-hook" '' - setupMillCache() { - mkdir -p "$NIX_MILL_HOME/.cache/coursier" - ${lndir}/bin/lndir "${self}"/.cache/coursier "$NIX_MILL_HOME"/.cache/coursier - - echo "Copied mill deps into $NIX_MILL_HOME" - } - - postUnpackHooks+=(setupMillCache) - ''); - } - (builtins.removeAttrs args [ "name" "src" "millDepsHash" "nativeBuildInputs" ])); + dontShrink = true; + dontPatchELF = true; + }; in -self +stdenvNoCC.mkDerivation + (lib.recursiveUpdate buildAttr + (builtins.removeAttrs args [ "name" "src" "millDepsHash" "propagatedBuildInputs" ])) diff --git a/overlays/mill-flows/install-ivy-repo.sh b/overlays/mill-flows/install-ivy-repo.sh new file mode 100644 index 0000000..f4f4a70 --- /dev/null +++ b/overlays/mill-flows/install-ivy-repo.sh @@ -0,0 +1,8 @@ +setupIvyLocalRepo() { + mkdir -p "$NIX_MILL_HOME/.ivy2/local" + lndir ../../.ivy2/local "$NIX_MILL_HOME/.ivy2/local" + + echo "Copied ivy repo to $NIX_MILL_HOME" +} + +postUnpackHooks+=(setupIvyLocalRepo) diff --git a/overlays/mill-flows/publish-mill-jar.nix b/overlays/mill-flows/publish-mill-jar.nix index 7cafe51..ec0e484 100644 --- a/overlays/mill-flows/publish-mill-jar.nix +++ b/overlays/mill-flows/publish-mill-jar.nix @@ -11,57 +11,46 @@ { name, src, publishTargets, ... }@args: let - self = stdenvNoCC.mkDerivation (lib.recursiveUpdate - { - name = "${name}-mill-local-ivy"; - inherit src; + buildAttr = { + name = "${name}-mill-local-ivy"; + inherit src; - nativeBuildInputs = [ - mill - configure-mill-home-hook - ] ++ (args.nativeBuildInputs or [ ]); + propagatedBuildInputs = [ + mill + configure-mill-home-hook + lndir + ] ++ (args.propagatedBuildInputs or [ ]); - publishTargets = lib.escapeShellArgs publishTargets; + publishTargets = lib.escapeShellArgs publishTargets; - buildPhase = '' - runHook preBuild + buildPhase = '' + runHook preBuild - publishTargetsArray=( "$publishTargets" ) - for target in "''${publishTargetsArray[@]}"; do - mill -i "$target.publishLocal" - done + publishTargetsArray=( "$publishTargets" ) + for target in "''${publishTargetsArray[@]}"; do + mill -i "$target.publishLocal" + done - runHook postBuild - ''; + runHook postBuild + ''; - installPhase = '' - runHook preInstall + installPhase = '' + runHook preInstall - mkdir -p $out/.ivy2 - mv $NIX_MILL_HOME/.ivy2/local $out/.ivy2/ + mkdir -p $out/.ivy2 + mv $NIX_MILL_HOME/.ivy2/local $out/.ivy2/ - runHook postInstall - ''; + mkdir -p "$out"/nix-support + cp ${./install-ivy-repo.sh} "$out"/nix-support/setup-hook + recordPropagatedDependencies - dontShrink = true; - dontPatchELF = true; + runHook postInstall + ''; - passthru.setupHook = makeSetupHook - { - name = "mill-local-ivy-setup-hook.sh"; - propagatedBuildInputs = [ mill configure-mill-home-hook ]; - } - (writeText "mill-setup-hook" '' - setupIvyLocalRepo() { - mkdir -p "$NIX_MILL_HOME/.ivy2/local" - ${lndir}/bin/lndir "${self}/.ivy2/local" "$NIX_MILL_HOME/.ivy2/local" - - echo "Copy ivy repo to $NIX_MILL_HOME" - } - - postUnpackHooks+=(setupIvyLocalRepo) - ''); - } - (builtins.removeAttrs args [ "name" "src" "nativeBuildInputs" ])); + dontShrink = true; + dontPatchELF = true; + }; in -self +stdenvNoCC.mkDerivation + (lib.recursiveUpdate buildAttr + (builtins.removeAttrs args [ "name" "src" "propagatedBuildInputs" ])) diff --git a/overlays/mill-flows/setup-mill-deps.sh b/overlays/mill-flows/setup-mill-deps.sh new file mode 100644 index 0000000..04382a4 --- /dev/null +++ b/overlays/mill-flows/setup-mill-deps.sh @@ -0,0 +1,8 @@ +setupMillCache() { + mkdir -p "$NIX_MILL_HOME/.cache/coursier" + lndir ../../.cache/coursier "$NIX_MILL_HOME"/.cache/coursier + + echo "Copied mill deps into $NIX_MILL_HOME" +} + +postUnpackHooks+=(setupMillCache) diff --git a/overlays/mill-flowss.nix b/overlays/mill-flowss.nix deleted file mode 100644 index db0e404..0000000 --- a/overlays/mill-flowss.nix +++ /dev/null @@ -1,6 +0,0 @@ -final: prev: -{ - configure-mill-home-hook = final.callPackage ./mill-flows/configure-mill-home.nix { }; - fetchMillDeps = final.callPackage ./mill-flows/fetch-mill-deps.nix { inherit (final.xorg) lndir; }; - publishMillJar = final.callPackage ./mill-flows/publish-mill-jar.nix { inherit (final.xorg) lndir; }; -} diff --git a/readme.md b/readme.md index 5d0eb85..9fd16a8 100644 --- a/readme.md +++ b/readme.md @@ -344,7 +344,7 @@ publishMillJar { ]; buildInputs = [ - chiselDeps.setupHook + chiselDeps ]; nativeBuildInputs = [