aboutsummaryrefslogtreecommitdiff
path: root/flake.nix
blob: 6f6e7138433ed9bebfb2ed7079e479ac356f9edf (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
81
82
83
{
  inputs = {
    nixpkgs.url = "github:nixos/nixpkgs/nixos-25.11";
    nci.url = "github:yusdacra/nix-cargo-integration";
    nci.inputs.nixpkgs.follows = "nixpkgs";
    parts.url = "github:hercules-ci/flake-parts";
    parts.inputs.nixpkgs-lib.follows = "nixpkgs";
  };

  outputs =
    inputs@{
      self,
      parts,
      nci,
      ...
    }:
    parts.lib.mkFlake { inherit inputs; } (
      { moduleWithSystem, withSystem, ... }:
      {
        systems = [
          "x86_64-linux"
          "aarch64-linux"
        ];
        imports = [ nci.flakeModule ];

        flake = {
          # nixosModules.default = flake-parts-lib.importApply ./nix/nixos-module.nix { localFlake = self; inherit withSystem; };
          nixosModules.default = moduleWithSystem (
            perSystem@{ config }: # NOTE: only explicit params will be in perSystem
            nixos@{ ... }:
            {
              services.catinator.package = perSystem.config.packages.default;
              imports = [ ./nix/nixos-module.nix ];
            }
          );
        };

        perSystem =
          {
            pkgs,
            config,
            lib,
            ...
          }:
          let
            # shorthand for accessing this crate's outputs
            # you can access crate outputs under `config.nci.outputs.<crate name>` (see documentation)
            crateOutputs = config.nci.outputs."catinator";
          in
          {
            nci = {
              projects."catinator".path = ./.;
              crates."catinator" =
                let
                  mkDerivation = {
                    nativeBuildInputs = [ pkgs.file.dev ];
                  };
                in
                {
                  drvConfig = {
                    inherit mkDerivation;
                  };
                  depsDrvConfig = {
                    inherit mkDerivation;
                  };
                };

              toolchainConfig = {
                channel = "stable";
                targets = [ "x86_64-unknown-linux-musl" ];
                components = [
                  "rustfmt"
                  "rust-src"
                ];
              };
            };

            devShells.default = crateOutputs.devShell;
            packages.default = crateOutputs.packages.release;
          };
      }
    );
}