nixpkgs mirror (for testing) github.com/NixOS/nixpkgs
nix
at devShellTools-shell 141 lines 3.0 kB view raw
1{ 2 lib, 3 fetchFromGitHub, 4 stdenv, 5 nodejs, 6 pnpm, 7 buildGoModule, 8 mage, 9 writeShellScriptBin, 10 nixosTests, 11}: 12 13let 14 version = "0.24.6"; 15 src = fetchFromGitHub { 16 owner = "go-vikunja"; 17 repo = "vikunja"; 18 rev = "v${version}"; 19 hash = "sha256-yUUZ6gPI2Bte36HzfUE6z8B/I1NlwWDSJA2pwkuzd34="; 20 }; 21 22 frontend = stdenv.mkDerivation (finalAttrs: { 23 pname = "vikunja-frontend"; 24 inherit version src; 25 26 patches = [ 27 ./nodejs-22.12-tailwindcss-update.patch 28 ]; 29 sourceRoot = "${finalAttrs.src.name}/frontend"; 30 31 pnpmDeps = pnpm.fetchDeps { 32 inherit (finalAttrs) 33 pname 34 version 35 patches 36 src 37 sourceRoot 38 ; 39 fetcherVersion = 1; 40 hash = "sha256-94ZlywOZYmW/NsvE0dtEA81MeBWGUrJsBXTUauuOmZM="; 41 }; 42 43 nativeBuildInputs = [ 44 nodejs 45 pnpm.configHook 46 ]; 47 48 doCheck = true; 49 50 postBuild = '' 51 pnpm run build 52 ''; 53 54 checkPhase = '' 55 pnpm run test:unit --run 56 ''; 57 58 installPhase = '' 59 cp -r dist/ $out 60 ''; 61 }); 62 63 # Injects a `t.Skip()` into a given test since there's apparently no other way to skip tests here. 64 skipTest = 65 lineOffset: testCase: file: 66 let 67 jumpAndAppend = lib.concatStringsSep ";" (lib.replicate (lineOffset - 1) "n" ++ [ "a" ]); 68 in 69 '' 70 sed -i -e '/${testCase}/{ 71 ${jumpAndAppend} t.Skip(); 72 }' ${file} 73 ''; 74in 75buildGoModule { 76 inherit src version; 77 pname = "vikunja"; 78 79 nativeBuildInputs = 80 let 81 fakeGit = writeShellScriptBin "git" '' 82 if [[ $@ = "describe --tags --always --abbrev=10" ]]; then 83 echo "${version}" 84 else 85 >&2 echo "Unknown command: $@" 86 exit 1 87 fi 88 ''; 89 in 90 [ 91 fakeGit 92 mage 93 ]; 94 95 vendorHash = "sha256-OsKejno8QGg7HzRsrftngiWGiWHFc1jDLi5mQ9/NjI4="; 96 97 inherit frontend; 98 99 prePatch = '' 100 cp -r ${frontend} frontend/dist 101 ''; 102 103 postConfigure = '' 104 # These tests need internet, so we skip them. 105 ${skipTest 1 "TestConvertTrelloToVikunja" "pkg/modules/migration/trello/trello_test.go"} 106 ${skipTest 1 "TestConvertTodoistToVikunja" "pkg/modules/migration/todoist/todoist_test.go"} 107 ''; 108 109 buildPhase = '' 110 runHook preBuild 111 112 # Fixes "mkdir /homeless-shelter: permission denied" - "Error: error compiling magefiles" during build 113 export HOME=$(mktemp -d) 114 mage build:build 115 116 runHook postBuild 117 ''; 118 119 checkPhase = '' 120 mage test:unit 121 mage test:integration 122 ''; 123 124 installPhase = '' 125 runHook preInstall 126 install -Dt $out/bin vikunja 127 runHook postInstall 128 ''; 129 130 passthru.tests.vikunja = nixosTests.vikunja; 131 132 meta = { 133 changelog = "https://kolaente.dev/vikunja/api/src/tag/v${version}/CHANGELOG.md"; 134 description = "Todo-app to organize your life"; 135 homepage = "https://vikunja.io/"; 136 license = lib.licenses.agpl3Plus; 137 maintainers = with lib.maintainers; [ leona ]; 138 mainProgram = "vikunja"; 139 platforms = lib.platforms.linux; 140 }; 141}