summary refs log tree commit diff
path: root/default.nix
blob: 6a3787d4efd7bbac00e9b9bf102c4e72f959eab9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
{ pkgs ? (import ./nix/nixpkgs-pinned.nix { })
, scryptSalt ? null
, apiTokens ? null
}:

let
  gi = pkgs.nix-gitignore;
  lib = pkgs.lib;

  version = import ./nix/version.nix;
  root = ./.;
  sourceName = "flipdot-gschichtler-source";

  rootSrc = builtins.path {
    path = root;
    name = sourceName;
    filter = gi.gitignoreFilter (builtins.readFile ./.gitignore) root;
  };

in

rec {
  warteraum-static = (pkgs.pkgsStatic.callPackage ./nix/warteraum.nix {
    # todo clang?
    redo = pkgs.pkgsStatic.redo-c;
    inherit scryptSalt apiTokens rootSrc sourceName;
    inherit (python3.pkgs) pytest pytest-randomly requests flipdot-gschichtler;
  }).overrideAttrs (old: {
    # musl, static linking
    postPatch = ''
      cat >> ./build_config << EOF
      CFLAGS="\$CFLAGS -static"
      EOF
    '';
  });

  warteraum = pkgs.callPackage ./nix/warteraum.nix {
    stdenv = pkgs.clangStdenv;
    redo = pkgs.redo-c;
    inherit scryptSalt apiTokens rootSrc sourceName;
    inherit (python3.pkgs) pytest pytest-randomly requests flipdot-gschichtler;
  };

  bahnhofshalle =
    let
      nodePackages = import ./bahnhofshalle/node2nix { inherit pkgs; inherit (pkgs) nodejs; };
      nodeDeps = nodePackages.shell.nodeDependencies;
    in pkgs.stdenv.mkDerivation {
      pname = "bahnhofshalle";
      inherit version;

      src = rootSrc + "/bahnhofshalle";

      buildInputs = [ pkgs.nodejs ];

      buildPhase = ''
        export PARCEL_WORKERS=$NIX_BUILD_CORES
        ln -s ${nodeDeps}/lib/node_modules ./node_modules
        export PATH="${nodeDeps}/bin:$PATH"

        parcel build index.html --out-dir="dist" --no-source-maps

        # fail if parcel doesn't produce an output
        if [[ "$(find dist | wc -l)" -le 1 ]]; then
          exit 1
        fi
      '';

      installPhase = ''
        cp -r dist $out
      '';
    };

  anzeigetafel =
    let
      drv = { buildPythonApplication, unifont, flipdots, flipdot-gschichtler }:
        buildPythonApplication {
          pname = "anzeigetafel";
          inherit version;

          src = rootSrc + "/anzeigetafel";

          propagatedBuildInputs = [ flipdots flipdot-gschichtler ];

          doCheck = false;

          patchPhase = ''
            rm flipdots flipdot_gschichtler

            sed -i "s/version = '.*'/version = '${version}'/" setup.py

            sed -i 's|FONT =.*$|FONT = "${unifont}/share/fonts/truetype/unifont.ttf"|' anzeigetafel.py
          '';
        };
    in python3.pkgs.callPackage drv { };


  python3 = pkgs.python3.override {
    packageOverrides = self: super: {
      flipdots = self.callPackage ./nix/python-flipdots.nix {
        inherit rootSrc;
      };

      flipdot-gschichtler = self.callPackage ./nix/python-flipdot-gschichtler.nix {
        inherit rootSrc;
      };
    };
  };
}