Skip to content

Commit

Permalink
improve artifacts and build job dependency flakes for cachix
Browse files Browse the repository at this point in the history
  • Loading branch information
manveru committed Feb 19, 2021
1 parent 766cf8d commit 096fd6b
Show file tree
Hide file tree
Showing 5 changed files with 25 additions and 13 deletions.
1 change: 1 addition & 0 deletions .github/workflows/cache.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,5 @@ jobs:
signingKey: '${{ secrets.CACHIX_SIGNING_KEY }}'
- run: nix run .#checkFmt
- run: nix run .#checkCue
- run: nix run .#buildJobFlakes
- run: nix -L build .#devShellPath
25 changes: 15 additions & 10 deletions deploy.cue
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,24 @@ import (

let fqdn = "vit.iohk.io"

let Namespace = {
_defaultJobs: {
"leader-0": #Jormungandr & {#role: "leader", #index: 0}
"leader-1": #Jormungandr & {#role: "leader", #index: 1}
"leader-2": #Jormungandr & {#role: "leader", #index: 2}
"follower-0": #Jormungandr & {#role: "follower", #index: 0}
"servicing-station": #ServicingStation
}

artifacts: [string]: [string]: {url: string, checksum: string}

Namespace: [Name=_]: {
vars: {
let hex = "[0-9a-f]"
let datacenter = "eu-central-1" | "us-east-2" | "eu-west-1"

namespace: Name
#block0: artifacts[Name].block0
#database: artifacts[Name].database
namespace: string
#domain: string
#vitOpsRev: =~"^\(hex){40}$" | *"c9251b4f3f0b34a22e3968bf28d5a049da120f8f"
Expand All @@ -20,15 +33,7 @@ let Namespace = {
jobs: [string]: types.#stanza.job
}

_defaultJobs: {
"leader-0": #Jormungandr & {#role: "leader", #index: 0}
"leader-1": #Jormungandr & {#role: "leader", #index: 1}
"leader-2": #Jormungandr & {#role: "leader", #index: 2}
"follower-0": #Jormungandr & {#role: "follower", #index: 0}
"servicing-station": #ServicingStation
}

#namespaces: [Name=_]: Namespace & {vars: namespace: Name}
#namespaces: Namespace

#namespaces: {
"catalyst-dryrun": {
Expand Down
2 changes: 1 addition & 1 deletion jormungandr.cue
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
)

#Jormungandr: types.#stanza.job & {
#block0: {url: string, checksum: string}
#role: "leader" | "follower"
#index: uint
#name: "\(#role)-\(#index)"
Expand Down Expand Up @@ -188,7 +189,6 @@ import (
}
}

#block0: artifacts[namespace].block0
artifact: "local/block0.bin": {
source: #block0.url
options: {
Expand Down
6 changes: 6 additions & 0 deletions overlay.nix
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,12 @@ in {
cue vet -c
'';


buildJobFlakes = final.writeShellScriptBin "build_job_flakes.sh" ''
export PATH="$PATH:${lib.makeBinPath (with final; [ cue jq coreutils findutils ])}"
cue eval --out json -e flakes | jq -r '. | unique | sort | .[]' | xargs nix build
'';

cue = final.callPackage ./pkgs/cue.nix { };

debugUtils = with final; [
Expand Down
4 changes: 2 additions & 2 deletions servicing-station.cue
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ import (
)

#ServicingStation: types.#stanza.job & {
#block0: {url: string, checksum: string}
#database: {url: string, checksum: string}
#vitOpsRev: string
#domain: string

Expand Down Expand Up @@ -118,15 +120,13 @@ import (
"""
}

#block0: artifacts[namespace].block0
artifact: "local/block0.bin": {
source: #block0.url
options: {
checksum: #block0.checksum
}
}

#database: artifacts[namespace].database
artifact: "local/database.sqlite3": {
source: #database.url
options: {
Expand Down

0 comments on commit 096fd6b

Please sign in to comment.