Skip to content

Commit 4e8bb1f

Browse files
committed
base: create from_ansible module for base_* variables
1 parent 0ba517a commit 4e8bb1f

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

flake.nix

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@
4646
];
4747
ansible_default = default ++ [
4848
nix-unify.nixosModules.ansible
49+
from_ansible
4950
];
5051
unify_default = ansible_default ++ [
5152
nix-unify.nixosModules.unify
@@ -71,6 +72,29 @@
7172
imports = self.nixosModules.onlypath_default;
7273
nixpkgs.hostPlatform = system;
7374
}).config.system.build.toplevel;
75+
76+
# check if our ansible set evaluates without any ansible stuff set
77+
# (this allows better ci testing)
78+
ansible = (import "${nixpkgs}/nixos/lib/eval-config.nix" {
79+
modules = [
80+
{
81+
imports = self.nixosModules.ansible_default;
82+
nixpkgs.hostPlatform = system;
83+
nixpkgs.overlays = [ self.overlays.default ];
84+
fileSystems."/" = { device = "/dev/sda1"; fsType = "ext4"; };
85+
boot.loader.systemd-boot.enable = true;
86+
users.allowNoPasswordLogin = true;
87+
}
88+
];
89+
90+
# this needs to be set via pkgs.nixos,
91+
# but there's no way to do that
92+
specialArgs = {
93+
inherit inputs;
94+
};
95+
96+
system = null;
97+
}).config.system.build.toplevel;
7498
}
7599
);
76100
};

modules/from_ansible/default.nix

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{ config, lib, ... }:
2+
3+
with lib;
4+
5+
{
6+
users.users.root.openssh.authorizedKeys.keys =
7+
mkIf (config.ansible.hostvars ? "base_ssh_root_keys")
8+
config.ansible.hostvars.base_ssh_root_keys;
9+
10+
services.openssh.settings.AllowUsers =
11+
mkIf (config.ansible.hostvars ? "base_ssh_allow_users")
12+
(lib.concatStringsSep " " config.ansible.hostvars.base_ssh_allow_users);
13+
}

0 commit comments

Comments
 (0)