Skip to content

Commit

Permalink
Merge pull request #5 from imincik/add-basic-process-test
Browse files Browse the repository at this point in the history
tests: add basic-process example test
  • Loading branch information
imincik authored Apr 4, 2024
2 parents 9c8c84c + 43f20ca commit d8bc1c4
Show file tree
Hide file tree
Showing 6 changed files with 92 additions and 1 deletion.
1 change: 1 addition & 0 deletions .github/workflows/test-examples.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ jobs:
matrix:
example:
- basic
- basic-process
os:
- ubuntu-22.04
# - macos-11
Expand Down
53 changes: 53 additions & 0 deletions examples/basic-process/flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
{
description = "Geospatial NIX";

nixConfig = {
extra-substituters = [
"https://geonix.cachix.org"
"https://devenv.cachix.org"
];
extra-trusted-public-keys = [
"geonix.cachix.org-1:iyhIXkDLYLXbMhL3X3qOLBtRF8HEyAbhPXjjPeYsCl0="
"devenv.cachix.org-1:w1cLUi8dv3hnoSPGAuibQv+f9TZLr6cv/Hm9XgU50cw="
];
bash-prompt = "\\[\\033[1m\\][geonix]\\[\\033\[m\\]\\040\\w >\\040";
};

inputs = {
geonix.url = "github:imincik/geospatial-nix";
nixpkgs.follows = "geonix/nixpkgs";
devenv = {
url = "path:../../.";
inputs.nixpkgs.follows = "geonix/nixpkgs";
};
nix2container = {
url = "github:nlewo/nix2container";
inputs.nixpkgs.follows = "geonix/nixpkgs";
};
mk-shell-bin.url = "github:rrbutani/nix-mk-shell-bin";
};

outputs = inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {

imports = [
inputs.devenv.flakeModule
];

systems = [ "x86_64-linux" ];

perSystem = { config, self', inputs', pkgs, system, ... }: {

devenv.shells.default = {
imports = [
inputs.geonix.modules
./geonix.nix
];
};

packages.geonixcli = inputs.geonix.packages.${system}.geonixcli;
};

flake = { };
};
}
14 changes: 14 additions & 0 deletions examples/basic-process/geonix.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#
# Use https://geospatial-nix.today to add more configuration.
#

{ inputs, config, lib, pkgs, ... }:

let
geopkgs = inputs.geonix.packages.${pkgs.system};

in {
processes.test.exec = ''
echo "Running test service"
'';
}
9 changes: 9 additions & 0 deletions examples/basic-process/test.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
#!/usr/bin/env bash

set -euo pipefail

source ../common.sh

assemble_devenv
procfilescript=$(nix "${NIX_FLAGS[@]}" build --impure --no-link --print-out-paths .#devenv-up)
exec $procfilescript
4 changes: 3 additions & 1 deletion examples/basic/test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,9 @@

set -euo pipefail

source ../common.sh

nix flake check --impure
nix flake show --impure

nix develop --impure --accept-flake-config --command gdalinfo --version | grep GDAL
nix "${NIX_FLAGS[@]}" develop --impure --command gdalinfo --version | grep GDAL
12 changes: 12 additions & 0 deletions examples/common.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
NIX_FLAGS=( --accept-flake-config --no-warn-dirty --extra-experimental-features nix-command --extra-experimental-features flakes )


function assemble_devenv {
# see: https://github.com/cachix/devenv/blob/405a4c6a3fecfd2a7fb37cc13f4e760658e522e6/src/devenv.nix#L29

DEVENV_DIR="$(pwd)/.devenv"
DEVENV_STATE="$DEVENV_DIR"/state
export DEVENV_DIR
export DEVENV_STATE
}

0 comments on commit d8bc1c4

Please sign in to comment.