aboutsummaryrefslogtreecommitdiff
path: root/flake.nix
blob: 2eb2de1c248c148181079cf3611f2842bebfa4ba (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
{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";
  };

  outputs = { nixpkgs, ... }: let
    system = "x86_64-linux";
    pkgs = import nixpkgs { inherit system; };
  in {
      packages.${system}.default = with pkgs; stdenv.mkDerivation {
        name = "papa_stories";
        src = ./src;
        buildInputs = with pkgs; [
          gnumake pandoc http-server
        ];

        buildPhase = ''
          make BUILD_DIR=$out/build all
        '';

        installPhase = ''
          mkdir -p $out/bin
          cat <<EOF > $out/bin/start-server
          #!/usr/bin/env bash
          ${http-server}/bin/http-server $out/build -p 8001 -d false
          EOF
          chmod +x $out/bin/start-server
        '';
      };

      devShells.${system}.default = pkgs.mkShell {
        buildInputs = with pkgs; [
          pandoc
          ripgrep
          http-server
          shellcheck
          gnumake
        ];
      };
    };
}