Skip to content

Commit f7328ea

Browse files
committed
netlifyDeploy: add flake-module
1 parent 2beaefd commit f7328ea

File tree

2 files changed

+76
-0
lines changed

2 files changed

+76
-0
lines changed

effects/netlify/flake-module.nix

+75
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
{ config, lib, withSystem, ... }:
2+
let
3+
inherit (lib) mkOption types optionalAttrs mapAttrs;
4+
cfg = config.hercules-ci.netlify-deploy;
5+
in
6+
{
7+
options.hercules-ci.netlify-deploy = mkOption {
8+
type = types.attrsOf (types.submodule {
9+
options = {
10+
enable = lib.mkEnableOption "On-push deployment to Netlify";
11+
12+
siteId = mkOption {
13+
type = types.str;
14+
description = ''
15+
An opaque identifier assigned by Netlify to the website you wish to deploy.
16+
See [docs.hercules-ci.com](https://docs.hercules-ci.com/hercules-ci-effects/reference/nix-functions/netlifydeploy/#param-name) on how to get the right siteId for your website from Netlify.
17+
'';
18+
};
19+
20+
secretName = mkOption {
21+
type = types.str;
22+
description = ''
23+
The secret that will be looked up in [secrets.json](https://docs.hercules-ci.com/hercules-ci-agent/secrets-json).
24+
This secret must hold the `secretField` field, ith a string value that is a Netlify personal access token.
25+
'';
26+
};
27+
28+
secretField = mkOption {
29+
type = types.str;
30+
default = "token";
31+
description = "The name of the field inside the `secretName` secret which holds the Netlify personal access token.";
32+
};
33+
34+
content = mkOption {
35+
type = types.str;
36+
description = ''
37+
Path to the site content, also known as the Publish directory.
38+
This includes files such as netlify.toml, _redirects, and all web resources, like index.html, style sheets, etc.
39+
You will typically put a derivation here.
40+
'';
41+
};
42+
43+
productionDeployment = mkOption {
44+
type = types.bool;
45+
default = false;
46+
description = "Whether this should be production deployment.";
47+
};
48+
49+
extraDeployArgs = mkOption {
50+
type = (types.listOf types.str);
51+
default = [ ];
52+
description = "Extra arguments to pass to the netlify deploy invocation.";
53+
};
54+
55+
effect.system = mkOption {
56+
type = types.str;
57+
default = config.defaultEffectSystem;
58+
defaultText = lib.literalMD "config.defaultEffectSystem";
59+
example = "aarch64-linux";
60+
description = "The [system](https://nixos.org/manual/nix/stable/command-ref/conf-file.html#conf-system) on which to run the website deployment on.";
61+
};
62+
};
63+
});
64+
};
65+
66+
config = {
67+
herculesCI.onPush.default.outputs.effects = {
68+
netlify-deploy = mapAttrs
69+
(name: siteCfg: optionalAttrs (siteCfg.enable) withSystem withSystem cfg.effect.system ({ hci-effects, ... }:
70+
hci-effects.netlifyDeploy { inherit (siteCfg) siteId secretName secretField content productionDeployment extraDeployArgs; }
71+
))
72+
cfg;
73+
};
74+
};
75+
}

flake-module.nix

+1
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
./flake-modules/herculesCI-attribute.nix
55
./flake-modules/herculesCI-helpers.nix
66
./effects/flake-update/flake-module.nix
7+
./effects/netlify/flake-module.nix
78
];
89
}

0 commit comments

Comments
 (0)