-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathflake.nix
More file actions
104 lines (92 loc) · 2.99 KB
/
flake.nix
File metadata and controls
104 lines (92 loc) · 2.99 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
{
description = "Example using github-actions-nix";
inputs = {
nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
flake-parts.url = "github:hercules-ci/flake-parts";
github-actions-nix.url = "github:synapdeck/github-actions-nix";
};
outputs = inputs @ {flake-parts, ...}:
flake-parts.lib.mkFlake {inherit inputs;} {
systems = ["x86_64-linux" "aarch64-linux" "x86_64-darwin" "aarch64-darwin"];
# Import the github-actions-nix module
imports = [
inputs.github-actions-nix.flakeModules.default
];
perSystem = {
config,
pkgs,
...
}: {
# Enable GitHub Actions generation
githubActions = {
enable = true;
workflows = {
ci = {
name = "CI";
on = {
push.branches = ["main"];
pullRequest.branches = ["main"];
workflowDispatch = {};
};
# Set defaults for all jobs
defaults.job = {
runsOn = "ubuntu-latest";
timeoutMinutes = 30;
};
jobs = {
build = {
name = "Build and Test";
# No need to specify runsOn, it uses the default
steps = [
{
name = "Checkout code";
uses = "actions/checkout@v4";
}
{
name = "Install Nix";
uses = "cachix/install-nix-action@v24";
with_ = {
nix_path = "nixpkgs=channel:nixos-unstable";
};
}
{
name = "Build";
run = "nix build";
}
{
name = "Run tests";
run = "nix flake check";
}
];
};
lint = {
name = "Lint";
# Override the default runner for this specific job
runsOn = "macos-latest";
steps = [
{
name = "Checkout code";
uses = "actions/checkout@v4";
}
{
name = "Install Nix";
uses = "cachix/install-nix-action@v24";
}
{
name = "Check formatting";
run = "nix fmt -- --check .";
}
];
};
};
};
};
};
# Create a package that copies the workflows to .github/workflows
packages.workflows = pkgs.runCommand "copy-workflows" {} ''
mkdir -p $out/.github/workflows
cp -r ${config.githubActions.workflowsDir}/* $out/.github/workflows/
'';
};
};
}