flake.nix (5585B)
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-25.11"; 25 systems.url = "github:nix-systems/default"; 26 gnunet.url = "git+https://git.gnunet.org/gnunet?rev=7c6b613e37e301b0e81fb94af5878d00c98e5b75"; 27 exchange.url = "git+https://git.gnunet.org/exchange?rev=92da4e81006404494f6443781c8f55249e723847"; 28 donau.url = "git+https://git.gnunet.org/donau?rev=4f609168fe263891f134eff01f86288066acdd81"; 29 self.submodules = true; 30 }; 31 32 outputs = { self, nixpkgs, gnunet, exchange, donau, systems, ... } @ inputs: 33 let 34 supportedSystems = [ "x86_64-linux" "x86_64-darwin" "aarch64-linux" "aarch64-darwin" ]; 35 forEachSystem = nixpkgs.lib.genAttrs supportedSystems; 36 nixpkgsFor = forEachSystem (system: import nixpkgs { inherit system; }); 37 in 38 { 39 # This defines (installable) package derivations 40 # For use in flakes that use this flake as input in order 41 # to specify/use this package from git as a dependency 42 packages = forEachSystem (system: 43 let 44 pkgs = nixpkgsFor.${system}; 45 gnunetpkgs = gnunet.packages.${system}; 46 exchangepkgs = exchange.packages.${system}; 47 donaupkgs = donau.packages.${system}; 48 in { 49 merchant = pkgs.stdenv.mkDerivation { 50 name = "merchant"; 51 src = ./.; 52 nativeBuildInputs = [ 53 pkgs.gnumake 54 pkgs.meson 55 pkgs.ninja 56 pkgs.pkg-config 57 pkgs.python3 58 pkgs.texinfo 59 pkgs.typst 60 pkgs.pdftk 61 ]; 62 buildInputs = [ 63 pkgs.libtool 64 pkgs.jansson 65 pkgs.git 66 pkgs.gettext 67 pkgs.postgresql 68 (pkgs.python3.withPackages (python-pkgs: [ 69 python-pkgs.jinja2 70 ])) 71 pkgs.libmicrohttpd 72 pkgs.libsodium 73 pkgs.libgcrypt 74 pkgs.libunistring 75 pkgs.curlWithGnuTls 76 pkgs.jq 77 pkgs.qrencode 78 gnunetpkgs.gnunet 79 exchangepkgs.exchange 80 donaupkgs.donau 81 ]; 82 preConfigure = '' 83 patchShebangs --build contrib/check-prebuilt 84 ./bootstrap 85 ''; 86 }; 87 } 88 ); 89 defaultPackage = forEachSystem (system: self.packages.${system}.merchant); 90 # This defines a development shell in which you can compile 91 # (and use) exchange 92 devShells = forEachSystem 93 (system: 94 let 95 pkgs = nixpkgsFor.${system}; 96 gnunetpkgs = gnunet.packages.${system}; 97 exchangepkgs = exchange.packages.${system}; 98 donaupkgs = donau.packages.${system}; 99 in 100 { 101 default = pkgs.mkShell { 102 packages = [ 103 pkgs.gcc 104 pkgs.meson 105 pkgs.ninja 106 pkgs.gnumake 107 pkgs.texinfo 108 pkgs.pkg-config 109 pkgs.libtool 110 pkgs.jansson 111 pkgs.git 112 pkgs.gettext 113 pkgs.postgresql 114 pkgs.curlWithGnuTls 115 gnunetpkgs.gnunet 116 pkgs.codespell 117 pkgs.clang-tools 118 pkgs.uncrustify 119 pkgs.jq #probably not needed 120 pkgs.doxygen 121 pkgs.typst 122 pkgs.pdftk 123 pkgs.qrencode 124 exchangepkgs.exchange 125 donaupkgs.donau 126 ]; 127 128 shellHook = '' 129 echo "taler-merchant environment loaded." 130 export CC=gcc 131 export CFLAGS="-O" 132 mkdir -p default 133 export PGHOST=localhost 134 export PGPORT=5432 135 export PGUSER=$USER 136 export PGDATABASE=talercheck 137 export PGDATA="$PWD/default/.pg" 138 echo $PWD 139 [ ! -d $PGDATA ] && PGHOST="$PGDATA" pg_ctl initdb -o "-U $PGUSER" 140 141 pg_ctl -o "-p $PGPORT -k $PGDATA" start && createdb talercheck && { 142 trap 'pg_ctl stop && rm -r $PGDATA' EXIT 143 } 144 ''; 145 }; 146 }); 147 }; 148 }