2020-09-30 01:10:06 +03:00
|
|
|
# SPDX-FileCopyrightText: 2020 Serokell <https://serokell.io/>
|
|
|
|
#
|
|
|
|
# SPDX-License-Identifier: MPL-2.0
|
|
|
|
|
2020-09-28 20:48:21 +03:00
|
|
|
{
|
2020-10-09 06:01:01 +03:00
|
|
|
description = "A Simple multi-profile Nix-flake deploy tool.";
|
|
|
|
|
2020-09-28 20:48:21 +03:00
|
|
|
inputs = {
|
|
|
|
nixpkgs.url = "github:NixOS/nixpkgs/nixpkgs-unstable";
|
2020-10-09 06:01:01 +03:00
|
|
|
naersk = {
|
|
|
|
url = "github:nmattia/naersk/master";
|
|
|
|
inputs.nixpkgs.follows = "nixpkgs";
|
|
|
|
};
|
2020-09-28 20:48:21 +03:00
|
|
|
utils.url = "github:numtide/flake-utils";
|
2020-10-09 06:01:01 +03:00
|
|
|
flake-compat = {
|
|
|
|
url = "github:edolstra/flake-compat";
|
|
|
|
flake = false;
|
|
|
|
};
|
2020-09-28 20:48:21 +03:00
|
|
|
};
|
|
|
|
|
2020-10-09 06:01:01 +03:00
|
|
|
outputs = { self, nixpkgs, utils, naersk, ... }:
|
2020-09-28 20:48:21 +03:00
|
|
|
utils.lib.eachDefaultSystem (system:
|
|
|
|
let
|
|
|
|
pkgs = import nixpkgs { inherit system; };
|
|
|
|
naersk-lib = pkgs.callPackage naersk { };
|
2020-10-06 05:46:28 +03:00
|
|
|
in
|
|
|
|
{
|
2020-10-09 06:01:01 +03:00
|
|
|
defaultPackage = self.packages."${system}".deploy-rs;
|
|
|
|
packages.deploy-rs = naersk-lib.buildPackage ./.;
|
2020-09-28 20:48:21 +03:00
|
|
|
|
2020-10-09 06:01:01 +03:00
|
|
|
defaultApp = self.apps."${system}".deploy-rs;
|
|
|
|
apps.deploy-rs = {
|
2020-09-28 20:48:21 +03:00
|
|
|
type = "app";
|
2020-09-29 01:45:53 +03:00
|
|
|
program = "${self.defaultPackage."${system}"}/bin/deploy";
|
2020-09-28 20:48:21 +03:00
|
|
|
};
|
2020-10-06 05:46:28 +03:00
|
|
|
|
|
|
|
lib = {
|
2020-10-12 01:08:02 +03:00
|
|
|
setActivate = base: activate: pkgs.buildEnv {
|
2020-10-09 06:01:01 +03:00
|
|
|
name = ("activatable-" + base.name);
|
|
|
|
paths = [
|
|
|
|
base
|
|
|
|
(pkgs.writeTextFile {
|
|
|
|
name = base.name + "-activate-path";
|
|
|
|
text = ''
|
|
|
|
#!${pkgs.runtimeShell}
|
|
|
|
${activate}
|
|
|
|
'';
|
|
|
|
executable = true;
|
2020-10-12 01:08:02 +03:00
|
|
|
destination = "/deploy-rs-activate";
|
2020-10-09 06:01:01 +03:00
|
|
|
})
|
|
|
|
];
|
|
|
|
};
|
2020-10-06 05:46:28 +03:00
|
|
|
|
|
|
|
checkSchema = deploy: pkgs.runCommandNoCC "jsonschema-deploy-system" { }
|
|
|
|
"${pkgs.python3.pkgs.jsonschema}/bin/jsonschema -i ${pkgs.writeText "deploy.json" (builtins.toJSON deploy)} ${./interface/deploy.json} && touch $out";
|
|
|
|
};
|
2020-09-28 20:48:21 +03:00
|
|
|
});
|
|
|
|
}
|