diff --git a/.gitlab-ci.dhall b/.gitlab-ci.dhall new file mode 100644 index 0000000000000000000000000000000000000000..a5367abe8ed5c35d875ddb571073af839ec5d92a --- /dev/null +++ b/.gitlab-ci.dhall @@ -0,0 +1,47 @@ +let Prelude = + env:DHALL_PRELUDE + ? https://raw.githubusercontent.com/dhall-lang/dhall-lang/v20.1.0/Prelude/package.dhall + sha256:26b0ef498663d269e4dc6a82b0ee289ec565d683ef4c00d0ebdd25333a5a3c98 + +let HsSrc = + < FromHackage : { name : Text, version : Text } + | FromGit : + { url : Text, revision : Optional Text, subdir : Optional Text } + > + +let Modifiers = + { Type = { doJailbreak : Bool, doCheck : Bool } + , default = { doJailbreak = True, doCheck = False } + } + +let Attr = λ(a : Type) → { mapKey : Text, mapValue : a } + +let HsPkg = {source : HsSrc, modifiers : Modifiers.Type } + +let Attr + : ∀(x : Type) → Type + = λ(x : Type) → { mapKey : Text, mapValue : x } + +let Step = { script : List Text } + +let toStep + : ∀(id : Text) → ∀(prefix : Text) → ∀(x : Text) → Attr Step + = λ(id : Text) → + λ(prefix : Text) → + λ(x : Text) → + { mapKey = id + , mapValue.script = [ "nix build -L .#${prefix}.${x}" ] + } + +let input = Prelude.Map.keys Text HsPkg ./manifest.dhall + +let packages = + Prelude.List.map + (Text) + (Attr Step) + ( λ(x : Text) → + toStep "Package ${x}" "packages.x86_64-linux" x + ) + (input : List Text) + +in packages diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 3cb0d50f283c76377693b3c2be23904d8de583a7..b4eda7ea91a079ca824ac2388609072ebf09da1b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -4,7 +4,7 @@ stages: generate-flake-ci: stage: generate - script: nix run "git+https://gitlab.homotopic.tech/haskell/flake-to-gitlab-ci" > flake-ci.yml + script: nix run ".#horizon-gen-gitlab-ci" > flake-ci.yml artifacts: paths: - flake-ci.yml diff --git a/flake.nix b/flake.nix index 035c02125b133a6fd34eb8089f4027a7533d83b8..f113f3eb0834cad59e55e32037e2e3365cb4273c 100644 --- a/flake.nix +++ b/flake.nix @@ -19,6 +19,7 @@ && v.type == "derivation" && v.meta.broken == false) hp; + horizon-gen-gitlab-ci = pkgs.writers.writeBashBin "gen-gitlab-ci" "${pkgs.dhall-json}/bin/dhall-to-yaml --file .gitlab-ci.dhall"; in { apps = { @@ -26,6 +27,10 @@ type = "app"; program = "${hp.horizon-gen-nix}/bin/horizon-gen-nix"; }; + horizon-gen-gitlab-ci = { + type = "app"; + program = "${horizon-gen-gitlab-ci}/bin/gen-gitlab-ci"; + }; }; checks = { dhall-format = lint-utils.outputs.linters.x86_64-linux.dhall-format ./.;