From b2f4c85a6c1afb74b257a14dcce9236ae021fe4a Mon Sep 17 00:00:00 2001 From: Martin Fischer Date: Sat, 17 Oct 2026 10:19:47 +0200 Subject: refactor: pass sources via specialArgs --- nixos/hosts/ev/default.nix | 3 +-- nixos/hosts/hamac/default.nix | 3 +-- nixos/hosts/tente/default.nix | 3 +-- nixos/profiles/common/default.nix | 16 ++++++---------- nixos/profiles/workstation/create.nix | 5 +---- nixos/profiles/workstation/default.nix | 3 +-- nixos/rebuild | 2 +- nixos/shared/prometheus-sql-exporter/default.nix | 4 +--- nixos/shared/prometheus-sql-exporter/service.nix | 4 ++-- nixos/shared/prometheus-storagebox-exporter/default.nix | 4 +--- nixos/shared/prometheus-storagebox-exporter/service.nix | 4 ++-- nixos/system.nix | 4 ++++ 12 files changed, 22 insertions(+), 33 deletions(-) create mode 100644 nixos/system.nix (limited to 'nixos') diff --git a/nixos/hosts/ev/default.nix b/nixos/hosts/ev/default.nix index 3e30678..a528fe4 100644 --- a/nixos/hosts/ev/default.nix +++ b/nixos/hosts/ev/default.nix @@ -2,13 +2,12 @@ # your system. Help is available in the configuration.nix(5) man page # and in the NixOS manual (accessible by running ‘nixos-help’). -{ config, lib, pkgs, ... }: +{ config, lib, pkgs, sources, ... }: let ports = import ./ports.nix; helpers = import { inherit config lib pkgs; }; backupHost = "u518695-sub2@u518695-sub2.your-storagebox.de"; - sources = import ; pkgs-unstable = import sources.nixos-unstable {}; in { diff --git a/nixos/hosts/hamac/default.nix b/nixos/hosts/hamac/default.nix index f258606..c68c408 100644 --- a/nixos/hosts/hamac/default.nix +++ b/nixos/hosts/hamac/default.nix @@ -1,9 +1,8 @@ # See the configuration.nix(5) man page and the NixOS manual (accessible by running `nixos-help`). -{ config, lib, pkgs, ... }: +{ config, lib, pkgs, sources, ... }: let - sources = import ; pkgs-unstable = import sources.nixos-unstable {}; in { diff --git a/nixos/hosts/tente/default.nix b/nixos/hosts/tente/default.nix index edf2bd8..04a2c98 100644 --- a/nixos/hosts/tente/default.nix +++ b/nixos/hosts/tente/default.nix @@ -2,14 +2,13 @@ # your system. Help is available in the configuration.nix(5) man page, on # https://search.nixos.org/options and in the NixOS manual (`nixos-help`). -{ config, lib, pkgs, ... }: +{ config, lib, pkgs, sources, ... }: let baseDomain = "push-f.com"; acmeEmail = "martin@push-f.com"; backupHost = "u518695-sub1@u518695-sub1.your-storagebox.de"; ports = import ./ports.nix; - sources = import ; helpers = import { inherit config lib pkgs; }; gitoliteDataDir = "/srv/gitolite"; reposDir = "${gitoliteDataDir}/repositories"; diff --git a/nixos/profiles/common/default.nix b/nixos/profiles/common/default.nix index 1705adf..d891879 100644 --- a/nixos/profiles/common/default.nix +++ b/nixos/profiles/common/default.nix @@ -1,13 +1,9 @@ -{ config, pkgs, ... }: +{ config, pkgs, sources, ... }: { - imports = - let - sources = import ; - in - [ - ./sanix.nix - ./basics.nix - "${sources.agenix}/modules/age.nix" - ]; + imports = [ + ./sanix.nix + ./basics.nix + "${sources.agenix}/modules/age.nix" + ]; } diff --git a/nixos/profiles/workstation/create.nix b/nixos/profiles/workstation/create.nix index 5580ec4..08320e6 100644 --- a/nixos/profiles/workstation/create.nix +++ b/nixos/profiles/workstation/create.nix @@ -1,8 +1,5 @@ -{ config, pkgs, pkgs-unstable, ... }: +{ config, pkgs, pkgs-unstable, sources, ... }: -let - sources = import ; -in { environment.systemPackages = with pkgs; [ graphviz-nox # for dot diff --git a/nixos/profiles/workstation/default.nix b/nixos/profiles/workstation/default.nix index 9332bca..0961a24 100644 --- a/nixos/profiles/workstation/default.nix +++ b/nixos/profiles/workstation/default.nix @@ -1,8 +1,7 @@ -{ config, lib, pkgs, pkgs-unstable, ... }: +{ config, lib, pkgs, pkgs-unstable, sources, ... }: let cfg = config.workstation; - sources = import ; cmd50 = pkgs.callPackage (sources.my-cmd50 { inherit pkgs; }) {}; in { diff --git a/nixos/rebuild b/nixos/rebuild index d6a06a8..dc7ee5d 100755 --- a/nixos/rebuild +++ b/nixos/rebuild @@ -47,5 +47,5 @@ nixpkgsPath=$( # nixos-rebuild always reads Nixpkgs from the NIX_PATH, # so we need to set it explicitly to our pinned version - exec nixos-rebuild "$@" -I nixpkgs="$nixpkgsPath" -I nixos-config="$configPath" -I top="$top" + exec nixos-rebuild "$@" --file "$top/system.nix" -I nixpkgs="$nixpkgsPath" -I nixos-config="$configPath" -I top="$top" ) diff --git a/nixos/shared/prometheus-sql-exporter/default.nix b/nixos/shared/prometheus-sql-exporter/default.nix index 5d80a62..e049396 100644 --- a/nixos/shared/prometheus-sql-exporter/default.nix +++ b/nixos/shared/prometheus-sql-exporter/default.nix @@ -1,10 +1,8 @@ { lib, buildGoModule, + sources, }: -let - sources = import ; -in buildGoModule { pname = "sql_exporter"; version = sources.prometheus-sql-exporter.version; diff --git a/nixos/shared/prometheus-sql-exporter/service.nix b/nixos/shared/prometheus-sql-exporter/service.nix index a79528c..3bbf5c2 100644 --- a/nixos/shared/prometheus-sql-exporter/service.nix +++ b/nixos/shared/prometheus-sql-exporter/service.nix @@ -1,8 +1,8 @@ # TODO: submit burningalchemist's sql_exporter to nixpkgs -{ config, lib, pkgs, ... }: +{ config, lib, pkgs, sources, ... }: let - sqlExporter = pkgs.callPackage ./default.nix {}; + sqlExporter = pkgs.callPackage ./default.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/default.nix b/nixos/shared/prometheus-storagebox-exporter/default.nix index 281290f..d4fd13e 100644 --- a/nixos/shared/prometheus-storagebox-exporter/default.nix +++ b/nixos/shared/prometheus-storagebox-exporter/default.nix @@ -1,10 +1,8 @@ { lib, buildGoModule, + sources, }: -let - sources = import ; -in buildGoModule { pname = "storagebox_exporter"; version = sources.prometheus-storagebox-exporter.version; diff --git a/nixos/shared/prometheus-storagebox-exporter/service.nix b/nixos/shared/prometheus-storagebox-exporter/service.nix index 74f0dd1..1d3cff5 100644 --- a/nixos/shared/prometheus-storagebox-exporter/service.nix +++ b/nixos/shared/prometheus-storagebox-exporter/service.nix @@ -1,8 +1,8 @@ # TODO: submit Christian's storagebox exporter to nixpkgs -{ config, lib, pkgs, ... }: +{ config, lib, pkgs, sources, ... }: let - storageboxExporter = pkgs.callPackage ./default.nix {}; + storageboxExporter = pkgs.callPackage ./default.nix { inherit sources; }; cfg = config.services.prometheus-storagebox-exporter; in { diff --git a/nixos/system.nix b/nixos/system.nix new file mode 100644 index 0000000..a3b04cb --- /dev/null +++ b/nixos/system.nix @@ -0,0 +1,4 @@ +import { + configuration = import ; + specialArgs.sources = import ./npins; +} -- cgit v1.3.1