feat(flake): generate nix.flake instead of Docker

...files if a `flake` key exists in a `build.yaml` file.

Refs: OD-37
This commit is contained in:
Oliver Davies 2023-06-27 13:29:10 +01:00
parent 04160ad7de
commit 99ffb87446
3 changed files with 75 additions and 11 deletions

View file

@ -0,0 +1,23 @@
{
inputs = {
devshell.url = "github:numtide/devshell";
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
};
outputs = inputs@{ flake-parts, ... }:
flake-parts.lib.mkFlake { inherit inputs; } {
imports = [ inputs.devshell.flakeModule ];
systems = [ "x86_64-linux" ];
perSystem = { config, self', inputs', pkgs, system, ... }: {
devshells.default = {
packages = with pkgs; [
{% for package in flake.devshell.packages %}
"{{ package }}"
{% endfor %}
];
};
};
};
}

View file

@ -1,5 +1,7 @@
# {{ managedText | raw }}
{% set isFlake = flake is defined %}
default:
@just --list
@ -39,8 +41,12 @@ install *args:
{% if "node" is same as language %}
yarn *args:
{% if isFlake %}
{{ "just _exec yarn {{ args }}" | raw }}
{% else %}
{{ "just _exec node yarn {{ args }}" | raw }}
{% endif %}
{% endif %}
{% if "fractal" is same as type %}
fractal *args:
@ -50,7 +56,7 @@ clean:
rm -fr build
build *args:
just fractal build {{ args }}
{{ "just fractal build {{ args }}" | raw }}
sync: clean build
#!/usr/bin/env bash
@ -99,8 +105,13 @@ test-commit:
{% endif %}
_exec +args:
{% if flake is defined %}
{{ "nix develop --command {{ args }}" | raw }}
{% else %}
{{ "docker compose exec -T {{ args }}" | raw }}
{% endif %}
{% if flake is not defined %}
_run service command *args:
docker compose run \
--entrypoint {{ "{{ command }}"|raw }} \
@ -108,5 +119,6 @@ _run service command *args:
--rm \
-T \
{{ "{{ service }} {{ args }}"|raw }}
{% endif %}
# vim: ft=just