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
|
# ooknet
|
||||||
description = "a nix configuration written by an orangutan";
|
description = "a nix configuration written by an orangutan";
|
||||||
|
|
||||||
outputs = {
|
outputs = {flake-parts, ...} @ inputs:
|
||||||
flake-parts,
|
flake-parts.lib.mkFlake {inherit inputs;} {
|
||||||
self,
|
|
||||||
...
|
|
||||||
} @ inputs:
|
|
||||||
flake-parts.lib.mkFlake {inherit inputs;} ({withSystem, ...}: {
|
|
||||||
systems = import inputs.systems;
|
systems = import inputs.systems;
|
||||||
|
imports = [./outputs];
|
||||||
imports = [
|
};
|
||||||
./outputs/pkgs
|
|
||||||
./outputs/sshKeys.nix
|
|
||||||
];
|
|
||||||
|
|
||||||
flake = {
|
|
||||||
nixosConfigurations = import ./outputs/nixos.nix {inherit self inputs withSystem;};
|
|
||||||
};
|
|
||||||
|
|
||||||
perSystem = {pkgs, ...}: {
|
|
||||||
formatter = pkgs.alejandra;
|
|
||||||
};
|
|
||||||
});
|
|
||||||
|
|
||||||
# External inputs we depend on
|
# External inputs we depend on
|
||||||
inputs = {
|
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,
|
self,
|
||||||
withSystem,
|
withSystem,
|
||||||
|
ooknet,
|
||||||
...
|
...
|
||||||
}: let
|
}: let
|
||||||
inherit (inputs.nixpkgs.lib) nixosSystem;
|
inherit (ooknet.lib.builders) mkServer mkWorkstation;
|
||||||
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;};
|
|
||||||
in {
|
in {
|
||||||
ooksdesk = nixosSystem {
|
flake.nixosConfigurations = {
|
||||||
inherit specialArgs;
|
ooksdesk = mkWorkstation {
|
||||||
system = "x86_64-linux";
|
inherit withSystem;
|
||||||
modules = ["${hosts}/ooksdesk"] ++ workstation;
|
hostname = "ooksdesk";
|
||||||
};
|
system = "x86_64-linux";
|
||||||
|
type = "desktop";
|
||||||
|
};
|
||||||
|
|
||||||
ookst480s = nixosSystem {
|
ookst480s = mkWorkstation {
|
||||||
inherit specialArgs;
|
inherit withSystem;
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
modules = ["${hosts}/ookst480s"] ++ workstation;
|
hostname = "ookst480s";
|
||||||
};
|
type = "laptop";
|
||||||
|
};
|
||||||
|
|
||||||
ooksmedia = nixosSystem {
|
ooksmedia = mkWorkstation {
|
||||||
inherit specialArgs;
|
inherit withSystem;
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
modules = ["${hosts}/ooksmedia" nixarr] ++ workstation;
|
hostname = "ooksmedia";
|
||||||
};
|
type = "desktop";
|
||||||
|
};
|
||||||
|
|
||||||
ooksmicro = nixosSystem {
|
ooksmicro = mkWorkstation {
|
||||||
inherit specialArgs;
|
inherit withSystem;
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
modules = ["${hosts}/ooksmicro"] ++ workstation;
|
hostname = "ooksmicro";
|
||||||
};
|
};
|
||||||
|
|
||||||
ooksx1 = nixosSystem {
|
ooksx1 = mkWorkstation {
|
||||||
inherit specialArgs;
|
inherit withSystem;
|
||||||
system = "x86_64-linux";
|
system = "x86_64-linux";
|
||||||
modules = ["${hosts}/ooksx1"] ++ workstation;
|
hostname = "ooksx1";
|
||||||
|
};
|
||||||
|
ooknode = mkServer {
|
||||||
|
inherit withSystem;
|
||||||
|
system = "x86_64-linux";
|
||||||
|
hostname = "ooknode";
|
||||||
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue