Compare commits
7
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4e8a8666b7 | ||
|
|
feae577108 | ||
|
|
ba23f719ab | ||
|
|
1447febbaf | ||
|
|
6b21be0088 | ||
|
|
0279df6b11 | ||
|
|
3a87891486 |
@@ -5,10 +5,6 @@ on:
|
||||
- cron: "0 6 * * 1"
|
||||
workflow_dispatch:
|
||||
|
||||
permissions:
|
||||
contents: read
|
||||
issues: write
|
||||
|
||||
jobs:
|
||||
scan:
|
||||
runs-on: nix
|
||||
@@ -25,7 +21,7 @@ jobs:
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
API: ${{ github.api_url }}
|
||||
REPO: ${{ github.repository }}
|
||||
run: nix run -L .#ci -- upsert-issue vulnix "vulnix: known vulnerabilities in system closure" "$RUNNER_TEMP/issue.md"
|
||||
run: 'nix run -L .#ci -- upsert-issue vulnix "vulnix: known vulnerabilities in system closure" "$RUNNER_TEMP/issue.md"'
|
||||
|
||||
- name: close resolved issue
|
||||
if: steps.scan.outputs.count == '0'
|
||||
|
||||
@@ -1,10 +1,17 @@
|
||||
{ lib, pkgs }:
|
||||
let
|
||||
# vulnix's bundled nix-2.34 broke its own --experimental-features detection
|
||||
nixConf = pkgs.writeText "ci-nix.conf" "experimental-features = nix-command flakes";
|
||||
in
|
||||
# tools must track ci.py's subprocess calls; nix stays ambient (uses the
|
||||
# runner's own nix, not a pinned one).
|
||||
pkgs.writers.writePython3Bin "ci" {
|
||||
flakeIgnore = [ "E501" ];
|
||||
libraries = [ pkgs.python3Packages.subprocess-tee ];
|
||||
makeWrapperArgs = [
|
||||
"--set-default"
|
||||
"NIX_USER_CONF_FILES"
|
||||
(toString nixConf)
|
||||
"--prefix"
|
||||
"PATH"
|
||||
":"
|
||||
|
||||
@@ -18,7 +18,8 @@ def run(*args, **kw):
|
||||
|
||||
|
||||
def nix(*args):
|
||||
return subprocess_tee.run(("nix", "--extra-experimental-features", "nix-command flakes", "-L", *args), check=True, text=True).stdout
|
||||
# tee to stderr - stdout leaks into GITHUB_OUTPUT $() captures
|
||||
return subprocess_tee.run(("nix", "--extra-experimental-features", "nix-command flakes", "-L", *args), check=True, text=True, stdout=sys.stderr).stdout
|
||||
|
||||
|
||||
def git(*args, check=True):
|
||||
@@ -32,8 +33,11 @@ def gitea(method, path, body=None):
|
||||
req.add_header("Authorization", f'token {os.environ["GH_TOKEN"]}')
|
||||
if data is not None:
|
||||
req.add_header("Content-Type", "application/json")
|
||||
try:
|
||||
with urllib.request.urlopen(req) as resp:
|
||||
raw = resp.read()
|
||||
except urllib.error.HTTPError as e:
|
||||
sys.exit(f"gitea {method} {path}: {e.code} {e.reason}\n{e.read().decode()}")
|
||||
return json.loads(raw) if raw else None
|
||||
|
||||
|
||||
|
||||
@@ -61,16 +61,29 @@ let
|
||||
net ? { },
|
||||
resources ? { },
|
||||
traits ? [ ],
|
||||
isolation ? { },
|
||||
}:
|
||||
mkContainer {
|
||||
inherit name;
|
||||
inherit net resources;
|
||||
svc.autoStart = true;
|
||||
isolation.nixDaemon = nixDaemon;
|
||||
isolation = {
|
||||
inherit nixDaemon;
|
||||
}
|
||||
// isolation;
|
||||
traits = [ sshTrait ] ++ traits;
|
||||
packages = with pkgs; [ tmux ] ++ packages;
|
||||
miscProperties = self._sshpiperRegister routingInfo;
|
||||
};
|
||||
|
||||
kvmTrait = {
|
||||
containerConfig =
|
||||
{ pkgs, ... }:
|
||||
{
|
||||
users.users.runner.extraGroups = [ "kvm" ];
|
||||
environment.systemPackages = [ pkgs.qemu_kvm ];
|
||||
};
|
||||
};
|
||||
in
|
||||
{
|
||||
ssh-admin = mkSsh {
|
||||
@@ -121,6 +134,25 @@ in
|
||||
mem = "16G";
|
||||
cpu = 65;
|
||||
};
|
||||
traits = [ kvmTrait ];
|
||||
isolation.allowedDevices = [
|
||||
{
|
||||
node = "/dev/kvm";
|
||||
modifier = "rw";
|
||||
}
|
||||
{
|
||||
node = "/dev/vhost-net";
|
||||
modifier = "rw";
|
||||
}
|
||||
{
|
||||
node = "/dev/net/tun";
|
||||
modifier = "rwm";
|
||||
}
|
||||
];
|
||||
isolation.additionalCapabilities = [
|
||||
"CAP_NET_ADMIN"
|
||||
"CAP_MKNOD"
|
||||
];
|
||||
routingInfo = [
|
||||
{
|
||||
username = "autumn";
|
||||
|
||||
@@ -228,6 +228,17 @@ rec {
|
||||
: systemd-nspawn user namespacing; see `--private-users=` in
|
||||
systemd-nspawn(1). Bind mounts always go through idmapped `--bind`.
|
||||
|
||||
`isolation.allowedDevices`
|
||||
: List of `{ node; modifier; }` host devices to grant the container's
|
||||
cgroup access to; see `containers.<name>.allowedDevices` in the NixOS
|
||||
manual. nspawn bind-mounts a handful of devices (`/dev/kvm`,
|
||||
`/dev/net/tun`, ...) into the container itself once the cgroup allows it -
|
||||
this doesn't need a matching `resources.fs` bind mount.
|
||||
|
||||
`isolation.additionalCapabilities`
|
||||
: Extra Linux capabilities granted to the container; see
|
||||
`containers.<name>.additionalCapabilities` in the NixOS manual.
|
||||
|
||||
`miscProperties`
|
||||
: Arbitrary data attached to the result. Used for cross-container discovery
|
||||
via `collectContainers`.
|
||||
@@ -272,6 +283,8 @@ rec {
|
||||
bindMounts = resources.fs or { };
|
||||
allowsNixDaemon = isolation.nixDaemon or false;
|
||||
privateUsers = isolation.privateUsers or "pick";
|
||||
allowedDevices = isolation.allowedDevices or [ ];
|
||||
additionalCapabilities = isolation.additionalCapabilities or [ ];
|
||||
|
||||
allowInternet = hasInternetAccess access;
|
||||
allBindMounts = builtins.foldl' (acc: t: acc // (t.resources.fs or { })) { } traits // bindMounts;
|
||||
@@ -368,7 +381,12 @@ rec {
|
||||
kind = "nspawn";
|
||||
miscProperties = flattenMiscProp self miscProperties;
|
||||
nixosContainer = {
|
||||
inherit autoStart privateUsers;
|
||||
inherit
|
||||
autoStart
|
||||
privateUsers
|
||||
allowedDevices
|
||||
additionalCapabilities
|
||||
;
|
||||
bindMounts = { };
|
||||
extraFlags = bindMountExtraFlags;
|
||||
privateNetwork = true;
|
||||
|
||||
Reference in New Issue
Block a user