Skip to content

Commit b389114

Browse files
committed
feat: sources generation
1 parent 81574c3 commit b389114

26 files changed

+1602
-0
lines changed
Lines changed: 169 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,169 @@
1+
env:
2+
CI_ALLOW_ROOT: '1'
3+
CI_CONFIG: ./ci/config.nix
4+
CI_PLATFORM: gh-actions
5+
jobs:
6+
ci-check:
7+
name: taimihud-datasources check
8+
runs-on: ubuntu-latest
9+
steps:
10+
- id: checkout
11+
name: git clone
12+
uses: actions/checkout@v4
13+
with:
14+
submodules: true
15+
- id: nix-install
16+
name: nix install
17+
uses: arcnmx/ci/actions/nix/install@v0.7
18+
- id: ci-action-build
19+
name: nix build ci.gh-actions.configFile
20+
uses: arcnmx/ci/actions/nix/build@v0.7
21+
with:
22+
attrs: ci.gh-actions.configFile
23+
out-link: .ci/workflow.yml
24+
- id: ci-action-compare
25+
name: gh-actions compare
26+
uses: arcnmx/ci/actions/nix/run@v0.7
27+
with:
28+
args: -u .github/workflows/taimihud-datasources.yml .ci/workflow.yml
29+
attrs: nixpkgs.diffutils
30+
command: diff
31+
main:
32+
name: taimihud-datasources-main
33+
permissions:
34+
contents: write
35+
runs-on: ubuntu-latest
36+
steps:
37+
- id: checkout
38+
name: git clone
39+
uses: actions/checkout@v4
40+
with:
41+
submodules: true
42+
- id: nix-install
43+
name: nix install
44+
uses: arcnmx/ci/actions/nix/install@v0.7
45+
- id: ci-setup
46+
name: nix setup
47+
uses: arcnmx/ci/actions/nix/run@v0.7
48+
with:
49+
attrs: ci.job.main.run.bootstrap
50+
quiet: false
51+
- id: ci-dirty
52+
name: nix test dirty
53+
uses: arcnmx/ci/actions/nix/run@v0.7
54+
with:
55+
attrs: ci.job.main.run.test
56+
command: ci-build-dirty
57+
quiet: false
58+
stdout: ${{ runner.temp }}/ci.build.dirty
59+
- id: ci-test
60+
name: nix test build
61+
uses: arcnmx/ci/actions/nix/run@v0.7
62+
with:
63+
attrs: ci.job.main.run.test
64+
command: ci-build-realise
65+
ignore-exit-code: true
66+
quiet: false
67+
stdin: ${{ runner.temp }}/ci.build.dirty
68+
- env:
69+
CI_EXIT_CODE: ${{ steps.ci-test.outputs.exit-code }}
70+
id: ci-summary
71+
name: nix test results
72+
uses: arcnmx/ci/actions/nix/run@v0.7
73+
with:
74+
attrs: ci.job.main.run.test
75+
command: ci-build-summarise
76+
quiet: false
77+
stdin: ${{ runner.temp }}/ci.build.dirty
78+
stdout: ${{ runner.temp }}/ci.build.cache
79+
- env:
80+
CACHIX_SIGNING_KEY: ${{ secrets.CACHIX_SIGNING_KEY }}
81+
id: ci-cache
82+
if: always()
83+
name: nix test cache
84+
uses: arcnmx/ci/actions/nix/run@v0.7
85+
with:
86+
attrs: ci.job.main.run.test
87+
command: ci-build-cache
88+
quiet: false
89+
stdin: ${{ runner.temp }}/ci.build.cache
90+
- id: artifact-build
91+
name: artifact build
92+
uses: arcnmx/ci/actions/nix/build@v0.7
93+
with:
94+
attrs: config.jobs.main.artifactPackage
95+
file: <ci>
96+
out-link: .ci/artifacts
97+
- id: artifact-upload
98+
name: artifact upload
99+
uses: actions/upload-artifact@v4
100+
with:
101+
name: TaimiHUD-DataSources
102+
path: .ci/artifacts/share/taimihud/sources.toml
103+
- id: release-upload
104+
if: startsWith(github.ref, 'refs/tags/')
105+
name: release
106+
uses: softprops/action-gh-release@v1
107+
with:
108+
files: .ci/artifacts/share/taimihud/sources.toml
109+
updates:
110+
name: taimihud-datasources-updates
111+
runs-on: ubuntu-latest
112+
steps:
113+
- id: checkout
114+
name: git clone
115+
uses: actions/checkout@v4
116+
with:
117+
submodules: true
118+
- id: nix-install
119+
name: nix install
120+
uses: arcnmx/ci/actions/nix/install@v0.7
121+
- id: ci-setup
122+
name: nix setup
123+
uses: arcnmx/ci/actions/nix/run@v0.7
124+
with:
125+
attrs: ci.job.updates.run.bootstrap
126+
quiet: false
127+
- id: ci-dirty
128+
name: nix test dirty
129+
uses: arcnmx/ci/actions/nix/run@v0.7
130+
with:
131+
attrs: ci.job.updates.run.test
132+
command: ci-build-dirty
133+
quiet: false
134+
stdout: ${{ runner.temp }}/ci.build.dirty
135+
- id: ci-test
136+
name: nix test build
137+
uses: arcnmx/ci/actions/nix/run@v0.7
138+
with:
139+
attrs: ci.job.updates.run.test
140+
command: ci-build-realise
141+
ignore-exit-code: true
142+
quiet: false
143+
stdin: ${{ runner.temp }}/ci.build.dirty
144+
- env:
145+
CI_EXIT_CODE: ${{ steps.ci-test.outputs.exit-code }}
146+
id: ci-summary
147+
name: nix test results
148+
uses: arcnmx/ci/actions/nix/run@v0.7
149+
with:
150+
attrs: ci.job.updates.run.test
151+
command: ci-build-summarise
152+
quiet: false
153+
stdin: ${{ runner.temp }}/ci.build.dirty
154+
stdout: ${{ runner.temp }}/ci.build.cache
155+
- env:
156+
CACHIX_SIGNING_KEY: ${{ secrets.CACHIX_SIGNING_KEY }}
157+
id: ci-cache
158+
if: always()
159+
name: nix test cache
160+
uses: arcnmx/ci/actions/nix/run@v0.7
161+
with:
162+
attrs: ci.job.updates.run.test
163+
command: ci-build-cache
164+
quiet: false
165+
stdin: ${{ runner.temp }}/ci.build.cache
166+
name: taimihud-datasources
167+
'on':
168+
- push
169+
- pull_request

README.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
# TaimiHUD data sources
22

33
This is a repository to be used for requests to list data sources for TaimiHUD.
4+
5+
## Updating
6+
7+
(this isn't necessary in order to generate sources.toml to be consumed by TaimiHUD so can be ignored for now)
8+
9+
This should be automated by CI, but some of the manual process will be described here.
10+
11+
```bash
12+
nix build -L .#allUpdateChecks
13+
```

ci/config.nix

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
{ config, pkgs, lib, ... }: with pkgs; with lib; let
2+
datasources = import ../.;
3+
legacyPackages = datasources.legacyPackages.${pkgs.system};
4+
packages = datasources.packages.${pkgs.system};
5+
artifactRoot = ".ci/artifacts";
6+
artifacts = "${artifactRoot}/${sourcesTomlPath}";
7+
release = "${artifactRoot}/${sourcesTomlPath}";
8+
sourcesTomlPath = "share/taimihud/sources.toml";
9+
sourcesToml = linkFarm "taimihud-sources.toml" [
10+
{ name = sourcesTomlPath; path = packages.sourcesToml; }
11+
];
12+
in
13+
{
14+
config = {
15+
name = "taimihud-datasources";
16+
ci.version = "v0.7";
17+
ci.gh-actions = {
18+
enable = true;
19+
export = true;
20+
};
21+
cache.cachix.taimihud = {
22+
enable = true;
23+
publicKey = "taimihud.cachix.org-1:2LByDgq5eUVU2FoeIlMd5NMgUeCDXuuVarS+XbNsIkY=";
24+
signingKey = "nya";
25+
};
26+
#channels.nixpkgs.version = "25.05";
27+
jobs = {
28+
main = {
29+
tasks = {
30+
build.inputs = [ sourcesToml ];
31+
};
32+
artifactPackages = {
33+
sources = sourcesToml;
34+
};
35+
};
36+
updates = {
37+
tasks = {
38+
build.inputs = legacyPackages.updateChecks;
39+
};
40+
};
41+
};
42+
43+
# XXX: symlinks are not followed, see https://github.com/softprops/action-gh-release/issues/182
44+
artifactPackage = mkIf (config.artifactPackages != {}) (runCommand "taimihud-datasource-artifacts" { } (''
45+
mkdir -p $out/share
46+
'' + concatStringsSep "\n" (mapAttrsToList (key: taimi: ''
47+
cp -Lr --no-preserve=mode -t $out ${taimi}/share
48+
'') config.artifactPackages)));
49+
50+
gh-actions = {
51+
jobs = mkIf (config.id != "ci" && config.artifactPackage != null) {
52+
${config.id} = {
53+
permissions = {
54+
contents = "write";
55+
};
56+
step = {
57+
artifact-build = {
58+
order = 1100;
59+
name = "artifact build";
60+
uses = {
61+
# XXX: a very hacky way of getting the runner
62+
inherit (config.gh-actions.jobs.${config.id}.step.ci-setup.uses) owner repo version;
63+
path = "actions/nix/build";
64+
};
65+
"with" = {
66+
file = "<ci>";
67+
attrs = "config.jobs.${config.jobId}.artifactPackage";
68+
out-link = artifactRoot;
69+
};
70+
};
71+
artifact-upload = {
72+
order = 1110;
73+
name = "artifact upload";
74+
uses.path = "actions/upload-artifact@v4";
75+
"with" = {
76+
name = "TaimiHUD-DataSources";
77+
path = artifacts;
78+
};
79+
};
80+
release-upload = {
81+
order = 1111;
82+
name = "release";
83+
"if" = "startsWith(github.ref, 'refs/tags/')";
84+
uses.path = "softprops/action-gh-release@v1";
85+
"with".files = release;
86+
};
87+
};
88+
};
89+
};
90+
};
91+
};
92+
options = {
93+
artifactPackage = mkOption {
94+
type = types.nullOr types.package;
95+
default = null;
96+
};
97+
artifactPackages = mkOption {
98+
type = with types; attrsOf package;
99+
default = {};
100+
};
101+
};
102+
}

config.nix

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
_: {
2+
}

default.nix

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
let
2+
lock = builtins.fromJSON (builtins.readFile ./flake.lock);
3+
flakeCompat = fetchTarball {
4+
url = "https://github.com/edolstra/flake-compat/archive/${lock.nodes.flake-compat.locked.rev}.tar.gz";
5+
sha256 = lock.nodes.flake-compat.locked.narHash;
6+
};
7+
taimiHUD = import flakeCompat {
8+
src = ./.;
9+
};
10+
in
11+
taimiHUD.defaultNix

flake.lock

Lines changed: 78 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)