summary refs log tree commit diff
path: root/flake.nix
blob: 7fda70010ead97b7a5e63b6f2d9bc9c2cdb3c88c (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
{
  description = "Logic table generator on the command line.";

  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-unstable";

    flake-parts.url = "github:hercules-ci/flake-parts";

    nci = {
      inputs.nixpkgs.follows = "nixpkgs";
      url = "github:yusdacra/nix-cargo-integration";
    };

    treefmt-nix.url = "github:numtide/treefmt-nix";
  };

  outputs = inputs @ {
    self,
    flake-parts,
    nixpkgs,
    nci,
    treefmt-nix,
  }:
    flake-parts.lib.mkFlake {inherit inputs;} {
      imports = [
        nci.flakeModule
        treefmt-nix.flakeModule
      ];

      systems = [
        "x86_64-linux"
      ];

      perSystem = {
        config,
        pkgs,
        system,
        lib,
        ...
      }: let
        crateOutputs = config.nci.outputs."mos6502";
      in {
        nci.projects.mos6502.path = ./.;

        # configure crates
        nci.crates.mos6502 = {
          depsDrvConfig.env = {
            RUSTFLAGS = "-A missing-docs";
          };
        };

        treefmt = {
          projectRootFile = "flake.nix";
          programs = {
            rustfmt = {
              enable = true;
              package = config.nci.toolchains.shell;
            };
            taplo.enable = true;
          };
        };

        devShells.default = crateOutputs.devShell.overrideAttrs (_: {
          buildInputs = with pkgs; [
            bacon
            gcc
            mold
          ];
        });

        packages.default = crateOutputs.packages.release;
      };
    };
}