From e02411d5636ac677b18d23bdb74c008ae5c4c76c Mon Sep 17 00:00:00 2001 From: Mohammad Rafiq Date: Tue, 15 Jul 2025 22:51:00 +0800 Subject: [PATCH 1/2] feat(flake): add manifest input and module import --- flake.lock | 16 ++++++++ flake.nix | 2 + nix/flake-parts/manifest.nix | 77 +----------------------------------- 3 files changed, 20 insertions(+), 75 deletions(-) diff --git a/flake.lock b/flake.lock index 21693cb..9d72b1b 100644 --- a/flake.lock +++ b/flake.lock @@ -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", diff --git a/flake.nix b/flake.nix index 5e22b8c..dcb6882 100644 --- a/flake.nix +++ b/flake.nix @@ -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. creates devShells and checks make-shell = { url = "github:nicknovitski/make-shell"; diff --git a/nix/flake-parts/manifest.nix b/nix/flake-parts/manifest.nix index 1d121a1..e61d29a 100644 --- a/nix/flake-parts/manifest.nix +++ b/nix/flake-parts/manifest.nix @@ -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 ]; } From ab627ac91948f4ca64cf78feef13e312d2d4084d Mon Sep 17 00:00:00 2001 From: Mohammad Rafiq Date: Tue, 15 Jul 2025 22:54:06 +0800 Subject: [PATCH 2/2] refactor(flake-parts): consolidate modules into one file --- nix/flake-parts/debug.nix | 3 --- nix/flake-parts/flake-parts.nix | 10 ++++++++++ nix/flake-parts/make-shell.nix | 5 ----- nix/flake-parts/manifest.nix | 4 ---- nix/flake-parts/modules.nix | 4 ---- nix/flake-parts/text.nix | 4 ---- 6 files changed, 10 insertions(+), 20 deletions(-) delete mode 100644 nix/flake-parts/debug.nix create mode 100644 nix/flake-parts/flake-parts.nix delete mode 100644 nix/flake-parts/make-shell.nix delete mode 100644 nix/flake-parts/manifest.nix delete mode 100644 nix/flake-parts/modules.nix delete mode 100644 nix/flake-parts/text.nix diff --git a/nix/flake-parts/debug.nix b/nix/flake-parts/debug.nix deleted file mode 100644 index 38e2cb3..0000000 --- a/nix/flake-parts/debug.nix +++ /dev/null @@ -1,3 +0,0 @@ -{ - debug = true; -} diff --git a/nix/flake-parts/flake-parts.nix b/nix/flake-parts/flake-parts.nix new file mode 100644 index 0000000..4f0d093 --- /dev/null +++ b/nix/flake-parts/flake-parts.nix @@ -0,0 +1,10 @@ +{ inputs, ... }: +{ + debug = true; + imports = [ + inputs.make-shell.flakeModules.default + inputs.manifest.flakeModules.default + inputs.flake-parts.flakeModules.modules + inputs.text.flakeModules.default + ]; +} diff --git a/nix/flake-parts/make-shell.nix b/nix/flake-parts/make-shell.nix deleted file mode 100644 index 66ca600..0000000 --- a/nix/flake-parts/make-shell.nix +++ /dev/null @@ -1,5 +0,0 @@ -{ inputs, ... }: -{ - #TODO: add to readme - imports = [ inputs.make-shell.flakeModules.default ]; -} diff --git a/nix/flake-parts/manifest.nix b/nix/flake-parts/manifest.nix deleted file mode 100644 index e61d29a..0000000 --- a/nix/flake-parts/manifest.nix +++ /dev/null @@ -1,4 +0,0 @@ -{ inputs, ... }: -{ - imports = [ inputs.manifest.flakeModules.default ]; -} diff --git a/nix/flake-parts/modules.nix b/nix/flake-parts/modules.nix deleted file mode 100644 index 1c75663..0000000 --- a/nix/flake-parts/modules.nix +++ /dev/null @@ -1,4 +0,0 @@ -{ inputs, ... }: -{ - imports = [ inputs.flake-parts.flakeModules.modules ]; -} diff --git a/nix/flake-parts/text.nix b/nix/flake-parts/text.nix deleted file mode 100644 index 81b2f51..0000000 --- a/nix/flake-parts/text.nix +++ /dev/null @@ -1,4 +0,0 @@ -{ inputs, ... }: -{ - imports = [ inputs.text.flakeModules.default ]; -}