commit f32cb421d52b28f70ee18e4e8be2195c6472b4e2 Author: kolaente Date: Thu May 6 11:55:31 2021 +0200 initial commit diff --git a/default.nix b/default.nix new file mode 100644 index 0000000..7f01aed --- /dev/null +++ b/default.nix @@ -0,0 +1,81 @@ +{ stdenv +, lib +, mkYarnPackage +, fetchgit +, python2 +, pkg-config +, libsass +, nodejs +, yarn +}: + +let + srcData = builtins.fromJSON (builtins.readFile ./src-frontend.json); + + version = "unstable-" + builtins.head (lib.splitString "T" srcData.date); + + src = fetchgit { + inherit (srcData) url rev sha256; + }; + + frontend-modules = mkYarnPackage rec { + name = "vikunja-frontend-modules"; + inherit version src; + + # cargo culted for node-sass + # https://github.com/input-output-hk/cardano-explorer/blob/7f28075951f248d2a5040dd30d8403f704474df6/nix/cardano-graphql/packages.nix + yarnPreBuild = '' + mkdir -p $HOME/.node-gyp/${nodejs.version} + echo 9 > $HOME/.node-gyp/${nodejs.version}/installVersion + ln -sfv ${nodejs}/include $HOME/.node-gyp/${nodejs.version} + ''; + + pkgConfig = { + node-sass = { + buildInputs = [ python2 pkg-config libsass ]; + # https://github.com/moretea/yarn2nix/issues/12#issuecomment-545084619 + postInstall = '' + LIBSASS_EXT=auto yarn --offline run build + rm build/config.gypi + ''; + }; + }; + + preInstall = '' + # for some reason the two node_modules have non-overlapping contents + cp -r deps/vikunja-frontend/node_modules/* node_modules/ + chmod -R a+w node_modules/ + ''; + + doDist = false; + }; +in stdenv.mkDerivation { + pname = "vikunja-desktop"; + inherit version src; + + nativeBuildInputs = [ frontend-modules yarn ]; + + buildPhase = '' + # Cannot use symlink or postcss-loader will crap out + cp -r ${frontend-modules}/libexec/vikunja-frontend/node_modules/ . + yarn --offline run build + sed -i 's/\/api\/v1//g' dist/index.html + ''; + + installPhase = '' + cp -r dist $out + ''; + + passthru = { + inherit frontend-modules; + }; + + meta = { + description = "Desktop version of the Vikunja to-do list app"; + homepage = "https://vikunja.io/"; + license = lib.licenses.gpl3Plus; + maintainers = with lib.maintainers; [ kolaente ]; + platforms = lib.platforms.all; + }; +} + diff --git a/src-frontend.json b/src-frontend.json new file mode 100644 index 0000000..afee1a3 --- /dev/null +++ b/src-frontend.json @@ -0,0 +1,10 @@ +{ + "url": "https://kolaente.dev/vikunja/frontend.git", + "rev": "fa4e53cf4a6aad708a8db6f01f063195c39c15c4", + "date": "2021-05-06T08:59:51+00:00", + "path": "/nix/store/0ysl6q05qnpqxxhh72swcwhrg3acmng0-frontend", + "sha256": "1my12qrgkqb9jqqc2dliw5cmjm6q5qkjn1lmhwbxg733ch7bnn4w", + "fetchSubmodules": false, + "deepClone": false, + "leaveDotGit": false +}