about summary refs log tree commit diff
path: root/flake.nix
blob: 0cf7d9554f3eff6dd617afce32d1d37d9b30e344 (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
{
  inputs = {
    flake-utils.url = "github:numtide/flake-utils";
    rust = {
      type = "github";
      owner = "oxalica";
      repo = "rust-overlay";
      ref = "master";
      inputs.flake-utils.follows = "flake-utils";
      inputs.nixpkgs.follows = "nixpkgs";
    };
    naersk = {
      type = "github";
      owner = "nmattia";
      repo = "naersk";
      ref = "master";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };
  outputs = { self, nixpkgs, rust, flake-utils, naersk }: let
    supportedSystems = ["aarch64-linux" "x86_64-linux"];
    forAllSystems = f: flake-utils.lib.eachSystem supportedSystems f;
  in forAllSystems (system: let
    pkgs = import nixpkgs {
      localSystem.system = system;
      overlays = [ rust.overlay ];
    };
    rust-bin = pkgs.rust-bin.stable.latest;
    packages = {
      kittybox-micropub = { stdenv, lib, openssl, pkg-config, redis, naersk-lib }:
      naersk-lib.buildPackage {
        pname = "kittybox-micropub";
        version = "0.1.0";

        src = ./.;

        #cargoSha256 = nixpkgs.lib.fakeSha256;
        #cargoHash = "sha256-c862J7qXkrCAA6+gFn/bX5NXrgu/1HtCH1DqOpQePgk=";

        buildInputs = [ openssl ];
        nativeBuildInputs = [ pkg-config ];
        checkInputs = [ redis ];
        doCheck = stdenv.hostPlatform == stdenv.targetPlatform;

        meta = with lib.meta; {
          maintainers = with maintainers; [ vika_nezrimaya ];
          platforms = supportedSystems;
          mainProgram = "kittybox_micropub";
        };
      };
    };
  in {
    packages = let
      naersk-lib = naersk.lib.${system}.override {
        rustc = pkgs.rust-bin.nightly.latest.minimal;
        cargo = pkgs.rust-bin.nightly.latest.minimal;
      };
    in {
      kittybox-micropub = pkgs.callPackage packages.kittybox-micropub { inherit naersk-lib; };
    };
    defaultPackage = self.packages.${system}.kittybox-micropub;

    devShell = pkgs.mkShell {
      name = "rust-dev-shell";
      buildInputs = with pkgs; [ openssl ];
      nativeBuildInputs = with pkgs; [
        pkg-config lld
        rust-bin.default
        rust-bin.rls
        redis
      ];
    };
  });
}