aboutsummaryrefslogtreecommitdiff
path: root/flake.nix
blob: bbfd8f09dd8f26f3b998faad0c01848cdfecd5a0 (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
# Author: Euxane TRAN-GIRARD
# Licence: EUPL-1.2

{
  inputs = {
    # For Nim 2.2.0 (necessary for generics, also better C compiler on master)
    # https://github.com/NixOS/nixpkgs/pull/346578
    nixpkgs.url = "github:NixOS/nixpkgs/7b2fbd2";
    flake-utils.url = "github:numtide/flake-utils";
    flaky-utils.url = "git+https://cgit.euxane.net/flaky-utils";
  };

  outputs = { self, nixpkgs, flake-utils, flaky-utils }:
  flake-utils.lib.eachDefaultSystem (system: let
    pkgs = import nixpkgs { inherit system; };
  in {
    devShell = flaky-utils.lib.mkDevShell {
      inherit pkgs;

      tools = with pkgs; [
        nim
        nrpl
        nim-atlas
        nimble
        nimlangserver
        nim_lk
      ];

      prePrompt = ''
        echo "<C-d> to exit this development shell."
      '';

      shell = null;
    };

    packages.default = pkgs.stdenv.mkDerivation (final: {
      pname = "tickwatch";
      meta.mainProgram = final.pname;
      version = "SNAPSHOT";
      src = ./.;
      buildInputs = [ pkgs.nim ];
      buildPhase = ''
        export VERSION=${final.version}
        nim c --nimcache:. -d:release main.nim
      '';
      doCheck = true;
      checkPhase = ''
        nim r --nimcache:. -d:test main.nim
      '';
      installPhase = ''
        mkdir -p $out/bin
        mv main $out/bin/${final.meta.mainProgram}
      '';
    });
  });
}