feat(flake): add manifest input and module import

This commit is contained in:
Mohammad Rafiq 2025-07-15 22:51:00 +08:00
parent 021dadfed8
commit e02411d563
No known key found for this signature in database
3 changed files with 20 additions and 75 deletions

16
flake.lock generated
View file

@ -337,6 +337,21 @@
"type": "github"
}
},
"manifest": {
"locked": {
"lastModified": 1752588656,
"narHash": "sha256-clKPzQ43eDpukeiGHzXmd1hGb2s4N+MWXAzQ5u5+pHQ=",
"owner": "rrvsh",
"repo": "manifest",
"rev": "365902fba994f30469298dee0c98a5fc0f41ec38",
"type": "github"
},
"original": {
"owner": "rrvsh",
"repo": "manifest",
"type": "github"
}
},
"nix-darwin": {
"inputs": {
"nixpkgs": [
@ -488,6 +503,7 @@
"impermanence": "impermanence",
"import-tree": "import-tree",
"make-shell": "make-shell",
"manifest": "manifest",
"nix-darwin": "nix-darwin",
"nix-index-database": "nix-index-database",
"nixpkgs": "nixpkgs",

View file

@ -71,6 +71,8 @@
files.url = "github:mightyiam/files";
# text.nix lets us easily define markdown text to pass to files
text.url = "github:rrvsh/text.nix";
# manifest lets us define all hosts in one file
manifest.url = "github:rrvsh/manifest";
# make-shells.<name> creates devShells and checks
make-shell = {
url = "github:nicknovitski/make-shell";

View file

@ -1,77 +1,4 @@
{ lib, config, ... }:
let
cfg = config.flake;
inherit (lib.options) mkOption mkEnableOption;
inherit (lib.types)
bool
str
lazyAttrsOf
deferredModule
submodule
;
inherit (cfg.lib.options) mkStrOption;
inherit (cfg.lib.attrsets) firstAttrNameMatching;
userOpts = submodule {
options = {
primary = mkOption { type = bool; };
username = mkOption { type = str; };
name = mkOption { type = str; };
email = mkOption { type = str; };
shell = mkOption { type = str; };
pubkey = mkOption { type = str; };
};
};
monitorOpts = submodule {
options = {
id = mkStrOption "";
resolution = mkStrOption "";
refresh-rate = mkStrOption "";
scale = mkStrOption "";
};
};
hostOpts = submodule {
options = {
graphical = mkEnableOption "";
machine = {
platform = mkStrOption "";
gpu = mkStrOption "";
root.drive = mkStrOption "";
root.ephemeral = mkEnableOption "" // {
default = true;
};
monitors = mkOption {
type = lazyAttrsOf monitorOpts;
default = { };
};
};
extraCfg = mkOption {
type = deferredModule;
default = { };
};
};
};
username = firstAttrNameMatching (_: v: v.primary or false) config.manifest.users;
in
{ inputs, ... }:
{
options.manifest = {
admin = mkOption {
type = userOpts;
readOnly = true;
};
users = mkOption {
type = lazyAttrsOf userOpts;
default = { };
};
hosts.nixos = mkOption {
type = lazyAttrsOf hostOpts;
default = { };
};
hosts.darwin = mkOption {
type = lazyAttrsOf hostOpts;
default = { };
};
};
config.manifest.admin = config.manifest.users.${username} // {
inherit username;
};
imports = [ inputs.manifest.flakeModules.default ];
}