1
0
Fork 0
mirror of https://github.com/hercules-ci/flake-parts.git synced 2024-12-14 11:47:31 +00:00

Add local tooling and CI wiring without bloating flake.nix

This commit is contained in:
Robert Hensing 2022-05-13 10:10:42 +02:00
parent 1c0f8f3036
commit 140da4067f
8 changed files with 112 additions and 0 deletions

11
ci.nix Normal file
View file

@ -0,0 +1,11 @@
# We're doing things a bit differently because Nix doesn't let us
# split out the dev dependencies and subflakes are broken, let alone "superflakes".
# See dev/README.md
let
flake = import ./dev;
inherit (flake.inputs.nixpkgs) lib;
in {
inherit (flake) herculesCI;
} // {
checks = lib.recurseIntoAttrs flake.checks.${builtins.currentSystem};
}

6
dev/README.md Normal file
View file

@ -0,0 +1,6 @@
# Separate `tools` flake
Wouldn't recommend this pattern normally, but I'm trying to keep
deps low for `flake-modules-core` until we have split dev inputs
that don't carry over to dependent lock files.

9
dev/default.nix Normal file
View file

@ -0,0 +1,9 @@
let
flake = builtins.getFlake (toString ./.);
fmc-lib = import ../lib.nix { inherit (flake.inputs.nixpkgs) lib; };
self = { inherit (flake) inputs; } //
fmc-lib.evalFlakeModule
{ inherit self; }
./flake-module.nix;
in
self.config.flake // { inherit (flake) inputs; }

41
dev/flake-module.nix Normal file
View file

@ -0,0 +1,41 @@
flakeModuleArgs@{ config, lib, ... }:
{
imports = [
];
systems = [ "x86_64-linux" "aarch64-darwin" ];
perSystem = system: { config, self', inputs', pkgs, ... }: {
_module.args.pkgs = inputs'.nixpkgs.legacyPackages;
devShells.default = pkgs.mkShell {
nativeBuildInputs = [ pkgs.nixpkgs-fmt ];
};
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 = {
onPush.default.outputs = {
inherit (config.flake) packages checks;
};
};
# for repl exploration / debug
config.config = config;
options.mySystem = lib.mkOption { default = config.allSystems.${builtins.currentSystem}; };
};
}

27
dev/flake.lock Normal file
View file

@ -0,0 +1,27 @@
{
"nodes": {
"nixpkgs": {
"locked": {
"lastModified": 1652425756,
"narHash": "sha256-3+5j3ZU43oC5PxRfGDQ6xs5sYnypS5GBhVP6uf7PVGM=",
"owner": "hercules-ci",
"repo": "nixpkgs",
"rev": "81a0a8be297a88f338ee0fd90c330cd94b4a55bd",
"type": "github"
},
"original": {
"owner": "hercules-ci",
"ref": "functionTo-properly",
"repo": "nixpkgs",
"type": "github"
}
},
"root": {
"inputs": {
"nixpkgs": "nixpkgs"
}
}
},
"root": "root",
"version": 7
}

13
dev/flake.nix Normal file
View file

@ -0,0 +1,13 @@
{
description = "Dependencies for development purposes";
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";
};
outputs = { self, ... }:
{
};
}

3
dev/repl.nix Normal file
View file

@ -0,0 +1,3 @@
# convenience for loading into nix repl
let self = builtins.getFlake (toString ./.);
in self // { inherit self; }

2
shell.nix Normal file
View file

@ -0,0 +1,2 @@
# non-idiomatic, see tools/README.md
(import ./dev).devShells.${builtins.currentSystem}.default