1
1
Fork 1
mirror of https://github.com/oddlama/nix-config.git synced 2025-10-10 23:00:39 +02:00

feat: inherit lovesegfault's changes to host generation

This commit is contained in:
oddlama 2023-01-30 17:10:56 +01:00
parent 2081ce6585
commit 7c6461d8e2
No known key found for this signature in database
GPG key ID: 14EFE510775FE39A
7 changed files with 18 additions and 29 deletions

View file

@ -50,6 +50,7 @@
...
} @ inputs:
{
hosts = import ./nix/hosts.nix;
deploy = import ./nix/deploy.nix inputs;
overlays = import ./nix/overlay.nix inputs;
homeConfigurations = import ./nix/home-manager.nix inputs;

View file

@ -35,13 +35,12 @@ with lib; {
hasGoodSuffix = x: strings.hasSuffix ".age" x || strings.hasSuffix ".pub" x;
in
# drv.drvPath doesn't force evaluation, which allows the warning to be displayed
# before the error occurs
# in case the derivation is not built before deploying
optional (!pathExists (removeSuffix ".drv" drv.drvPath)) ''
The secrets have not yet been rekeyed!
The secrets for host ${config.networking.hostName} have not yet been rekeyed!
Be sure to run `nix run ".#rekey"` after changing your secrets!
''
++ optional (!all hasGoodSuffix config.rekey.masterIdentityPaths)
''
++ optional (!all hasGoodSuffix config.rekey.masterIdentityPaths) ''
It seems like at least one of your rekey.masterIdentityPaths contains an
unencrypted age identity. These files will be copied to the nix store, so
make sure they don't contain any secret information!

View file

@ -5,13 +5,13 @@
...
}: let
inherit (nixpkgs) lib;
hosts = (import ./hosts.nix).all;
genNode = hostName: nixosCfg: let
inherit (hosts.${hostName}) hostname hostPlatform remoteBuild;
inherit (deploy-rs.lib.${hostPlatform}) activate;
generateNode = hostName: nixosCfg: let
host = self.hosts.${hostName};
inherit (deploy-rs.lib.${host.hostPlatform}) activate;
in {
inherit remoteBuild hostname;
remoteBuild = host.remoteBuild or true;
hostname = host.address or hostName;
profiles.system.path = activate.nixos nixosCfg;
};
in {
@ -20,5 +20,5 @@ in {
sshUser = "root";
user = "root";
sudo = "runuser -u";
nodes = lib.mapAttrs genNode self.nixosConfigurations;
nodes = lib.mapAttrs generateNode (self.nixosConfigurations or {});
}

View file

@ -6,12 +6,6 @@
...
}: let
inherit (nixpkgs) lib;
hosts = let
hostsNix = import ./hosts.nix;
in
if builtins.hasAttr "homeManager" hostsNix
then hostsNix.homeManager
else {};
genModules = hostName: {homeDirectory, ...}: {
config,
@ -51,4 +45,4 @@
modules = [(genModules hostName attrs)];
};
in
lib.mapAttrs genConfiguration hosts
lib.mapAttrs genConfiguration (self.hosts.homeManager or {})

View file

@ -1,8 +1,6 @@
{self, ...}: system: let
inherit (self.pkgs.${system}) lib linkFarm;
hosts = import ./hosts.nix;
nixosDrvs = lib.mapAttrs (_: nixos: nixos.config.system.build.toplevel) self.nixosConfigurations;
homeDrvs = lib.mapAttrs (_: home: home.activationPackage) self.homeConfigurations;
hostDrvs = nixosDrvs // homeDrvs;
@ -11,7 +9,7 @@
lib.mapAttrsRecursiveCond
(hostAttr: !(hostAttr ? "type" && (lib.elem hostAttr.type ["homeManager" "nixos"])))
(path: _: hostDrvs.${lib.last path})
hosts;
self.hosts;
structuredHostFarms =
lib.mapAttrsRecursiveCond

View file

@ -2,13 +2,11 @@ let
hosts = {
nom = {
type = "nixos";
hostname = "nom";
hostPlatform = "x86_64-linux";
remoteBuild = true;
};
ward = {
type = "nixos";
hostname = "ward";
hostPlatform = "x86_64-linux";
remoteBuild = true;
};

View file

@ -1,7 +1,7 @@
{
self,
home-manager,
impermanence,
#impermanence,
nixos-hardware,
nixpkgs,
ragenix,
@ -9,7 +9,6 @@
...
}: let
inherit (nixpkgs) lib;
hosts = (import ./hosts.nix).nixos;
nixRegistry = {
nix.registry = {
@ -24,8 +23,8 @@
lib.nixosSystem {
modules = [
(../hosts + "/${hostName}")
# Set hostName to same value as key in nixosConfigurations
{networking.hostName = hostName;}
# By default, set networking.hostName to the hostName
{ networking.hostName = lib.mkDefault hostName; }
# Use correct pkgs definition
{
nixpkgs.pkgs = self.pkgs.${hostPlatform};
@ -34,13 +33,13 @@
}
nixRegistry
home-manager.nixosModules.home-manager
impermanence.nixosModules.impermanence
#impermanence.nixosModules.impermanence
ragenix.nixosModules.age
];
specialArgs = {
impermanence = impermanence.nixosModules;
#impermanence = impermanence.nixosModules;
nixos-hardware = nixos-hardware.nixosModules;
};
};
in
lib.mapAttrs genConfiguration hosts
lib.mapAttrs genConfiguration (self.hosts.nixos or {})