summaryrefslogtreecommitdiff
path: root/flake.nix
blob: a61750896dbfd596f929582140fdc3a7ebb7ce24 (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
{
  description = "a unixy rss/atom reader";

  outputs = { self, nixpkgs }:
    let
      supportedSystems = [ "x86_64-linux" "aarch64-darwin" "x86_64-darwin" ];
      forAllSystems = nixpkgs.lib.genAttrs supportedSystems;
      nixpkgsFor = forAllSystems (system: import nixpkgs {
        inherit system;
        overlays = [ self.overlays.default ];
      });
    in
    {

      overlays.default = final: prev: {
        syn =
          let
            packageMeta = (final.lib.importTOML ./Cargo.toml).package;
          in
          final.rustPlatform.buildRustPackage {
            pname = packageMeta.name;
            inherit (packageMeta) version;
            src = self;
            nativeBuildInputs = [ final.pkg-config ];
            buildInputs = [ final.openssl ];
            cargoLock.lockFile = ./Cargo.lock;
          };
      };

      packages = forAllSystems (system: {
        inherit (nixpkgsFor."${system}") syn;
      });

      defaultPackage = forAllSystems (system: self.packages."${system}".syn);

      devShell = forAllSystems (system:
        let
          pkgs = nixpkgsFor."${ system}";
        in
        pkgs.mkShell {
          nativeBuildInputs = [
            pkgs.rustc
            pkgs.cargo
            pkgs.rustfmt
            pkgs.rust-analyzer
            pkgs.cargo-watch
          ];
          RUST_BACKTRACE = 1;
        }
      );

    };
}