mirror of
https://github.com/nix-community/dream2nix.git
synced 2024-11-26 22:31:39 +03:00
feat: add integration test for contribution workflow
This commit is contained in:
parent
d76408ae63
commit
070f24d316
48
tests/integration/tests/contribute/default.nix
Normal file
48
tests/integration/tests/contribute/default.nix
Normal 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
|
||||
''
|
33
tests/integration/tests/contribute/my-flake.nix
Normal file
33
tests/integration/tests/contribute/my-flake.nix
Normal 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";
|
||||
};
|
||||
};
|
||||
};
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user