Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
esselius committed Jul 14, 2024
1 parent f8228bf commit de77c3f
Show file tree
Hide file tree
Showing 4 changed files with 115 additions and 5 deletions.
66 changes: 66 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
name: CI

on:
pull_request:
branches:
- main

jobs:
generate-matrix:
name: Generate job matrices
runs-on: ubuntu-latest
outputs:
darwin-configurations: ${{ steps.x.outputs.matrix }}
darwin-modules: ${{ steps.x.outputs.matrix }}
home-configurations: ${{ steps.x.outputs.matrix }}
home-modules: ${{ steps.x.outputs.matrix }}
nixos-configurations: ${{ steps.x.outputs.matrix }}
nixos-modules: ${{ steps.x.outputs.matrix }}
nixos-tests: ${{ steps.x.outputs.matrix }}
steps:
- name: Get changes
id: changed-files
uses: tj-actions/changed-files@v44
with:
dir_names_max_depth: 1
dir_names: true
matrix: true

# nix

# - name: Generate matrix | Infrastructure
# id: neo-infrastructure
# uses: hellofresh/action-changed-files@v3
# with:
# pattern: infrastructure/(?P<environment>[^/]+)
# default-patterns: |
# terraform-modules
# deploy.sh

# - name: Generate matrix | Library
# id: neo-library
# uses: hellofresh/action-changed-files@v3
# with:
# pattern: library/(?P<lib>(?!common)[^/]+)
# default-patterns: |
# library/common

# infrastructure:
# runs-on: ubuntu-latest
# needs: [ generate-matrix ] # don't forget this!
# strategy:
# matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix-infrastructure) }}
# if: ${{ fromJson(needs.generate-matrix.outputs.matrix-infrastructure).include[0] }} # skip if the matrix is empty!
# steps:
# - name: Deploy infrastructure
# run: echo "Deploying ${{ matrix.environment }}"

# build:
# runs-on: ubuntu-latest
# needs: [ generate-matrix ]
# strategy:
# matrix: ${{ fromJson(needs.generate-matrix.outputs.matrix-build) }}
# if: ${{ fromJson(needs.generate-matrix.outputs.matrix-build).include[0] }}
# steps:
# - name: Building library
# run: echo "Building ${{ matrix.lib }}"
44 changes: 44 additions & 0 deletions dag.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
import os
import re

import networkx as nx

moduleSystems = ["darwin", "home", "nixos"]
moduleTypes = ["configurations", "modules", "tests"]
ezModulePattern = re.compile(r"ezModules.([a-zA-Z-1-9]+)")
inputsModulePattern = re.compile(r"[^-]inputs.([a-zA-Z-1-9]+)")

G = nx.Graph()

for ms in moduleSystems:
for mt in moduleTypes:
folder = f"{ms}-{mt}"

if os.path.exists(folder):
for fd in os.scandir(folder):
module = folder + "/" + fd.name.removesuffix(".nix")

if mt == "configurations":
defaultModule = f"{ms}-modules/default"
G.add_edge(module, defaultModule)

if fd.name.endswith(".nix"):
with open(fd, encoding="utf-8") as f:
data = f.read()
for match in re.finditer(ezModulePattern, data):
dep = f"{ms}-modules/{match.group(1)}"
G.add_edge(module, dep)

for match in re.finditer(inputsModulePattern, data):
dep = f"inputs/{match.group(1)}"
G.add_edge(module, dep)
else:
for sub_fd in os.scandir(fd.path):
with open(sub_fd, encoding="utf-8") as f:
data = f.read()
for match in re.finditer(ezModulePattern, data):
dep = f"{ms}-modules/{match.group(1)}"
G.add_edge(module, dep)

print(G.nodes)
print(nx.shortest_path(G, "darwin-configurations/Fox", "inputs/nixpkgs-unstable"))
4 changes: 2 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@
};
perSystem = { pkgs, ... }: {
nixosTests = {
path = ./tests;
path = ./nixos-tests;
args = {
inherit inputs;
myModules = self.nixosModules;
ezModules = self.nixosModules;
};
env = {
PLAYWRIGHT_BROWSERS_PATH = pkgs.playwright-driver.browsers;
Expand Down
6 changes: 3 additions & 3 deletions tests/monitoring-auth.nix → nixos-tests/monitoring-auth.nix
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{ myModules, inputs, ... }:
{ ezModules, inputs, ... }:

{
name = "monitoring-auth";
Expand All @@ -13,8 +13,8 @@
imports = [
inputs.authentik-nix.nixosModules.default

myModules.authentik-blueprints
myModules.profiles
ezModules.authentik-blueprints
ezModules.profiles
];

networking.firewall.enable = false;
Expand Down

0 comments on commit de77c3f

Please sign in to comment.