create own library for globals and net.nix

This commit is contained in:
Pim Kunis 2024-04-13 17:28:31 +02:00
parent c8023afceb
commit 8b937fdfc4
12 changed files with 31 additions and 33 deletions

View file

@ -1,11 +1,11 @@
{ self, hostPkgs, machines, flake-utils, deploy-rs, ... }: flake-utils.lib.eachDefaultSystem (system: {
{ self, pkgs, machines, flake-utils, deploy-rs, ... }: flake-utils.lib.eachDefaultSystem (system: {
# Deploy-rs' flake checks seem broken for architectures different from the deployment machine.
# We skip these here.
checks = deploy-rs.lib.${system}.deployChecks (
hostPkgs.lib.attrsets.updateManyAttrsByPath [{
pkgs.lib.attrsets.updateManyAttrsByPath [{
path = [ "nodes" ];
update = hostPkgs.lib.attrsets.filterAttrs (name: node:
update = pkgs.lib.attrsets.filterAttrs (name: node:
machines.${name}.arch == system
);
}]

View file

@ -1,4 +1,4 @@
{ self, hostPkgs, machines, deploy-rs, ... }:
{ self, pkgs, machines, deploy-rs, ... }:
let
mkDeployNodes = nodeDef:
builtins.mapAttrs
@ -17,7 +17,7 @@ in
{
hostname = nixosConfiguration.config.networking.fqdn;
profiles.system = {
remoteBuild = machine.arch != hostPkgs.stdenv.hostPlatform.system;
remoteBuild = machine.arch != pkgs.stdenv.hostPlatform.system;
path = deploy-rs.lib.${machine.arch}.activate.nixos nixosConfiguration;
};
});

View file

@ -1,14 +1,15 @@
{ flake-utils, kubenix, nixhelm, ... }: flake-utils.lib.eachDefaultSystem
{ myLib, flake-utils, kubenix, nixhelm, ... }: flake-utils.lib.eachDefaultSystem
(system: {
# TODO: DRY
kubenix = kubenix.packages.${system}.default.override
{
specialArgs = { inherit kubenix nixhelm system; };
specialArgs = { inherit myLib kubenix nixhelm system; };
module = { imports = [ ../kubenix-modules/all.nix ]; };
};
kubenix-bootstrap = kubenix.packages.${system}.default.override
{
specialArgs = { inherit kubenix nixhelm system; };
specialArgs = { inherit myLib kubenix nixhelm system; };
module = { imports = [ ../kubenix-modules/base.nix ]; };
};
})

View file

@ -1,4 +1,4 @@
{ nixpkgs, nixpkgs-unstable, machines, dns, agenix, nixos-hardware, kubenix, disko, ... }:
{ myLib, nixpkgs, nixpkgs-unstable, machines, dns, agenix, nixos-hardware, kubenix, disko, ... }:
let
mkNixosSystems = systemDef:
builtins.mapAttrs
@ -11,7 +11,7 @@ in
nixosConfigurations = mkNixosSystems (name: machine: {
system = machine.arch;
specialArgs = { inherit nixpkgs-unstable machines machine dns agenix nixos-hardware kubenix disko; };
specialArgs = { inherit myLib nixpkgs-unstable machines machine dns agenix nixos-hardware kubenix disko; };
modules = [
../configuration.nix
{ networking.hostName = name; }

View file

@ -1,19 +1,19 @@
{ flake-utils, hostPkgs, ... }: flake-utils.lib.eachDefaultSystem (system:
{ flake-utils, pkgs, ... }: flake-utils.lib.eachDefaultSystem (system:
let
createScript = name: runtimeInputs: scriptPath:
let
script = (hostPkgs.writeScriptBin name (builtins.readFile scriptPath)).overrideAttrs (old: {
script = (pkgs.writeScriptBin name (builtins.readFile scriptPath)).overrideAttrs (old: {
buildCommand = "${old.buildCommand}\n patchShebangs $out";
});
in
hostPkgs.symlinkJoin {
pkgs.symlinkJoin {
inherit name;
paths = [ script ] ++ runtimeInputs;
buildInputs = [ hostPkgs.makeWrapper ];
buildInputs = [ pkgs.makeWrapper ];
postBuild = "wrapProgram $out/bin/${name} --set PATH $out/bin";
};
in
{
packages.bootstrap = createScript "bootstrap" (with hostPkgs; [ libsecret coreutils nixos-anywhere ]) ./bootstrap.sh;
packages.gen-k3s-cert = createScript "create-k3s-cert" (with hostPkgs; [ openssl coreutils openssh yq ]) ./gen-k3s-cert.sh;
packages.bootstrap = createScript "bootstrap" (with pkgs; [ libsecret coreutils nixos-anywhere ]) ./bootstrap.sh;
packages.gen-k3s-cert = createScript "create-k3s-cert" (with pkgs; [ openssl coreutils openssh yq ]) ./gen-k3s-cert.sh;
})