feat: add integration test for contribution workflow

This commit is contained in:
DavHau 2022-11-15 23:07:40 +01:00
parent d76408ae63
commit 070f24d316
2 changed files with 81 additions and 0 deletions

View File

@ -0,0 +1,48 @@
{
lib,
pkgs,
utils,
self,
...
}: let
l = lib // builtins;
in
utils.writePureShellScript
(with pkgs; [
coreutils
nix
])
''
# create working dirs
mkdir $TMPDIR/{dream2nix,test-flake}
# checkout dream2nix source code
cd $TMPDIR/dream2nix
cp -r ${self}/* .
chmod -R +w .
# define names for new modules
subsystem="my-subsystem"
pureTranslator="my-pure-translator"
impureTranslator="my-impure-translator"
builder="my-builder"
# initialize pure translator
mkdir -p ./src/subsystems/$subsystem/translators/$pureTranslator
cp ./src/templates/translators/pure.nix ./src/subsystems/$subsystem/translators/$pureTranslator/default.nix
# initialize builder
mkdir -p ./src/subsystems/$subsystem/builders/$builder
cp ./src/templates/builders/default.nix ./src/subsystems/$subsystem/builders/$builder/default.nix
# initialize flake for building a test package
cp ${./my-flake.nix} $TMPDIR/test-flake/flake.nix
cd $TMPDIR/test-flake
nix flake lock --override-input dream2nix $TMPDIR/dream2nix --show-trace
# test `nix flake show`
nix flake show --show-trace
# build test package
nix build .#default --show-trace
''

View File

@ -0,0 +1,33 @@
{
inputs = {
dream2nix.url = "github:nix-community/dream2nix";
nixpkgs.follows = "dream2nix/nixpkgs";
flake-parts.url = "github:hercules-ci/flake-parts";
src.url = "github:nmattia/niv";
src.flake = false;
};
outputs = {
self,
dream2nix,
flake-parts,
src,
...
}:
flake-parts.lib.mkFlake {inherit self;} {
systems = ["x86_64-linux"];
imports = [dream2nix.flakeModuleBeta];
perSystem = {config, ...}: {
# define an input for dream2nix to generate outputs for
dream2nix.inputs."niv" = {
source = src;
projects.my-project = {
name = "my-project";
subsytem = "my-subsystem";
translator = "my-pure-translator";
};
};
};
};
}