feat: flake interface definition
This commit is contained in:
commit
b4625b5719
12
flake.nix
Normal file
12
flake.nix
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
{
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11";
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = inputs: {
|
||||||
|
nixosModules = {
|
||||||
|
users = (import ./users) inputs;
|
||||||
|
hosts = (import ./hosts) inputs;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
9
hosts/default.nix
Normal file
9
hosts/default.nix
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
inputs @ {nixpkgs, ...}:
|
||||||
|
let
|
||||||
|
inherit (nixpkgs) lib;
|
||||||
|
isDir = _name: type: type == "directory";
|
||||||
|
directoriesAsModules = dir: (builtins.mapAttrs
|
||||||
|
(name: _value: dir + "/${name}")
|
||||||
|
(lib.filterAttrs isDir (builtins.readDir dir))
|
||||||
|
);
|
||||||
|
in directoriesAsModules ./.
|
8
hosts/git.example.tld/default.nix
Normal file
8
hosts/git.example.tld/default.nix
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
inputs @ {config, ...}:
|
||||||
|
let
|
||||||
|
allusers = (import ../../users) inputs;
|
||||||
|
{
|
||||||
|
users.users = {
|
||||||
|
inherit (allUsers) alice bob;
|
||||||
|
}
|
||||||
|
}
|
8
hosts/web.example.org/default.nix
Normal file
8
hosts/web.example.org/default.nix
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
inputs @ {config, ...}:
|
||||||
|
let
|
||||||
|
allusers = (import ../../users) inputs;
|
||||||
|
{
|
||||||
|
users.users = {
|
||||||
|
inherit (allUsers) alice bob mallory root;
|
||||||
|
}
|
||||||
|
}
|
13
users/alice/default.nix
Normal file
13
users/alice/default.nix
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
{config, lib, pkgs, ...}:
|
||||||
|
{
|
||||||
|
isNormalUser = true;
|
||||||
|
description = "Alice Lastname";
|
||||||
|
packages = with pkgs; [
|
||||||
|
"firefox"
|
||||||
|
"element-desktop"
|
||||||
|
];
|
||||||
|
extraGroups = [
|
||||||
|
"audio"
|
||||||
|
"video"
|
||||||
|
];
|
||||||
|
}
|
14
users/bob/default.nix
Normal file
14
users/bob/default.nix
Normal file
@ -0,0 +1,14 @@
|
|||||||
|
{config, lib, pkgs, ...}:
|
||||||
|
{
|
||||||
|
isNormalUser = true;
|
||||||
|
description = "Bob TheBuilder";
|
||||||
|
packages = with pkgs; [
|
||||||
|
"firefox-beta"
|
||||||
|
"element-desktop"
|
||||||
|
];
|
||||||
|
extraGroups = [
|
||||||
|
"audio"
|
||||||
|
"video"
|
||||||
|
"docker"
|
||||||
|
];
|
||||||
|
}
|
18
users/default.nix
Normal file
18
users/default.nix
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
{config, lib, ...}:
|
||||||
|
let
|
||||||
|
alice = import ./alice;
|
||||||
|
bob = import ./bob;
|
||||||
|
mallory = import ./mallory;
|
||||||
|
isSystemUser = _name: userConfig: userConfig.isSystemUser == true;
|
||||||
|
in
|
||||||
|
{
|
||||||
|
users.users = {
|
||||||
|
inherit alice;
|
||||||
|
inherit bob;
|
||||||
|
root = {
|
||||||
|
openssh.authorizedKeys.keys = lib.lists.flatten (attrValues (lib.mapAttrs
|
||||||
|
(_name: userConfig: userConfig.openssh.authorizedKeys.keys)
|
||||||
|
(lib.filterAttrs isSystemUser config.users.users)))
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
11
users/mallory/default.nix
Normal file
11
users/mallory/default.nix
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{config, lib, pkgs, ...}:
|
||||||
|
{
|
||||||
|
isSystemUser = true;
|
||||||
|
description = "muahahaaa";
|
||||||
|
packages = with pkgs; [
|
||||||
|
"mtr"
|
||||||
|
"nmap"
|
||||||
|
"pwntools"
|
||||||
|
"hexedit"
|
||||||
|
];
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user