Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: implement github-actions mixin and actions-runner ami #9

Merged
merged 4 commits into from
May 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/flake.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
profile:
- gc-fwd
- ecs-node
- actions-runner
steps:
- uses: cachix/install-nix-action@v25
with:
Expand Down
36 changes: 15 additions & 21 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 15 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,21 @@
];
format = "amazon"; # ami
};

actions-runner = inputs.nixos-generators.nixosGenerate {
inherit system;
modules = [
({...}: { amazonImage.sizeMB = 6 * 1024; })
inputs.srvos.nixosModules.server
inputs.srvos.nixosModules.hardware-amazon
./modules/profiles/common.nix
./modules/mixins/github-actions
];
specialArgs = {
diskSize = 6 * 1024; # 6GB
};
format = "amazon"; # ami
};
};
};
};
Expand Down
81 changes: 81 additions & 0 deletions modules/mixins/github-actions/default.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# GitHub Actions runner mixin
# In theory, compatible with x86_64-linux and aarch64-linux.
{ pkgs, ... }:
let
name = "altf4llc-${pkgs.stdenv.system}";
in
{
imports = [
../alloy
../docker
];

nix = {
extraOptions = ''
min-free = ${toString (5 * 1024 * 1024 * 1024)}
max-free = ${toString (5 * 1024 * 1024 * 1024)}
extra-experimental-features = flakes nix-command
'';
settings = {
cores = 4;
trusted-users = [ "root" "github-runner" ];
};
};

users.groups.github-runner = {};
users.users.github-runner = {
group = "github-runner";
extraGroups = [ "docker" ];
isNormalUser = true;
home = "/run/github-runner/${name}";
};

services.github-runners.${name} = {
enable = true;
url = "https://github.com/ALT-F4-LLC";
user = "github-runner";
tokenFile = "/run/keys/github-runner";
serviceOverrides = {
ReadWritePaths = [ "/nix/var/nix/profiles/per-user/" ];
ProtectHome = "tmpfs";
};

extraLabels = [ "nixos" "nix" pkgs.stdenv.system ];

extraPackages = with pkgs; [
awscli2
bashInteractive
bzip2
cachix
coreutils-full
cpio
curl
diffutils
docker
findutils
gawk
getconf
getent
gnugrep
gnupatch
gnused
gnutar
gzip
jq
just
less
mkpasswd
ncurses
netcat
nixos-rebuild
openssh
procps
stdenv.cc.libc
time
util-linux
which
xz
zstd
];
};
}