diff options
| author | Martin Fischer <martin@push-f.com> | 2026-10-17 11:14:02 +0200 |
|---|---|---|
| committer | Martin Fischer <martin@push-f.com> | 2026-10-18 07:25:43 +0200 |
| commit | 9237328fb09b2c18365bb5fcef1c4596d77973a9 (patch) | |
| tree | 55bbfd35140871166a52bbf01bb658c03ca127d6 | |
| parent | f29ddff912ddcd58a4726736702b24655505ce09 (diff) | |
refactor: make server packages buildable via packages.*
| -rw-r--r-- | AGENTS.md | 5 | ||||
| -rw-r--r-- | nixos/default.nix | 11 | ||||
| -rw-r--r-- | nixos/helpers.nix | 2 | ||||
| -rw-r--r-- | nixos/hosts/ev/exporters.nix | 4 | ||||
| -rw-r--r-- | nixos/hosts/tente/exporters.nix | 5 | ||||
| -rw-r--r-- | nixos/profiles/server/default.nix | 2 | ||||
| -rw-r--r-- | nixos/profiles/server/pkgs/alloy-nix-config/alloy_nix_config.go (renamed from nixos/shared/alloy-nix-config/alloy_nix_config.go) | 0 | ||||
| -rw-r--r-- | nixos/profiles/server/pkgs/alloy-nix-config/go.mod (renamed from nixos/shared/alloy-nix-config/go.mod) | 0 | ||||
| -rw-r--r-- | nixos/profiles/server/pkgs/alloy-nix-config/package.nix (renamed from nixos/shared/alloy-nix-config/default.nix) | 4 | ||||
| -rw-r--r-- | nixos/profiles/server/pkgs/prometheus-sql-exporter.nix (renamed from nixos/shared/prometheus-sql-exporter/default.nix) | 0 | ||||
| -rw-r--r-- | nixos/profiles/server/pkgs/prometheus-storagebox-exporter.nix (renamed from nixos/shared/prometheus-storagebox-exporter/default.nix) | 0 | ||||
| -rw-r--r-- | nixos/profiles/server/prometheus-sql-exporter.nix (renamed from nixos/shared/prometheus-sql-exporter/service.nix) | 2 | ||||
| -rw-r--r-- | nixos/profiles/server/prometheus-storagebox-exporter.nix (renamed from nixos/shared/prometheus-storagebox-exporter/service.nix) | 2 |
13 files changed, 22 insertions, 15 deletions
@@ -34,6 +34,11 @@ To get the store path to a pin, use the `get-path` npins subcommand: npins -d nixos/npins get-path <name> +Build a package under `nixos/profiles/server/pkgs/` +(both `<package>.nix` and `<package>/package.nix` map to `<package>`): + + nix build --no-link --file nixos packages.server.<package> + ## Documentation * The Nixpkgs manual is in `<nixpkgs>/doc`. diff --git a/nixos/default.nix b/nixos/default.nix index e5090db..c164c7f 100644 --- a/nixos/default.nix +++ b/nixos/default.nix @@ -53,5 +53,14 @@ rec { standaloneConfigurations = mkConfigurations (host: host.standaloneModule) hostDefs; - standaloneSystems = mkSystems standaloneConfigurations; + packages = { + server = + let + pkgs = import sources.nixos-small.outPath { }; + in + pkgs.lib.packagesFromDirectoryRecursive { + directory = ./profiles/server/pkgs; + callPackage = pkgs.newScope { inherit sources; }; + }; + }; } diff --git a/nixos/helpers.nix b/nixos/helpers.nix index 4ee33ef..49877a5 100644 --- a/nixos/helpers.nix +++ b/nixos/helpers.nix @@ -83,7 +83,7 @@ writeAlloyConfig = cfg: let - alloy-nix-config = "${pkgs.callPackage ./shared/alloy-nix-config {}}/bin/alloy-nix-config"; + alloy-nix-config = "${pkgs.callPackage ./profiles/server/pkgs/alloy-nix-config/package.nix {}}/bin/alloy-nix-config"; in pkgs.runCommand "generated-config" {} '' ${alloy-nix-config} ${pkgs.writeText "input.json" (builtins.toJSON cfg)} $out diff --git a/nixos/hosts/ev/exporters.nix b/nixos/hosts/ev/exporters.nix index f22f043..aa4c773 100644 --- a/nixos/hosts/ev/exporters.nix +++ b/nixos/hosts/ev/exporters.nix @@ -11,10 +11,6 @@ in }; }; - imports = [ - ../../shared/prometheus-sql-exporter/service.nix - ]; - config = { services.prometheus-sql-exporter = { enable = true; diff --git a/nixos/hosts/tente/exporters.nix b/nixos/hosts/tente/exporters.nix index f146567..0eb9199 100644 --- a/nixos/hosts/tente/exporters.nix +++ b/nixos/hosts/tente/exporters.nix @@ -14,11 +14,6 @@ in }; }; - imports = [ - ../../shared/prometheus-sql-exporter/service.nix - ../../shared/prometheus-storagebox-exporter/service.nix - ]; - config = { services.prometheus-sql-exporter = { enable = true; diff --git a/nixos/profiles/server/default.nix b/nixos/profiles/server/default.nix index 6e744a6..3e917c2 100644 --- a/nixos/profiles/server/default.nix +++ b/nixos/profiles/server/default.nix @@ -4,6 +4,8 @@ imports = [ ../common ./detect-hostname-change.nix + ./prometheus-sql-exporter.nix + ./prometheus-storagebox-exporter.nix ]; services = { diff --git a/nixos/shared/alloy-nix-config/alloy_nix_config.go b/nixos/profiles/server/pkgs/alloy-nix-config/alloy_nix_config.go index 4b6eb63..4b6eb63 100644 --- a/nixos/shared/alloy-nix-config/alloy_nix_config.go +++ b/nixos/profiles/server/pkgs/alloy-nix-config/alloy_nix_config.go diff --git a/nixos/shared/alloy-nix-config/go.mod b/nixos/profiles/server/pkgs/alloy-nix-config/go.mod index 2916089..2916089 100644 --- a/nixos/shared/alloy-nix-config/go.mod +++ b/nixos/profiles/server/pkgs/alloy-nix-config/go.mod diff --git a/nixos/shared/alloy-nix-config/default.nix b/nixos/profiles/server/pkgs/alloy-nix-config/package.nix index d4efe02..981b612 100644 --- a/nixos/shared/alloy-nix-config/default.nix +++ b/nixos/profiles/server/pkgs/alloy-nix-config/package.nix @@ -1,6 +1,6 @@ -{ pkgs ? import <nixpkgs> {} }: +{ buildGoModule }: -pkgs.buildGoModule { +buildGoModule { pname = "alloy-nix-config"; version = "git"; src = ./.; diff --git a/nixos/shared/prometheus-sql-exporter/default.nix b/nixos/profiles/server/pkgs/prometheus-sql-exporter.nix index e049396..e049396 100644 --- a/nixos/shared/prometheus-sql-exporter/default.nix +++ b/nixos/profiles/server/pkgs/prometheus-sql-exporter.nix diff --git a/nixos/shared/prometheus-storagebox-exporter/default.nix b/nixos/profiles/server/pkgs/prometheus-storagebox-exporter.nix index d4fd13e..d4fd13e 100644 --- a/nixos/shared/prometheus-storagebox-exporter/default.nix +++ b/nixos/profiles/server/pkgs/prometheus-storagebox-exporter.nix diff --git a/nixos/shared/prometheus-sql-exporter/service.nix b/nixos/profiles/server/prometheus-sql-exporter.nix index 3bbf5c2..fe2ef7b 100644 --- a/nixos/shared/prometheus-sql-exporter/service.nix +++ b/nixos/profiles/server/prometheus-sql-exporter.nix @@ -2,7 +2,7 @@ { config, lib, pkgs, sources, ... }: let - sqlExporter = pkgs.callPackage ./default.nix { inherit sources; }; + sqlExporter = pkgs.callPackage ./pkgs/prometheus-sql-exporter.nix { inherit sources; }; cfg = config.services.prometheus-sql-exporter; configFile = builtins.toFile "config.yaml" (builtins.toJSON cfg.config); validateConfig = file: diff --git a/nixos/shared/prometheus-storagebox-exporter/service.nix b/nixos/profiles/server/prometheus-storagebox-exporter.nix index 1d3cff5..16b03e6 100644 --- a/nixos/shared/prometheus-storagebox-exporter/service.nix +++ b/nixos/profiles/server/prometheus-storagebox-exporter.nix @@ -2,7 +2,7 @@ { config, lib, pkgs, sources, ... }: let - storageboxExporter = pkgs.callPackage ./default.nix { inherit sources; }; + storageboxExporter = pkgs.callPackage ./pkgs/prometheus-storagebox-exporter.nix { inherit sources; }; cfg = config.services.prometheus-storagebox-exporter; in { |
