stash: Refactor to use finalAttrs, straighten out src references (#442514)
This commit is contained in:
@@ -21,117 +21,125 @@ let
|
|||||||
;
|
;
|
||||||
|
|
||||||
pname = "stash";
|
pname = "stash";
|
||||||
|
in
|
||||||
|
buildGoModule (
|
||||||
|
finalAttrs:
|
||||||
|
let
|
||||||
|
frontend = stdenv.mkDerivation (final: {
|
||||||
|
pname = "${finalAttrs.pname}-ui";
|
||||||
|
inherit (finalAttrs) version gitHash;
|
||||||
|
src = "${finalAttrs.src}/ui/v2.5";
|
||||||
|
|
||||||
src = fetchFromGitHub {
|
yarnOfflineCache = fetchYarnDeps {
|
||||||
owner = "stashapp";
|
yarnLock = "${final.src}/yarn.lock";
|
||||||
repo = "stash";
|
hash = finalAttrs.yarnHash;
|
||||||
tag = "v${version}";
|
};
|
||||||
hash = srcHash;
|
|
||||||
};
|
|
||||||
|
|
||||||
frontend = stdenv.mkDerivation (final: {
|
nativeBuildInputs = [
|
||||||
inherit version;
|
yarnConfigHook
|
||||||
pname = "${pname}-ui";
|
yarnBuildHook
|
||||||
src = "${src}/ui/v2.5";
|
# Needed for executing package.json scripts
|
||||||
|
nodejs
|
||||||
|
];
|
||||||
|
|
||||||
yarnOfflineCache = fetchYarnDeps {
|
postPatch = ''
|
||||||
yarnLock = "${final.src}/yarn.lock";
|
substituteInPlace codegen.ts \
|
||||||
hash = yarnHash;
|
--replace-fail "../../graphql/" "${finalAttrs.src}/graphql/"
|
||||||
|
'';
|
||||||
|
|
||||||
|
buildPhase = ''
|
||||||
|
runHook preBuild
|
||||||
|
|
||||||
|
export HOME=$(mktemp -d)
|
||||||
|
export VITE_APP_DATE='1970-01-01 00:00:00'
|
||||||
|
export VITE_APP_GITHASH=${finalAttrs.gitHash}
|
||||||
|
export VITE_APP_STASH_VERSION=v${finalAttrs.version}
|
||||||
|
export VITE_APP_NOLEGACY=true
|
||||||
|
|
||||||
|
yarn --offline run gqlgen
|
||||||
|
yarn --offline build
|
||||||
|
|
||||||
|
mv build $out
|
||||||
|
|
||||||
|
runHook postBuild
|
||||||
|
'';
|
||||||
|
|
||||||
|
dontInstall = true;
|
||||||
|
dontFixup = true;
|
||||||
|
});
|
||||||
|
in
|
||||||
|
{
|
||||||
|
inherit
|
||||||
|
pname
|
||||||
|
version
|
||||||
|
gitHash
|
||||||
|
yarnHash
|
||||||
|
vendorHash
|
||||||
|
;
|
||||||
|
|
||||||
|
src = fetchFromGitHub {
|
||||||
|
owner = "stashapp";
|
||||||
|
repo = "stash";
|
||||||
|
tag = "v${finalAttrs.version}";
|
||||||
|
hash = srcHash;
|
||||||
};
|
};
|
||||||
|
|
||||||
nativeBuildInputs = [
|
ldflags = [
|
||||||
yarnConfigHook
|
"-s"
|
||||||
yarnBuildHook
|
"-w"
|
||||||
# Needed for executing package.json scripts
|
"-X 'github.com/stashapp/stash/internal/build.buildstamp=1970-01-01 00:00:00'"
|
||||||
nodejs
|
"-X 'github.com/stashapp/stash/internal/build.githash=${finalAttrs.gitHash}'"
|
||||||
|
"-X 'github.com/stashapp/stash/internal/build.version=v${finalAttrs.version}'"
|
||||||
|
"-X 'github.com/stashapp/stash/internal/build.officialBuild=false'"
|
||||||
];
|
];
|
||||||
|
tags = [
|
||||||
|
"sqlite_stat4"
|
||||||
|
"sqlite_math_functions"
|
||||||
|
];
|
||||||
|
|
||||||
|
subPackages = [ "cmd/stash" ];
|
||||||
|
|
||||||
postPatch = ''
|
postPatch = ''
|
||||||
substituteInPlace codegen.ts \
|
cp -a ${frontend} ui/v2.5/build
|
||||||
--replace-fail "../../graphql/" "${src}/graphql/"
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
buildPhase = ''
|
preBuild = ''
|
||||||
runHook preBuild
|
# `go mod tidy` requires internet access and does nothing
|
||||||
|
echo "skip_mod_tidy: true" >> gqlgen.yml
|
||||||
export HOME=$(mktemp -d)
|
# remove `-trimpath` fron `GOFLAGS` because `gqlgen` does not work with it
|
||||||
export VITE_APP_DATE='1970-01-01 00:00:00'
|
GOFLAGS="''${GOFLAGS/-trimpath/}" go generate ./cmd/stash
|
||||||
export VITE_APP_GITHASH=${gitHash}
|
|
||||||
export VITE_APP_STASH_VERSION=v${version}
|
|
||||||
export VITE_APP_NOLEGACY=true
|
|
||||||
|
|
||||||
yarn --offline run gqlgen
|
|
||||||
yarn --offline build
|
|
||||||
|
|
||||||
mv build $out
|
|
||||||
|
|
||||||
runHook postBuild
|
|
||||||
'';
|
'';
|
||||||
|
|
||||||
dontInstall = true;
|
strictDeps = true;
|
||||||
dontFixup = true;
|
|
||||||
});
|
|
||||||
in
|
|
||||||
buildGoModule {
|
|
||||||
inherit
|
|
||||||
pname
|
|
||||||
src
|
|
||||||
version
|
|
||||||
vendorHash
|
|
||||||
;
|
|
||||||
|
|
||||||
ldflags = [
|
passthru = {
|
||||||
"-s"
|
inherit frontend;
|
||||||
"-w"
|
updateScript = ./update.py;
|
||||||
"-X 'github.com/stashapp/stash/internal/build.buildstamp=1970-01-01 00:00:00'"
|
tests = {
|
||||||
"-X 'github.com/stashapp/stash/internal/build.githash=${gitHash}'"
|
inherit (nixosTests) stash;
|
||||||
"-X 'github.com/stashapp/stash/internal/build.version=v${version}'"
|
version = testers.testVersion {
|
||||||
"-X 'github.com/stashapp/stash/internal/build.officialBuild=false'"
|
package = stash;
|
||||||
];
|
version = "v${finalAttrs.version} (${finalAttrs.gitHash}) - Unofficial Build - 1970-01-01 00:00:00";
|
||||||
tags = [
|
};
|
||||||
"sqlite_stat4"
|
|
||||||
"sqlite_math_functions"
|
|
||||||
];
|
|
||||||
|
|
||||||
subPackages = [ "cmd/stash" ];
|
|
||||||
|
|
||||||
preBuild = ''
|
|
||||||
cp -a ${frontend} ui/v2.5/build
|
|
||||||
# `go mod tidy` requires internet access and does nothing
|
|
||||||
echo "skip_mod_tidy: true" >> gqlgen.yml
|
|
||||||
# remove `-trimpath` fron `GOFLAGS` because `gqlgen` does not work with it
|
|
||||||
GOFLAGS="''${GOFLAGS/-trimpath/}" go generate ./cmd/stash
|
|
||||||
'';
|
|
||||||
|
|
||||||
strictDeps = true;
|
|
||||||
|
|
||||||
passthru = {
|
|
||||||
inherit frontend;
|
|
||||||
updateScript = ./update.py;
|
|
||||||
tests = {
|
|
||||||
inherit (nixosTests) stash;
|
|
||||||
version = testers.testVersion {
|
|
||||||
package = stash;
|
|
||||||
version = "v${version} (${gitHash}) - Unofficial Build - 1970-01-01 00:00:00";
|
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
|
||||||
|
|
||||||
meta = {
|
meta = {
|
||||||
mainProgram = "stash";
|
mainProgram = "stash";
|
||||||
description = "Organizer for your adult videos/images";
|
description = "Organizer for your adult videos/images";
|
||||||
license = lib.licenses.agpl3Only;
|
license = lib.licenses.agpl3Only;
|
||||||
homepage = "https://stashapp.cc/";
|
homepage = "https://stashapp.cc/";
|
||||||
changelog = "https://github.com/stashapp/stash/blob/v${version}/ui/v2.5/src/docs/en/Changelog/v${lib.versions.major version}${lib.versions.minor version}0.md";
|
changelog = "https://github.com/stashapp/stash/blob/v${finalAttrs.version}/ui/v2.5/src/docs/en/Changelog/v${lib.versions.major finalAttrs.version}${lib.versions.minor finalAttrs.version}0.md";
|
||||||
maintainers = with lib.maintainers; [
|
maintainers = with lib.maintainers; [
|
||||||
Golo300
|
Golo300
|
||||||
DrakeTDL
|
DrakeTDL
|
||||||
];
|
];
|
||||||
platforms = [
|
platforms = [
|
||||||
"x86_64-linux"
|
"x86_64-linux"
|
||||||
"aarch64-linux"
|
"aarch64-linux"
|
||||||
"x86_64-darwin"
|
"x86_64-darwin"
|
||||||
"aarch64-darwin"
|
"aarch64-darwin"
|
||||||
];
|
];
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user