aboutsummaryrefslogtreecommitdiff
path: root/deploy/flake.nix
blob: f77528cb64a502689144d7e1fb697277ab7938e5 (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
{
  inputs = {
    devshell.url = "github:numtide/devshell";
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable?dir=lib";
    secrets = {
      type = "git";
      url = "git+ssh://gitolite@git.immae.eu/perso/Immae/Config/Nix/Nixops/Secrets";
      ref = "master";
    };
    main-flake.url = "path:../flakes";
    main-flake.inputs.secrets.follows = "secrets";
  };
  outputs = inputs@{ self, nixpkgs, main-flake, devshell, ... }: {
    sops-vars-file = inputs.secrets.vars-file;
    devShells.x86_64-linux.default = devshell.legacyPackages.x86_64-linux.mkShell {
      env = [
        { name = "NIX_BUILD_TOP"; value = ""; }
        { name = "SOPS_VARS_FILE"; value = builtins.toString self.sops-vars-file; }
      ];
    };
    colmena =
      let
        nodeFlakes = main-flake.subflakes.nodes;
        hosts = builtins.attrNames nodeFlakes;
        toHostNixpkgs = name: nodeFlakes.${name}.colmena.meta.nixpkgs;
        toHostSpecialArgs = name: nodeFlakes.${name}.colmena.meta.specialArgs;
        toHostColmena = name: nodeFlakes.${name}.colmena.${name};

      in nixpkgs.lib.genAttrs hosts toHostColmena
        // {
        meta = {
          # nixpkgs is required for colmena, but only lib is actually used
          nixpkgs.lib = nixpkgs.lib;
          specialArgs.secrets = main-flake.subflakes.secrets;
          nodeNixpkgs = nixpkgs.lib.genAttrs hosts toHostNixpkgs;
          nodeSpecialArgs = nixpkgs.lib.genAttrs hosts toHostSpecialArgs;
        };
      };
  };
}