deploy-rs/flake.nix

59 lines
1.8 KiB
Nix
Raw Normal View History

# 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 { };
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";
program = "${self.defaultPackage."${system}"}/bin/deploy";
2020-09-28 20:48:21 +03:00
};
lib = {
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;
destination = "/deploy-rs-activate";
2020-10-09 06:01:01 +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
});
}