Clone of https://github.com/NixOS/nixpkgs.git (to stress-test knotserver)
1{ 2 lib, 3 stdenv, 4 buildGoModule, 5 fetchFromGitHub, 6 fetchNpmDeps, 7 npmHooks, 8 nodejs, 9 nix-update-script, 10 versionCheckHook, 11 postgresqlTestHook, 12 postgresql, 13 defaultApiEndPoint ? "https://api.getdnote.com", 14}: 15 16buildGoModule rec { 17 pname = "dnote"; 18 version = "0.15.1"; 19 20 src = fetchFromGitHub { 21 owner = "dnote"; 22 repo = "dnote"; 23 tag = "cli-v${version}"; 24 hash = "sha256-2vVopuFf9bx8U3+U4wznC/9nlLtan+fU5v9HUCEI1R4="; 25 }; 26 27 npmDeps = fetchNpmDeps { 28 inherit version src; 29 pname = "${pname}-webui"; 30 sourceRoot = "${src.name}/pkg/server/assets"; 31 hash = "sha256-gUr8ptPsE7uw/F52CZi1P2L7eLgGiELEz6tI+fwAN0I="; 32 }; 33 34 overrideModAttrs = oldAttrs: { 35 # Do not add `npmConfigHook` to `goModules` 36 nativeBuildInputs = lib.remove npmHooks.npmConfigHook oldAttrs.nativeBuildInputs; 37 preBuild = null; 38 }; 39 40 npmRoot = "pkg/server/assets"; 41 42 env = { 43 DBHost = "localhost"; 44 DBPort = "5432"; 45 DBName = "test_db"; 46 DBUser = "postgres"; 47 DBPassword = ""; 48 DBSkipSSL = true; 49 SmtpUsername = "mock-SmtpUsername"; 50 SmtpPassword = "mock-SmtpPassword"; 51 SmtpHost = "mock-SmtpHost"; 52 SmtpPort = 465; 53 WebURL = "http://localhost:3000"; 54 DisableRegistration = false; 55 postgresqlEnableTCP = true; 56 }; 57 58 nativeBuildInputs = [ 59 npmHooks.npmConfigHook 60 nodejs 61 ]; 62 63 nativeCheckInputs = [ 64 postgresqlTestHook 65 postgresql 66 ]; 67 68 tags = [ 69 "fts5" 70 ]; 71 72 preBuild = '' 73 patchShebangs . 74 75 pushd pkg/server/assets 76 77 ./styles/build.sh 78 ./js/build.sh 79 80 popd 81 ''; 82 83 ldflags = [ 84 "-X github.com/dnote/dnote/pkg/server/buildinfo.Version=${version}" 85 "-X github.com/dnote/dnote/pkg/cli/buildinfo.Version=${version}" 86 "-X main.apiEndpoint=${defaultApiEndPoint}" 87 "-X main.versionTag=${version}" 88 "-X github.com/dnote/dnote/pkg/server/buildinfo.Standalone=true" 89 "-X github.com/dnote/dnote/pkg/server/buildinfo.JSFiles=main.js" 90 "-X github.com/dnote/dnote/pkg/server/buildinfo.CSSFiles=main.css" 91 ]; 92 93 __darwinAllowLocalNetworking = true; 94 95 postInstall = '' 96 mv $out/bin/cli $out/bin/dnote-cli 97 mv $out/bin/migrate $out/bin/dnote-migrate 98 mv $out/bin/server $out/bin/dnote-server 99 mv $out/bin/templates $out/bin/dnote-templates 100 mv $out/bin/watcher $out/bin/dnote-watcher 101 ''; 102 103 checkFlags = [ 104 "-p 1" 105 ]; 106 107 vendorHash = "sha256-4mP5z3ZVlHYhItRjkbXvcOxVm6PuZ6viL2GHqzCH9tA="; 108 109 nativeInstallCheckInputs = [ 110 versionCheckHook 111 ]; 112 versionCheckProgram = "${placeholder "out"}/bin/dnote-cli"; 113 versionCheckProgramArg = "version"; 114 # Fails on darwin: 115 # panic: initializing context: initializing files: creating the dnote dir: 116 # initializing config dir: creating a directory at /var/empty/.config/dnote: mkdir /var/empty: file exists 117 doInstallCheck = !stdenv.hostPlatform.isDarwin; 118 119 passthru = { 120 updateScript = nix-update-script { }; 121 }; 122 123 meta = { 124 description = "Simple command line notebook for programmers"; 125 homepage = "https://www.getdnote.com/"; 126 changelog = "https://github.com/dnote/dnote/blob/cli-v${version}/CHANGELOG.md"; 127 platforms = lib.platforms.unix; 128 maintainers = with lib.maintainers; [ bot-wxt1221 ]; 129 license = with lib.licenses; [ 130 gpl3Only 131 agpl3Only 132 ]; 133 }; 134}