summaryrefslogtreecommitdiff
path: root/flake.nix
blob: 07c64806ca65bba0c65a5225fd04e50122c39a63 (plain)
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
{
  description = "A basic flake using pyproject.toml project metadata";

  inputs = {
    pyproject-nix = {
      url = "github:nix-community/pyproject.nix";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = { nixpkgs, pyproject-nix, ... }:
    let
      inherit (nixpkgs) lib;

      project = pyproject-nix.lib.project.loadPyproject {
        # Read & unmarshal pyproject.toml relative to this project root.
        # projectRoot is also used to set `src` for renderers such as buildPythonPackage.
        projectRoot = ./.;
      };

      # This example is only using x86_64-linux
      pkgs = nixpkgs.legacyPackages.x86_64-linux;

      python = pkgs.python3;

      # Returns an attribute set that can be passed to `buildPythonPackage`.
      attrs = project.renderers.buildPythonPackage { inherit python; };

      pkg = python.pkgs.buildPythonPackage (attrs // {
          meta = {
            description = "Bornhack schedule web displayer with a teletext theme";
            homepage = "https://text-tv.bornhack.node5.net/";
            changelog = "https://git.node5.net/misc/text-tv.bornhack.node5.net/log/";
            mainProgram = "node5-text-tv";
          };

          postInstall = ''
            echo $src
            echo $out
            cp -r $src/src/static/ $out/${python.sitePackages}
            cp -r $src/src/templates/ $out/${python.sitePackages}
            cp $src/fetch_program.sh $out/bin/node5-text-tv-fetch

            # Make necessary programs available to the scripts PATH
            wrapProgram "$out/bin/node5-text-tv-fetch" \
              --prefix PATH : ${lib.makeBinPath [
                pkgs.coreutils
                pkgs.curl
                pkgs.yq
                pkgs.diffutils
            ]}
          '';
        });
    in
    {
      packages.x86_64-linux.default = pkg;
      apps.x86_64-linux = {
        node5-text-tv = {
          type = "app";
          program = "${pkg}/bin/node5-text-tv";
        };
        node5-text-tv-program = {
          type = "app";
          program = "${pkg}/bin/node5-text-tv-program";
        };
        node5-text-tv-fetch = {
          type = "app";
          program = "${pkg}/bin/node5-text-tv-fetch";
        };
      };
      pythonPath = "${python.pkgs.makePythonPath attrs.dependencies}:${pkg}/${python.sitePackages}";
  };
}