summaryrefslogtreecommitdiffstats
path: root/flake.nix
blob: 19637d9a6273fa351ca403d29a1a98d16f7d3b28 (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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
{

  inputs = {
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    devenv.url = "github:cachix/devenv";
    nix2container.url = "github:nlewo/nix2container";
    nix2container.inputs.nixpkgs.follows = "nixpkgs";
    mk-shell-bin.url = "github:rrbutani/nix-mk-shell-bin";
    treefmt-nix.url = "github:numtide/treefmt-nix";
    mission-control.url = "github:Platonic-Systems/mission-control";
    flake-root.url = "github:srid/flake-root";
    fenix = {
      url = "github:nix-community/fenix";
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };

  outputs = inputs@{ flake-parts, nixpkgs, ... }:
    flake-parts.lib.mkFlake { inherit inputs; } {
      imports = [
        inputs.devenv.flakeModule
        inputs.treefmt-nix.flakeModule
        inputs.flake-root.flakeModule
        inputs.mission-control.flakeModule
        inputs.flake-parts.flakeModules.easyOverlay
      ];
      systems = nixpkgs.lib.systems.flakeExposed;
      perSystem = { config, self', inputs', pkgs, system, final, ... }: {
        treefmt.config = {
          inherit (config.flake-root) projectRootFile;
          programs.rustfmt.enable = true;
          package = pkgs.treefmt;
          programs.nixpkgs-fmt.enable = true;
          programs.prettier.enable = true;
          programs.taplo.enable = true;
          programs.beautysh = {
            enable = true;
            indent_size = 4;
          };
        };
        mission-control.scripts = {
          fmt = {
            description = "Format source code";
            exec = config.treefmt.build.wrapper;
            category = "Dev Tools";
          };
          run = {
            description = "Run app";
            exec = "cargo run";
            category = "Dev Tools";
          };
        };

        packages.default = pkgs.callPackage ./utils/nix { };
        overlayAttrs = {
          inherit (config.packages) joshuto;
        };
        packages.joshuto = pkgs.callPackage ./utils/nix { };

        devShells.default = pkgs.mkShell {
          inputsFrom = [
            config.flake-root.devShell
            config.mission-control.devShell
            self'.devShells.my-shell
          ];
        };
        devenv.shells.my-shell = {
          languages.rust = {
            enable = true;
            version = "latest";
          };
          packages = [
          ];
          enterShell = ''
            echo $'\e[1;32mWelcom to joshuto project~\e[0m'
          '';
        };
      };
    };
}