1
0
Fork 0
mirror of https://github.com/hercules-ci/flake-parts.git synced 2025-04-08 18:14:00 +00:00

Deploy basic site with netlify

This commit is contained in:
Robert Hensing 2022-05-18 00:41:17 +02:00
parent 0263a393a2
commit 13fc0c610b
5 changed files with 126 additions and 9 deletions

View file

@ -3,6 +3,7 @@ flakeModuleArgs@{ config, lib, inputs, ... }:
{
imports = [
inputs.pre-commit-hooks-nix.flakeModule
../site/flake-module.nix
];
systems = [ "x86_64-linux" "aarch64-darwin" ];
perSystem = system: { config, self', inputs', pkgs, ... }: {
@ -11,6 +12,9 @@ flakeModuleArgs@{ config, lib, inputs, ... }:
nativeBuildInputs = [
pkgs.nixpkgs-fmt
pkgs.pre-commit
pkgs.hci
pkgs.netlify-cli
pkgs.pandoc
];
shellHook = ''
${config.pre-commit.installationScript}
@ -43,9 +47,22 @@ flakeModuleArgs@{ config, lib, inputs, ... }:
};
flake = {
options.herculesCI = lib.mkOption { type = lib.types.raw; };
config.herculesCI = {
config.herculesCI = { branch, ... }: {
onPush.default.outputs = {
inherit (config.flake) packages checks;
effects =
let
pkgs = inputs.nixpkgs.legacyPackages.x86_64-linux;
effects = inputs.hercules-ci-effects.lib.withPkgs pkgs;
in
{
netlifyDeploy = effects.runIf (branch == "main") (effects.netlifyDeploy {
content = config.flake.packages.x86_64-linux.websitePackage;
secretName = "default-netlify";
siteId = "29a153b1-3698-433c-bc73-62415efb8117";
productionDeployment = true;
});
};
};
};

48
dev/flake.lock generated
View file

@ -15,18 +15,51 @@
"type": "github"
}
},
"nixpkgs": {
"hercules-ci-effects": {
"inputs": {
"nixpkgs": "nixpkgs"
},
"locked": {
"lastModified": 1652734403,
"narHash": "sha256-pIp7mRuYQd4JY2Ih4QaDjKVFgu7f1yHRRAvpb/rU9Mg=",
"lastModified": 1653415319,
"narHash": "sha256-h+YUX7ZYujf73KL1R07LsEnhV7uV8oxSKEhH4bDj0Jc=",
"owner": "hercules-ci",
"repo": "nixpkgs",
"rev": "0b02135d3bdf49f9154f60e7a4c9d54d5e0ee70d",
"repo": "hercules-ci-effects",
"rev": "1f904af1824e7393702daaf40a8fed56ebead0d7",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"ref": "functionTo-properly",
"repo": "hercules-ci-effects",
"type": "github"
}
},
"nixpkgs": {
"locked": {
"lastModified": 1647297614,
"narHash": "sha256-ulGq3W5XsrBMU/u5k9d4oPy65pQTkunR4HKKtTq0RwY=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "73ad5f9e147c0d2a2061f1d4bd91e05078dc0b58",
"type": "github"
},
"original": {
"owner": "NixOS",
"ref": "nixos-unstable",
"repo": "nixpkgs",
"type": "github"
}
},
"nixpkgs_2": {
"locked": {
"lastModified": 1653465299,
"narHash": "sha256-+1jyM4dsppYFgiJf+VkAAS/l5iF0y5J7D2l1fLzT8DA=",
"owner": "NixOS",
"repo": "nixpkgs",
"rev": "5862243e1ab8c0a19cb448f523c27c167dcd826b",
"type": "github"
},
"original": {
"owner": "NixOS",
"repo": "nixpkgs",
"type": "github"
}
@ -55,7 +88,8 @@
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs",
"hercules-ci-effects": "hercules-ci-effects",
"nixpkgs": "nixpkgs_2",
"pre-commit-hooks-nix": "pre-commit-hooks-nix"
}
}

View file

@ -4,10 +4,12 @@
inputs = {
# Flakes don't give us a good way to depend on .., so we don't.
# This has drastic consequences of course.
nixpkgs.url = "github:hercules-ci/nixpkgs/functionTo-properly";
nixpkgs.url = "github:NixOS/nixpkgs";
pre-commit-hooks-nix.url = "github:hercules-ci/pre-commit-hooks.nix/flakeModule";
pre-commit-hooks-nix.inputs.nixpkgs.follows = "nixpkgs";
hercules-ci-effects.url = "github:hercules-ci/hercules-ci-effects";
};
outputs = { self, ... }:

22
site/flake-module.nix Normal file
View file

@ -0,0 +1,22 @@
{ ... }: {
perSystem = system: { config, self', inputs', pkgs, lib, ... }: {
packages.websitePackage = pkgs.stdenvNoCC.mkDerivation {
name = "site";
nativeBuildInputs = [ pkgs.pandoc ];
src = lib.cleanSourceWith {
filter = path: type:
path == ./.
|| baseNameOf path == "index.html";
src = ./.;
};
buildPhase = ''
pandoc --from docbook --to html5 \
${config.packages.optionsDocBook} >options.html
'';
installPhase = ''
mkdir -p $out
cp *.html $out/
'';
};
};
}

42
site/index.html Normal file
View file

@ -0,0 +1,42 @@
<html>
<head>
<title>flake-modules-core</title>
</head>
<body>
<h1><code>flake-modules-core</code></h1>
<p>
Compose flakes with the (NixOS) module system.
</p>
<p>
Testimonials:
</p>
<blockquote>
yeah.. powerful stuff
</blockquote>
<blockquote>
I cannot tell you how freeing the flake-modules concept is<br/>
fucking hell<br/>
I feel like a hipster using it too
</blockquote>
<p>
Learn more:
</p>
<p>
<a href="https://github.com/hercules-ci/flake-modules-core">GitHub</a>
</p>
<p>
<a href="./options.html">Options Reference</a>
</p>
</body>
</html>