nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at python-updates 142 lines 3.6 kB view raw
1{ 2 lib, 3 applyPatches, 4 bundlerEnv, 5 fetchFromGitHub, 6 fetchNpmDeps, 7 nixosTests, 8 nodejs, 9 npmHooks, 10 ruby_3_4, 11 stdenv, 12 tailwindcss_3, 13 gemset ? import ./gemset.nix, 14 sources ? lib.importJSON ./sources.json, 15 unpatchedSource ? fetchFromGitHub { 16 owner = "Freika"; 17 repo = "dawarich"; 18 tag = sources.version; 19 inherit (sources) hash; 20 }, 21}: 22let 23 ruby = ruby_3_4; 24in 25stdenv.mkDerivation (finalAttrs: { 26 pname = "dawarich"; 27 inherit (sources) version; 28 29 # Use `applyPatches` here because bundix in the update script (see ./update.sh) 30 # needs to run on the already patched Gemfile and Gemfile.lock. 31 # Only patches changing these two files should be here; 32 # patches for other parts of the application should go directly into mkDerivation. 33 src = applyPatches { 34 src = unpatchedSource; 35 patches = [ 36 # bundix and bundlerEnv fail with system-specific gems 37 ./0001-build-ffi-gem.diff 38 # openssl 3.6.0 breaks ruby openssl gem 39 # See https://github.com/NixOS/nixpkgs/issues/456753 40 # and https://github.com/ruby/openssl/issues/949#issuecomment-3370358680 41 ./0002-openssl-hotfix.diff 42 ]; 43 postPatch = '' 44 substituteInPlace ./Gemfile \ 45 --replace-fail "ruby File.read('.ruby-version').strip" "ruby '>= 3.4.0'" 46 ''; 47 }; 48 49 postPatch = '' 50 # move import directory to a more convenient place, otherwise its behind systemd private tmp 51 substituteInPlace ./app/services/imports/watcher.rb \ 52 --replace-fail 'tmp/imports/watched' 'storage/imports/watched' 53 ''; 54 55 dawarichGems = bundlerEnv { 56 name = "${finalAttrs.pname}-gems-${finalAttrs.version}"; 57 inherit gemset ruby; 58 inherit (finalAttrs) version; 59 gemdir = finalAttrs.src; 60 }; 61 62 npmDeps = fetchNpmDeps { 63 inherit (finalAttrs) src; 64 hash = sources.npmHash; 65 }; 66 67 RAILS_ENV = "production"; 68 NODE_ENV = "production"; 69 REDIS_URL = ""; # build error if not defined 70 TAILWINDCSS_INSTALL_DIR = "${tailwindcss_3}/bin"; 71 72 nativeBuildInputs = [ 73 nodejs 74 npmHooks.npmConfigHook 75 finalAttrs.dawarichGems 76 finalAttrs.dawarichGems.wrappedRuby 77 ]; 78 propagatedBuildInputs = [ 79 finalAttrs.dawarichGems.wrappedRuby 80 ]; 81 buildInputs = [ 82 finalAttrs.dawarichGems 83 ]; 84 85 buildPhase = '' 86 runHook preBuild 87 88 patchShebangs bin/ 89 for b in $(ls $dawarichGems/bin/) 90 do 91 if [ ! -f bin/$b ]; then 92 ln -s $dawarichGems/bin/$b bin/$b 93 fi 94 done 95 96 SECRET_KEY_BASE_DUMMY=1 bundle exec rake assets:precompile 97 98 rm -rf node_modules tmp log storage 99 ln -s /var/log/dawarich log 100 ln -s /var/lib/dawarich storage 101 ln -s /tmp tmp 102 103 # delete more files unneeded at runtime 104 rm -rf docker docs screenshots package.json package-lock.json *.md *.example 105 106 runHook postBuild 107 ''; 108 109 installPhase = '' 110 runHook preInstall 111 112 # tests are not needed at runtime 113 rm -rf spec e2e 114 # delete artifacts from patching 115 rm *.orig 116 117 mkdir -p $out 118 mv .{ruby*,app_version} $out/ 119 mv * $out/ 120 121 runHook postInstall 122 ''; 123 124 passthru = { 125 tests = { 126 inherit (nixosTests) dawarich; 127 }; 128 # run with: nix-shell ./maintainers/scripts/update.nix --argstr package dawarich 129 updateScript = ./update.sh; 130 }; 131 132 meta = { 133 changelog = "https://github.com/Freika/dawarich/blob/${finalAttrs.version}/CHANGELOG.md"; 134 description = "Self-hostable alternative to Google Location History (Google Maps Timeline)"; 135 homepage = "https://dawarich.app/"; 136 license = lib.licenses.agpl3Only; 137 maintainers = with lib.maintainers; [ 138 diogotcorreia 139 ]; 140 platforms = lib.platforms.linux; 141 }; 142})