flake: add builder lib & formatter
flake: add builder lib & formatter flake: add builder lib & formatter flake: add builder lib & formatter
This commit is contained in:
parent
6ccdce3710
commit
19a4bbda3c
6 changed files with 157 additions and 63 deletions
24
flake.nix
24
flake.nix
|
|
@ -2,27 +2,11 @@
|
|||
# ooknet
|
||||
description = "a nix configuration written by an orangutan";
|
||||
|
||||
outputs = {
|
||||
flake-parts,
|
||||
self,
|
||||
...
|
||||
} @ inputs:
|
||||
flake-parts.lib.mkFlake {inherit inputs;} ({withSystem, ...}: {
|
||||
outputs = {flake-parts, ...} @ inputs:
|
||||
flake-parts.lib.mkFlake {inherit inputs;} {
|
||||
systems = import inputs.systems;
|
||||
|
||||
imports = [
|
||||
./outputs/pkgs
|
||||
./outputs/sshKeys.nix
|
||||
];
|
||||
|
||||
flake = {
|
||||
nixosConfigurations = import ./outputs/nixos.nix {inherit self inputs withSystem;};
|
||||
};
|
||||
|
||||
perSystem = {pkgs, ...}: {
|
||||
formatter = pkgs.alejandra;
|
||||
};
|
||||
});
|
||||
imports = [./outputs];
|
||||
};
|
||||
|
||||
# External inputs we depend on
|
||||
inputs = {
|
||||
|
|
|
|||
9
outputs/default.nix
Normal file
9
outputs/default.nix
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
{
|
||||
imports = [
|
||||
./nixos.nix
|
||||
./sshKeys.nix
|
||||
./formatter.nix
|
||||
./lib
|
||||
./pkgs
|
||||
];
|
||||
}
|
||||
5
outputs/formatter.nix
Normal file
5
outputs/formatter.nix
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
_: {
|
||||
perSystem = {pkgs, ...}: {
|
||||
formatter = pkgs.alejandra;
|
||||
};
|
||||
}
|
||||
91
outputs/lib/builders.nix
Normal file
91
outputs/lib/builders.nix
Normal file
|
|
@ -0,0 +1,91 @@
|
|||
{
|
||||
lib,
|
||||
inputs,
|
||||
self,
|
||||
...
|
||||
}: let
|
||||
inherit (lib) singleton recursiveUpdate mkDefault;
|
||||
inherit (builtins) concatLists;
|
||||
inherit (self) keys;
|
||||
hm = inputs.home-manager.nixosModules.home-manager;
|
||||
agenix = inputs.agenix.nixosModules.default;
|
||||
nixosModules = "${self}/nixos";
|
||||
mkNixos = inputs.nixpkgs.lib.nixosSystem;
|
||||
hostModules = "${self}/hosts";
|
||||
|
||||
mkBaseSystem = {
|
||||
withSystem,
|
||||
hostname,
|
||||
system,
|
||||
type,
|
||||
role,
|
||||
additionalModules ? [],
|
||||
specialArgs ? {},
|
||||
}:
|
||||
withSystem system ({
|
||||
inputs',
|
||||
self',
|
||||
...
|
||||
}:
|
||||
mkNixos {
|
||||
specialArgs =
|
||||
recursiveUpdate {
|
||||
inherit keys lib inputs self inputs' self';
|
||||
}
|
||||
specialArgs;
|
||||
modules = concatLists [
|
||||
(singleton {
|
||||
networking.hostName = hostname;
|
||||
nixpkgs.hostPlatform = mkDefault system;
|
||||
ooknet.host = {
|
||||
name = hostname;
|
||||
inherit role type;
|
||||
};
|
||||
})
|
||||
[(hostModules + "/${hostname}")]
|
||||
additionalModules
|
||||
];
|
||||
});
|
||||
|
||||
mkWorkstation = {
|
||||
withSystem,
|
||||
hostname,
|
||||
system,
|
||||
type,
|
||||
additionalModules ? [],
|
||||
specialArgs ? {},
|
||||
}:
|
||||
mkBaseSystem {
|
||||
inherit withSystem hostname system type specialArgs;
|
||||
role = "workstation";
|
||||
additionalModules = concatLists [
|
||||
[hm agenix nixosModules]
|
||||
additionalModules
|
||||
];
|
||||
};
|
||||
|
||||
mkServer = {
|
||||
withSystem,
|
||||
hostname,
|
||||
system,
|
||||
type,
|
||||
platform,
|
||||
services,
|
||||
additionalModules ? [],
|
||||
specialArgs ? {},
|
||||
}:
|
||||
mkBaseSystem {
|
||||
inherit withSystem hostname system type specialArgs;
|
||||
role = "server";
|
||||
additionalModules = concatLists [
|
||||
(singleton {
|
||||
ooknet.host = {
|
||||
inherit platform services;
|
||||
};
|
||||
})
|
||||
additionalModules
|
||||
];
|
||||
};
|
||||
in {
|
||||
inherit mkServer mkWorkstation;
|
||||
}
|
||||
12
outputs/lib/default.nix
Normal file
12
outputs/lib/default.nix
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
{
|
||||
lib,
|
||||
self,
|
||||
inputs,
|
||||
...
|
||||
}: let
|
||||
builders = import ./builders.nix {inherit self lib inputs;};
|
||||
in {
|
||||
_module.args.ooknet.lib = {
|
||||
inherit builders;
|
||||
};
|
||||
}
|
||||
|
|
@ -1,55 +1,48 @@
|
|||
{
|
||||
inputs,
|
||||
self,
|
||||
withSystem,
|
||||
ooknet,
|
||||
...
|
||||
}: let
|
||||
inherit (inputs.nixpkgs.lib) nixosSystem;
|
||||
inherit (self) keys;
|
||||
|
||||
hosts = "${self}/hosts";
|
||||
|
||||
hm = inputs.home-manager.nixosModules.home-manager;
|
||||
nixarr = inputs.nixarr.nixosModules.default;
|
||||
agenix = inputs.agenix.nixosModules.default;
|
||||
|
||||
nixosModules = "${self}/nixos";
|
||||
|
||||
workstation = [
|
||||
hm
|
||||
agenix
|
||||
nixosModules
|
||||
];
|
||||
|
||||
specialArgs = {inherit withSystem keys inputs self;};
|
||||
inherit (ooknet.lib.builders) mkServer mkWorkstation;
|
||||
in {
|
||||
ooksdesk = nixosSystem {
|
||||
inherit specialArgs;
|
||||
system = "x86_64-linux";
|
||||
modules = ["${hosts}/ooksdesk"] ++ workstation;
|
||||
};
|
||||
flake.nixosConfigurations = {
|
||||
ooksdesk = mkWorkstation {
|
||||
inherit withSystem;
|
||||
hostname = "ooksdesk";
|
||||
system = "x86_64-linux";
|
||||
type = "desktop";
|
||||
};
|
||||
|
||||
ookst480s = nixosSystem {
|
||||
inherit specialArgs;
|
||||
system = "x86_64-linux";
|
||||
modules = ["${hosts}/ookst480s"] ++ workstation;
|
||||
};
|
||||
ookst480s = mkWorkstation {
|
||||
inherit withSystem;
|
||||
system = "x86_64-linux";
|
||||
hostname = "ookst480s";
|
||||
type = "laptop";
|
||||
};
|
||||
|
||||
ooksmedia = nixosSystem {
|
||||
inherit specialArgs;
|
||||
system = "x86_64-linux";
|
||||
modules = ["${hosts}/ooksmedia" nixarr] ++ workstation;
|
||||
};
|
||||
ooksmedia = mkWorkstation {
|
||||
inherit withSystem;
|
||||
system = "x86_64-linux";
|
||||
hostname = "ooksmedia";
|
||||
type = "desktop";
|
||||
};
|
||||
|
||||
ooksmicro = nixosSystem {
|
||||
inherit specialArgs;
|
||||
system = "x86_64-linux";
|
||||
modules = ["${hosts}/ooksmicro"] ++ workstation;
|
||||
};
|
||||
ooksmicro = mkWorkstation {
|
||||
inherit withSystem;
|
||||
system = "x86_64-linux";
|
||||
hostname = "ooksmicro";
|
||||
};
|
||||
|
||||
ooksx1 = nixosSystem {
|
||||
inherit specialArgs;
|
||||
system = "x86_64-linux";
|
||||
modules = ["${hosts}/ooksx1"] ++ workstation;
|
||||
ooksx1 = mkWorkstation {
|
||||
inherit withSystem;
|
||||
system = "x86_64-linux";
|
||||
hostname = "ooksx1";
|
||||
};
|
||||
ooknode = mkServer {
|
||||
inherit withSystem;
|
||||
system = "x86_64-linux";
|
||||
hostname = "ooknode";
|
||||
};
|
||||
};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue