aboutsummaryrefslogtreecommitdiff
path: root/examples/simple/flake.nix
blob: f53352b9f3beb4eebb4d208a3615fba724a2457c (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
# SPDX-FileCopyrightText: 2020 Serokell <https://serokell.io/>
#
# SPDX-License-Identifier: MPL-2.0

{
  description = "Deploy GNU hello to localhost";

  outputs = { self, nixpkgs }:
    let
      setActivate = base: activate: nixpkgs.legacyPackages.x86_64-linux.symlinkJoin {
        name = ("activatable-" + base.name);
        paths = [
          base
          (nixpkgs.legacyPackages.x86_64-linux.writeTextFile {
            name = base.name + "-activate-path";
            text = ''
              #!${nixpkgs.legacyPackages.x86_64-linux.runtimeShell}
              ${activate}
            '';
            executable = true;
            destination = "/activate";
          })
        ];
      };
    in
    {

      deploy.nodes.example = {
        hostname = "localhost";
        profiles.hello = {
          user = "balsoft";
          path = setActivate nixpkgs.legacyPackages.x86_64-linux.hello "./bin/hello";
        };
      };
      checks = builtins.mapAttrs
        (_: pkgs: {
          jsonschema = pkgs.runCommandNoCC "jsonschema-deploy-simple" { }
            "${pkgs.python3.pkgs.jsonschema}/bin/jsonschema -i ${
          pkgs.writeText "deploy.json" (builtins.toJSON self.deploy)
        } ${../../interface/deploy.json} && touch $out";
        })
        nixpkgs.legacyPackages;
    };
}