Skip to content

Commit

Permalink
feat: implement github-actions mixin and actions-runner ami (#9)
Browse files Browse the repository at this point in the history
* feat: implement github-actions mixin and actions-runner ami

* fix: bump disk size for actions-runner to 6gb

* fix(actions-runner): increase build disk size

* feat(actions-runner): add nix labels
  • Loading branch information
hbjydev authored May 2, 2024
1 parent 8309e0d commit ec150d5
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 21 deletions.
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
];
};
}

0 comments on commit ec150d5

Please sign in to comment.