forked from mirrors_public/oddlama_nix-config
feat: inherit lovesegfault's changes to host generation
This commit is contained in:
parent
2081ce6585
commit
7c6461d8e2
7 changed files with 18 additions and 29 deletions
|
@ -50,6 +50,7 @@
|
||||||
...
|
...
|
||||||
} @ inputs:
|
} @ inputs:
|
||||||
{
|
{
|
||||||
|
hosts = import ./nix/hosts.nix;
|
||||||
deploy = import ./nix/deploy.nix inputs;
|
deploy = import ./nix/deploy.nix inputs;
|
||||||
overlays = import ./nix/overlay.nix inputs;
|
overlays = import ./nix/overlay.nix inputs;
|
||||||
homeConfigurations = import ./nix/home-manager.nix inputs;
|
homeConfigurations = import ./nix/home-manager.nix inputs;
|
||||||
|
|
|
@ -35,13 +35,12 @@ with lib; {
|
||||||
hasGoodSuffix = x: strings.hasSuffix ".age" x || strings.hasSuffix ".pub" x;
|
hasGoodSuffix = x: strings.hasSuffix ".age" x || strings.hasSuffix ".pub" x;
|
||||||
in
|
in
|
||||||
# drv.drvPath doesn't force evaluation, which allows the warning to be displayed
|
# 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)) ''
|
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!
|
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
|
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
|
unencrypted age identity. These files will be copied to the nix store, so
|
||||||
make sure they don't contain any secret information!
|
make sure they don't contain any secret information!
|
||||||
|
|
|
@ -5,13 +5,13 @@
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (nixpkgs) lib;
|
inherit (nixpkgs) lib;
|
||||||
hosts = (import ./hosts.nix).all;
|
|
||||||
|
|
||||||
genNode = hostName: nixosCfg: let
|
generateNode = hostName: nixosCfg: let
|
||||||
inherit (hosts.${hostName}) hostname hostPlatform remoteBuild;
|
host = self.hosts.${hostName};
|
||||||
inherit (deploy-rs.lib.${hostPlatform}) activate;
|
inherit (deploy-rs.lib.${host.hostPlatform}) activate;
|
||||||
in {
|
in {
|
||||||
inherit remoteBuild hostname;
|
remoteBuild = host.remoteBuild or true;
|
||||||
|
hostname = host.address or hostName;
|
||||||
profiles.system.path = activate.nixos nixosCfg;
|
profiles.system.path = activate.nixos nixosCfg;
|
||||||
};
|
};
|
||||||
in {
|
in {
|
||||||
|
@ -20,5 +20,5 @@ in {
|
||||||
sshUser = "root";
|
sshUser = "root";
|
||||||
user = "root";
|
user = "root";
|
||||||
sudo = "runuser -u";
|
sudo = "runuser -u";
|
||||||
nodes = lib.mapAttrs genNode self.nixosConfigurations;
|
nodes = lib.mapAttrs generateNode (self.nixosConfigurations or {});
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,12 +6,6 @@
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (nixpkgs) lib;
|
inherit (nixpkgs) lib;
|
||||||
hosts = let
|
|
||||||
hostsNix = import ./hosts.nix;
|
|
||||||
in
|
|
||||||
if builtins.hasAttr "homeManager" hostsNix
|
|
||||||
then hostsNix.homeManager
|
|
||||||
else {};
|
|
||||||
|
|
||||||
genModules = hostName: {homeDirectory, ...}: {
|
genModules = hostName: {homeDirectory, ...}: {
|
||||||
config,
|
config,
|
||||||
|
@ -51,4 +45,4 @@
|
||||||
modules = [(genModules hostName attrs)];
|
modules = [(genModules hostName attrs)];
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
lib.mapAttrs genConfiguration hosts
|
lib.mapAttrs genConfiguration (self.hosts.homeManager or {})
|
||||||
|
|
|
@ -1,8 +1,6 @@
|
||||||
{self, ...}: system: let
|
{self, ...}: system: let
|
||||||
inherit (self.pkgs.${system}) lib linkFarm;
|
inherit (self.pkgs.${system}) lib linkFarm;
|
||||||
|
|
||||||
hosts = import ./hosts.nix;
|
|
||||||
|
|
||||||
nixosDrvs = lib.mapAttrs (_: nixos: nixos.config.system.build.toplevel) self.nixosConfigurations;
|
nixosDrvs = lib.mapAttrs (_: nixos: nixos.config.system.build.toplevel) self.nixosConfigurations;
|
||||||
homeDrvs = lib.mapAttrs (_: home: home.activationPackage) self.homeConfigurations;
|
homeDrvs = lib.mapAttrs (_: home: home.activationPackage) self.homeConfigurations;
|
||||||
hostDrvs = nixosDrvs // homeDrvs;
|
hostDrvs = nixosDrvs // homeDrvs;
|
||||||
|
@ -11,7 +9,7 @@
|
||||||
lib.mapAttrsRecursiveCond
|
lib.mapAttrsRecursiveCond
|
||||||
(hostAttr: !(hostAttr ? "type" && (lib.elem hostAttr.type ["homeManager" "nixos"])))
|
(hostAttr: !(hostAttr ? "type" && (lib.elem hostAttr.type ["homeManager" "nixos"])))
|
||||||
(path: _: hostDrvs.${lib.last path})
|
(path: _: hostDrvs.${lib.last path})
|
||||||
hosts;
|
self.hosts;
|
||||||
|
|
||||||
structuredHostFarms =
|
structuredHostFarms =
|
||||||
lib.mapAttrsRecursiveCond
|
lib.mapAttrsRecursiveCond
|
||||||
|
|
|
@ -2,13 +2,11 @@ let
|
||||||
hosts = {
|
hosts = {
|
||||||
nom = {
|
nom = {
|
||||||
type = "nixos";
|
type = "nixos";
|
||||||
hostname = "nom";
|
|
||||||
hostPlatform = "x86_64-linux";
|
hostPlatform = "x86_64-linux";
|
||||||
remoteBuild = true;
|
remoteBuild = true;
|
||||||
};
|
};
|
||||||
ward = {
|
ward = {
|
||||||
type = "nixos";
|
type = "nixos";
|
||||||
hostname = "ward";
|
|
||||||
hostPlatform = "x86_64-linux";
|
hostPlatform = "x86_64-linux";
|
||||||
remoteBuild = true;
|
remoteBuild = true;
|
||||||
};
|
};
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
{
|
{
|
||||||
self,
|
self,
|
||||||
home-manager,
|
home-manager,
|
||||||
impermanence,
|
#impermanence,
|
||||||
nixos-hardware,
|
nixos-hardware,
|
||||||
nixpkgs,
|
nixpkgs,
|
||||||
ragenix,
|
ragenix,
|
||||||
|
@ -9,7 +9,6 @@
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (nixpkgs) lib;
|
inherit (nixpkgs) lib;
|
||||||
hosts = (import ./hosts.nix).nixos;
|
|
||||||
|
|
||||||
nixRegistry = {
|
nixRegistry = {
|
||||||
nix.registry = {
|
nix.registry = {
|
||||||
|
@ -24,8 +23,8 @@
|
||||||
lib.nixosSystem {
|
lib.nixosSystem {
|
||||||
modules = [
|
modules = [
|
||||||
(../hosts + "/${hostName}")
|
(../hosts + "/${hostName}")
|
||||||
# Set hostName to same value as key in nixosConfigurations
|
# By default, set networking.hostName to the hostName
|
||||||
{networking.hostName = hostName;}
|
{ networking.hostName = lib.mkDefault hostName; }
|
||||||
# Use correct pkgs definition
|
# Use correct pkgs definition
|
||||||
{
|
{
|
||||||
nixpkgs.pkgs = self.pkgs.${hostPlatform};
|
nixpkgs.pkgs = self.pkgs.${hostPlatform};
|
||||||
|
@ -34,13 +33,13 @@
|
||||||
}
|
}
|
||||||
nixRegistry
|
nixRegistry
|
||||||
home-manager.nixosModules.home-manager
|
home-manager.nixosModules.home-manager
|
||||||
impermanence.nixosModules.impermanence
|
#impermanence.nixosModules.impermanence
|
||||||
ragenix.nixosModules.age
|
ragenix.nixosModules.age
|
||||||
];
|
];
|
||||||
specialArgs = {
|
specialArgs = {
|
||||||
impermanence = impermanence.nixosModules;
|
#impermanence = impermanence.nixosModules;
|
||||||
nixos-hardware = nixos-hardware.nixosModules;
|
nixos-hardware = nixos-hardware.nixosModules;
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
in
|
in
|
||||||
lib.mapAttrs genConfiguration hosts
|
lib.mapAttrs genConfiguration (self.hosts.nixos or {})
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue