flake.nix (6258B)
1 # This is a nix flake. To use it, you need nix (with flake support) installed. 2 # If you do not have nix and do not intend to use it, you can ignore this file. 3 # Why should you use it? Using this flake will allow you to enter a developer shell 4 # which has all necessary packages for this repository already installed. 5 # The shell will allow you to code against the specific revisions of the dependencies 6 # pinned in this file. 7 # This is useful when git HEAD of your dependencies already contains breaking changes 8 # you should not (yet) code against. 9 # OTOH, if you should code against a newer, not yet released revision, you can specify 10 # this revision in this file. 11 # You can use this file in three ways: 12 # 1. Build: $ nix build 13 # this will build the package (it runs make for you in an environment with the dependencies installed) 14 # 2. Develop: $ nix develop 15 # This will drop you inside a shell in which you can develop and compile (and test) your code. 16 # It even starts and sets up the test database for you. 17 # 3. Use this repository in a new project 18 # Should you create a new project that depends on this project you are in luck. You can create a flake.nix 19 # in your repository and include this packages as a dependency just like the dependencies of this package are 20 # included here. 21 22 { 23 inputs = { 24 nixpkgs.url = "nixpkgs/release-26.05"; 25 systems.url = "github:nix-systems/default"; 26 gnunet.url = "git+https://git.gnunet.org/gnunet?ref=refs/tags/v0.29.1"; 27 exchange.url = "git+https://git.gnunet.org/exchange?ref=refs/tags/v1.6.16"; 28 # exchange v1.6.16 needs GNUNET_CRYPTO_eddsa_verify_raw, which its own 29 # GNUnet pin (v0.28.0) does not provide. 30 exchange.inputs.gnunet.follows = "gnunet"; 31 # merchant needs DONAU_setup(), available since donau v1.6.7 32 donau.url = "git+https://git.gnunet.org/donau?ref=refs/tags/v1.6.9"; 33 donau.inputs.gnunet.follows = "gnunet"; 34 donau.inputs.exchange.follows = "exchange"; 35 self.submodules = true; 36 }; 37 38 outputs = { self, nixpkgs, gnunet, exchange, donau, systems, ... } @ inputs: 39 let 40 supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; 41 forEachSystem = nixpkgs.lib.genAttrs supportedSystems; 42 nixpkgsFor = forEachSystem (system: import nixpkgs { inherit system; }); 43 in 44 { 45 # This defines (installable) package derivations 46 # For use in flakes that use this flake as input in order 47 # to specify/use this package from git as a dependency 48 packages = forEachSystem (system: 49 let 50 pkgs = nixpkgsFor.${system}; 51 gnunetpkgs = gnunet.packages.${system}; 52 exchangepkgs = exchange.packages.${system}; 53 donaupkgs = donau.packages.${system}; 54 # donau's doc/prebuilt submodule lags behind its doc/meson.build, 55 # so build it without the documentation. 56 donaupkg = donaupkgs.donau.overrideAttrs (old: { 57 mesonFlags = (old.mesonFlags or []) ++ [ "-Ddisable-doc=true" ]; 58 }); 59 in { 60 merchant = pkgs.stdenv.mkDerivation { 61 name = "merchant"; 62 src = ./.; 63 nativeBuildInputs = [ 64 pkgs.gnumake 65 pkgs.meson 66 pkgs.ninja 67 pkgs.pkg-config 68 pkgs.python3 69 pkgs.texinfo 70 pkgs.typst 71 pkgs.pdftk 72 ]; 73 buildInputs = [ 74 pkgs.libtool 75 pkgs.jansson 76 pkgs.git 77 pkgs.gettext 78 pkgs.postgresql 79 (pkgs.python3.withPackages (python-pkgs: [ 80 python-pkgs.jinja2 81 ])) 82 pkgs.libmicrohttpd 83 pkgs.libsodium 84 pkgs.libgcrypt 85 pkgs.libunistring 86 pkgs.curlWithGnuTls 87 pkgs.jq 88 pkgs.qrencode 89 gnunetpkgs.gnunet 90 exchangepkgs.exchange 91 donaupkg 92 ]; 93 preConfigure = '' 94 patchShebangs --build contrib/check-prebuilt 95 ./bootstrap 96 ''; 97 }; 98 } 99 ); 100 defaultPackage = forEachSystem (system: self.packages.${system}.merchant); 101 # This defines a development shell in which you can compile 102 # (and use) exchange 103 devShells = forEachSystem 104 (system: 105 let 106 pkgs = nixpkgsFor.${system}; 107 gnunetpkgs = gnunet.packages.${system}; 108 exchangepkgs = exchange.packages.${system}; 109 donaupkgs = donau.packages.${system}; 110 donaupkg = donaupkgs.donau.overrideAttrs (old: { 111 mesonFlags = (old.mesonFlags or []) ++ [ "-Ddisable-doc=true" ]; 112 }); 113 in 114 { 115 default = pkgs.mkShell { 116 packages = [ 117 pkgs.gcc 118 pkgs.meson 119 pkgs.ninja 120 pkgs.gnumake 121 pkgs.texinfo 122 pkgs.pkg-config 123 pkgs.libtool 124 pkgs.jansson 125 pkgs.git 126 pkgs.gettext 127 pkgs.postgresql 128 pkgs.curlWithGnuTls 129 gnunetpkgs.gnunet 130 pkgs.codespell 131 pkgs.clang-tools 132 pkgs.uncrustify 133 pkgs.jq #probably not needed 134 pkgs.doxygen 135 pkgs.typst 136 pkgs.pdftk 137 pkgs.qrencode 138 exchangepkgs.exchange 139 donaupkg 140 ]; 141 142 shellHook = '' 143 echo "taler-merchant environment loaded." 144 export CC=gcc 145 export CFLAGS="-O" 146 mkdir -p default 147 export PGHOST=localhost 148 export PGPORT=5432 149 export PGUSER=$USER 150 export PGDATABASE=talercheck 151 export PGDATA="$PWD/default/.pg" 152 echo $PWD 153 [ ! -d $PGDATA ] && PGHOST="$PGDATA" pg_ctl initdb -o "-U $PGUSER" 154 155 pg_ctl -o "-p $PGPORT -k $PGDATA" start && createdb talercheck && { 156 trap 'pg_ctl stop && rm -r $PGDATA' EXIT 157 } 158 ''; 159 }; 160 }); 161 }; 162 }