From e267955814e6959bbe07cf7ca7a992a1812ddc60 Mon Sep 17 00:00:00 2001 From: Cottand Date: Sat, 10 Aug 2024 14:25:17 +0100 Subject: [PATCH] add flake check, move modules into machines folder --- .github/workflows/main.yml | 17 ++++++++++++++++- hive.nix | 2 +- {modules => machines/modules}/consul.nix | 0 {modules => machines/modules}/default.nix | 0 .../modules}/defaultNomadConfig/client.hcl | 0 .../modules}/defaultNomadConfig/server.hcl | 0 {modules => machines/modules}/nomad.nix | 0 {modules => machines/modules}/vault.nix | 0 {modules => machines/modules}/vaultSecret.nix | 0 {modules => machines/modules}/wireguard.nix | 0 scripts/all-images/default.nix | 10 ++++++++++ scripts/default.nix | 12 +++++------- services/default.nix | 5 +++++ 13 files changed, 37 insertions(+), 9 deletions(-) rename {modules => machines/modules}/consul.nix (100%) rename {modules => machines/modules}/default.nix (100%) rename {modules => machines/modules}/defaultNomadConfig/client.hcl (100%) rename {modules => machines/modules}/defaultNomadConfig/server.hcl (100%) rename {modules => machines/modules}/nomad.nix (100%) rename {modules => machines/modules}/vault.nix (100%) rename {modules => machines/modules}/vaultSecret.nix (100%) rename {modules => machines/modules}/wireguard.nix (100%) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 558c0dea..d8be4b05 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -1,4 +1,4 @@ -name: Build Images +name: Main permissions: contents: read @@ -18,6 +18,21 @@ env: REGISTRY_IMAGE: "ghcr.io/cottand/selfhosted" jobs: + check: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + + - uses: cachix/install-nix-action@v22 + with: + github_access_token: ${{ secrets.GITHUB_TOKEN }} + + - uses: DeterminateSystems/magic-nix-cache-action@main + + - name: Flake check + run: | + nix check . + build-images: runs-on: ubuntu-latest steps: diff --git a/hive.nix b/hive.nix index 1766ca61..9e765f70 100644 --- a/hive.nix +++ b/hive.nix @@ -25,7 +25,7 @@ in imports = [ ./machines/${name}/definition.nix ./machines/_default - ./modules + ./machines/modules home-manager.nixosModules.home-manager cottand.nixosModules.seaweedBinaryCache cottand.nixosModules.dcottaRootCa diff --git a/modules/consul.nix b/machines/modules/consul.nix similarity index 100% rename from modules/consul.nix rename to machines/modules/consul.nix diff --git a/modules/default.nix b/machines/modules/default.nix similarity index 100% rename from modules/default.nix rename to machines/modules/default.nix diff --git a/modules/defaultNomadConfig/client.hcl b/machines/modules/defaultNomadConfig/client.hcl similarity index 100% rename from modules/defaultNomadConfig/client.hcl rename to machines/modules/defaultNomadConfig/client.hcl diff --git a/modules/defaultNomadConfig/server.hcl b/machines/modules/defaultNomadConfig/server.hcl similarity index 100% rename from modules/defaultNomadConfig/server.hcl rename to machines/modules/defaultNomadConfig/server.hcl diff --git a/modules/nomad.nix b/machines/modules/nomad.nix similarity index 100% rename from modules/nomad.nix rename to machines/modules/nomad.nix diff --git a/modules/vault.nix b/machines/modules/vault.nix similarity index 100% rename from modules/vault.nix rename to machines/modules/vault.nix diff --git a/modules/vaultSecret.nix b/machines/modules/vaultSecret.nix similarity index 100% rename from modules/vaultSecret.nix rename to machines/modules/vaultSecret.nix diff --git a/modules/wireguard.nix b/machines/modules/wireguard.nix similarity index 100% rename from modules/wireguard.nix rename to machines/modules/wireguard.nix diff --git a/scripts/all-images/default.nix b/scripts/all-images/default.nix index 954f6e32..dc32af56 100644 --- a/scripts/all-images/default.nix +++ b/scripts/all-images/default.nix @@ -1,3 +1,13 @@ +# For every image to be built in CI, +# this produces a JSON-formatted file like: +# +# { +# : , +# : , +# ...etc +# } +# +# You can build and cat this file to build all images. { self, writeText, system, ... }: let services = self.legacyPackages.${system}.services; diff --git a/scripts/default.nix b/scripts/default.nix index d5124149..19fab3a3 100644 --- a/scripts/default.nix +++ b/scripts/default.nix @@ -1,11 +1,9 @@ { self, callPackage, nomad, jq, nix, bws, writeShellScriptBin, writeScriptBin, yaegi, ... }: rec { - # buildAllImages = callPackage (import ./buildAllImages) {}; - - buildYaegiScript = name: filePath: writeScriptBin name '' - #! ${yaegi}/bin/yaegi - ${builtins.readFile filePath} - ''; +# buildYaegiScript = name: filePath: writeScriptBin name '' +# #! ${yaegi}/bin/yaegi +# ${builtins.readFile filePath} +# ''; # templates a nomad nix file into JSON and calls nomad run on it # usage: nixmad path/to/job.nix @@ -30,5 +28,5 @@ ${jq}/bin/jq -n --arg value "$SECRET" '{ "value": $value }' ''; - all-images = callPackage (import ./all-images) { inherit self; }; + all-images = callPackage ./all-images { inherit self; }; } diff --git a/services/default.nix b/services/default.nix index 95940e53..ea9ba975 100644 --- a/services/default.nix +++ b/services/default.nix @@ -1,3 +1,8 @@ +# Collection of services used in this repo. +# +# The source code does not need to live here, but every attribute of this set must return +# the built binary and that itself has to have an extra `.image` attribute, which is +# the OCI image to be built and run. { callPackage, writeText, ... }: { s-portfolio-stats = callPackage (import ./s-portfolio-stats) { }; }