Split modules and profiles

This commit is contained in:
Alexander Bantyev 2021-06-24 11:41:17 +03:00
parent 7efadcdd7f
commit 7db6eb7179
Signed by: balsoft
GPG Key ID: E081FF12ADCB4AD5
89 changed files with 81 additions and 74 deletions

View File

@ -59,9 +59,7 @@
flake = false;
};
nix-direnv = {
url = "github:nix-community/nix-direnv";
};
nix-direnv = { url = "github:nix-community/nix-direnv"; };
nheko = {
url = "github:balsoft/nheko/allow-edits-of-pending-messages";
@ -69,10 +67,28 @@
};
};
outputs = { nixpkgs, nix, self, deploy-rs, ... }@inputs: {
nixosModules = import ./modules;
outputs = { nixpkgs, nix, self, deploy-rs, ... }@inputs:
let
findModules = dir:
builtins.concatLists (builtins.attrValues (builtins.mapAttrs
(name: type:
if type == "regular" then
[{
name = builtins.elemAt (builtins.match "(.*)\\.nix" name) 0;
value = dir + "/${name}";
}]
else if (builtins.readDir (dir + "/${name}"))
? "default.nix" then [{
inherit name;
value = dir + "/${name}";
}] else
findModules (dir + "/${name}")) (builtins.readDir dir)));
in {
nixosModules = builtins.listToAttrs (findModules ./modules);
nixosProfiles = import ./profiles;
nixosProfiles = builtins.listToAttrs (findModules ./profiles);
nixosRoles = import ./roles;
nixosConfigurations = with nixpkgs.lib;
let
@ -80,7 +96,8 @@
mkHost = name:
nixosSystem {
system = builtins.readFile (./machines + "/${name}/system");
modules = [ (import (./machines + "/${name}")) { device = name; } ];
modules =
[ (import (./machines + "/${name}")) { device = name; } ];
specialArgs = { inherit inputs; };
};
in genAttrs hosts mkHost;

View File

@ -1,9 +1,9 @@
{ config, inputs, ... }: {
imports = [
./hardware-configuration.nix
inputs.self.nixosProfiles.desktop
inputs.self.nixosModules.print-scan
inputs.self.nixosModules.aws
inputs.self.nixosRoles.desktop
inputs.self.nixosProfiles.print-scan
inputs.self.nixosProfiles.aws
];
deviceSpecific.devInfo = {
cpu = {

View File

@ -1,7 +1,7 @@
{ inputs, ... }: {
imports = with inputs.self.nixosModules; [
./hardware-configuration.nix
inputs.self.nixosProfiles.server
inputs.self.nixosRoles.server
mailserver
];

View File

@ -1,7 +1,7 @@
{ inputs, ... }: {
imports = with inputs.self.nixosModules; [
./hardware-configuration.nix
inputs.self.nixosProfiles.base
inputs.self.nixosRoles.base
gitea
# jitsi
mailserver

View File

@ -1,5 +1,5 @@
{ inputs, ... }: {
imports = [ ./hardware-configuration.nix inputs.self.nixosProfiles.desktop ];
imports = [ ./hardware-configuration.nix inputs.self.nixosRoles.desktop ];
deviceSpecific.devInfo = {
cpu = {
vendor = "intel";

View File

@ -1,7 +1,7 @@
{ inputs, lib, config, pkgs, ... }: {
imports = [
./hardware-configuration.nix
inputs.self.nixosProfiles.desktop
inputs.self.nixosRoles.desktop
];
deviceSpecific.devInfo = {
cpu = {

View File

@ -1,7 +1,7 @@
{ modulesPath, lib, inputs, pkgs, ... }: {
imports = with inputs.self.nixosModules; [
"${modulesPath}/installer/cd-dvd/installation-cd-minimal.nix"
inputs.self.nixosProfiles.base
inputs.self.nixosRoles.base
themes
fonts
cage

View File

@ -1,17 +0,0 @@
let
findModules = dir:
builtins.concatLists (builtins.attrValues (builtins.mapAttrs (name: type:
if type == "regular" then
(if name == "default.nix" then
[ ]
else [{
name = builtins.elemAt (builtins.match "(.*)\\.nix" name) 0;
value = dir + "/${name}";
}])
else if (builtins.readDir (dir + "/${name}")) ? "default.nix" then [{
inherit name;
value = dir + "/${name}";
}] else
findModules (dir + "/${name}")) (builtins.readDir dir)));
in builtins.listToAttrs (findModules ./.)

View File

@ -1,15 +1,19 @@
{ inputs, ... }: {
imports = with inputs.self.nixosModules; [
imports = with inputs.self.nixosModules; with inputs.self.nixosProfiles; [
inputs.home-manager.nixosModules.home-manager
# MODULES
applications
boot
secrets
secrets-envsubst
persist
# PROFILES
autoRun
xdg
boot
devices
git
gpg
@ -18,7 +22,6 @@
network
nix
overlay
persist
security
ssh
zsh

View File

@ -1,11 +1,15 @@
{ inputs, ... }: {
imports = with inputs.self.nixosModules; [
imports = with inputs.self.nixosModules; with inputs.self.nixosProfiles; [
./base.nix
applications-setup
ezwg
hardware
# MODULES
themes
ezwg
# PROFILES
applications-setup
hardware
virtualisation
alacritty