diff --git a/dev/flake-module.nix b/dev/flake-module.nix index f4fb450..60da698 100644 --- a/dev/flake-module.nix +++ b/dev/flake-module.nix @@ -1,8 +1,9 @@ -flakeModuleArgs@{ config, lib, inputs, ... }: +{ 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} @@ -24,28 +28,25 @@ flakeModuleArgs@{ config, lib, inputs, ... }: }; }; - packages = { - inherit (pkgs.nixosOptionsDoc { inherit (flakeModuleArgs) options; }) - optionsDocBook; - optionsMarkdown = pkgs.runCommand "options-markdown" - { - inherit (config.packages) optionsDocBook; - nativeBuildInputs = [ pkgs.pandoc ]; - } '' - mkdir $out - pandoc \ - --from docbook \ - --to markdown \ - --output $out/options.md \ - $optionsDocBook - ''; - }; }; 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.siteContent; + secretName = "default-netlify"; + siteId = "29a153b1-3698-433c-bc73-62415efb8117"; + productionDeployment = true; + }); + }; }; }; diff --git a/dev/flake.lock b/dev/flake.lock index 28eacfb..2dcc47f 100644 --- a/dev/flake.lock +++ b/dev/flake.lock @@ -15,18 +15,52 @@ "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": 1653476104, + "narHash": "sha256-oVuWUnGQX+fRn/cFoNfbLEUGtsyyXuMLDQFEZ2OxP3k=", + "owner": "hercules-ci", + "repo": "nixpkgs", + "rev": "612e22e67eb6f8d5bfb6288abe515e9da3b96103", + "type": "github" + }, + "original": { + "owner": "hercules-ci", + "ref": "module-docs-update", "repo": "nixpkgs", "type": "github" } @@ -55,7 +89,8 @@ }, "root": { "inputs": { - "nixpkgs": "nixpkgs", + "hercules-ci-effects": "hercules-ci-effects", + "nixpkgs": "nixpkgs_2", "pre-commit-hooks-nix": "pre-commit-hooks-nix" } } diff --git a/dev/flake.nix b/dev/flake.nix index af815b4..1b1d4e1 100644 --- a/dev/flake.nix +++ b/dev/flake.nix @@ -4,10 +4,15 @@ 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"; + + # https://github.com/NixOS/nixpkgs/pull/174460 + # https://github.com/NixOS/nixpkgs/pull/174470 + nixpkgs.url = "github:hercules-ci/nixpkgs/module-docs-update"; 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, ... }: diff --git a/site/flake-module.nix b/site/flake-module.nix new file mode 100644 index 0000000..3543cb4 --- /dev/null +++ b/site/flake-module.nix @@ -0,0 +1,74 @@ +{ ... }: { + perSystem = system: { config, self', inputs', pkgs, lib, ... }: + let + inherit (lib) filter any hasPrefix concatMap removePrefix; + + libNix = import ../lib.nix { inherit lib; }; + eval = libNix.evalFlakeModule { self = { }; } { }; + opts = eval.options; + + filterTransformOptions = { sourceName, sourcePath, baseUrl }: + let sourcePathStr = toString sourcePath; + in + opt: + let declarations = concatMap + (decl: + if hasPrefix sourcePathStr (toString decl) + then + let subpath = removePrefix sourcePathStr (toString decl); + in [{ url = baseUrl + subpath; name = sourceName + subpath; }] + else [ ] + ) + opt.declarations; + in + if declarations == [ ] + then opt // { visible = false; } + else opt // { inherit declarations; }; + + optionsDoc = { sourceName, baseUrl, sourcePath, title }: pkgs.runCommand "${sourceName}-doc" + { + nativeBuildInputs = [ pkgs.libxslt.bin ]; + inputDoc = (pkgs.nixosOptionsDoc { + options = opts; + documentType = "none"; + transformOptions = filterTransformOptions { + inherit sourceName baseUrl sourcePath; + }; + }).optionsDocBook; + inherit title; + } '' + xsltproc --stringparam title "$title" \ + -o $out ${./options.xsl} \ + "$inputDoc" + ''; + in + { + + packages = { + + siteContent = pkgs.stdenvNoCC.mkDerivation { + name = "site"; + nativeBuildInputs = [ pkgs.pandoc pkgs.libxslt.bin ]; + src = lib.cleanSourceWith { + filter = path: type: + path == ./. + || baseNameOf path == "index.html"; + src = ./.; + }; + coreOptions = optionsDoc { + title = "Core Options"; + sourceName = "flake-modules-core"; + baseUrl = "https://github.com/hercules-ci/flake-modules-core/blob/main"; + sourcePath = ../.; + }; + buildPhase = '' + pandoc --verbose --from docbook --to html5 $coreOptions >options.html + ''; + installPhase = '' + mkdir -p $out + cp *.html $out/ + ''; + }; + }; + }; +} diff --git a/site/index.html b/site/index.html new file mode 100644 index 0000000..759f7be --- /dev/null +++ b/site/index.html @@ -0,0 +1,42 @@ + + +
+flake-modules-core+ Compose flakes with the (NixOS) module system. +
+ ++ Testimonials: +
+ ++ yeah.. powerful stuff ++ +
+ I cannot tell you how freeing the flake-modules concept is+ +
+ fucking hell
+ I feel like a hipster using it too +
+ Learn more: +
+ ++ GitHub +
+ + + + + + \ No newline at end of file diff --git a/site/options.xsl b/site/options.xsl new file mode 100644 index 0000000..70f725d --- /dev/null +++ b/site/options.xsl @@ -0,0 +1,53 @@ + +