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