From e8a1db296c73847e88cba76a655167a78a8f157a Mon Sep 17 00:00:00 2001 From: guangtao Date: Tue, 19 Sep 2023 21:53:26 -0700 Subject: [PATCH] refactor: done the minor version --- examples/nixos/_test.nix | 16 ++++ examples/nixos/default.nix | 107 +++++----------------- examples/nixos/pops/homeModules.nix | 20 +++- examples/nixos/pops/homeProfiles.nix | 23 ++++- examples/nixos/pops/nixosModules.nix | 6 ++ examples/nixos/pops/nixosProfiles.nix | 32 ++++++- examples/nixos/pops/selfNixOSProfiles.nix | 5 +- flake.nix | 1 + 8 files changed, 121 insertions(+), 89 deletions(-) create mode 100644 examples/nixos/_test.nix diff --git a/examples/nixos/_test.nix b/examples/nixos/_test.nix new file mode 100644 index 0000000..f731e38 --- /dev/null +++ b/examples/nixos/_test.nix @@ -0,0 +1,16 @@ +( + { + lib, + config, + options, + ... + }@args: + { + options = { + __test__ = lib.mkOption { + type = lib.types.attrs; + default = { }; + }; + }; + } +) diff --git a/examples/nixos/default.nix b/examples/nixos/default.nix index f1ffb24..125380a 100644 --- a/examples/nixos/default.nix +++ b/examples/nixos/default.nix @@ -1,92 +1,35 @@ let - pops = lib.mapAttrs (_: v: v.outputsForTarget) ( + pops = lib.mapAttrs (_: v: v.exports) ( lib.removeAttrs super.pops [ "inputs__" ] ); in { - nixosSuites = - let - customProfiles = { - nix = - (pops.nixosProfiles.dmerge { - nix.extraOptions = '' - allowed-uris = https://github.com/ - ''; - }) - [ - "presets" - "nix" - ]; - boot = - (pops.nixosProfiles.dmerge { - # boot.__profiles__.systemd-initrd.enable = true; - boot.__profiles__.systemd-boot.enable = true; - }) - [ - "presets" - "boot" - ]; - }; - in - lib.flatten [ - pops.selfNixOSProfiles.default.bootstrap + nixosSuites = lib.flatten [ + pops.selfNixOSProfiles.default.bootstrap - # self.nixosProfiles.default.presets.boot - customProfiles.boot + # self.nixosProfiles.default.presets.boot + pops.nixosModules.default.programs.git - pops.nixosModules.default.programs.git + # --custom profiles + pops.nixosProfiles.customProfiles.nix + pops.nixosProfiles.customProfiles.boot - # ( - # { - # lib, - # config, - # options, - # ... - # }@args: - # { - # options = { - # __test__ = lib.mkOption { - # type = lib.types.attrs; - # default = ; - # }; - # }; - # } - # ) + (selfLib.mkHome + { + admin = { + uid = 1000; + description = "default manager"; + isNormalUser = true; + extraGroups = [ "wheel" ]; + }; + } + "zsh" + self.homeSuites + ) + ]; - # --custom profiles - customProfiles.nix - - (selfLib.mkHome - { - admin = { - uid = 1000; - description = "default manager"; - isNormalUser = true; - extraGroups = [ "wheel" ]; - }; - } - "zsh" - self.homeSuites - ) - ]; - - homeSuites = - let - customProfiles = { - hyprland = - (pops.homeProfiles.dmerge { - wayland.windowManager.hyprland.__profiles__ = { - nvidia = true; - }; - }) - [ - "presets" - "hyprland" - ]; - }; - in - [ - customProfiles.hyprland - # self.homeModules.wayland.windowManager.hyprland - ]; + homeSuites = [ + pops.homeProfiles.customProfiles.hyprland + # self.homeModules.wayland.windowManager.hyprland + ]; } diff --git a/examples/nixos/pops/homeModules.nix b/examples/nixos/pops/homeModules.nix index 93d67ba..f0eae86 100644 --- a/examples/nixos/pops/homeModules.nix +++ b/examples/nixos/pops/homeModules.nix @@ -1 +1,19 @@ -loadHomeModules.addLoadExtender { inputs = super.inputs__.outputs // { }; } +(loadHomeModules.addLoadExtender { inputs = super.inputs__.outputs // { }; }) +.addExporters + [ + (POP.extendPop flops.haumea.pops.exporter ( + self: super: { + exports.customModules.git = + self.outputsForTarget.dmerge + { + enable = false; + customList = with dmerge; append [ "1" ]; + imports = with dmerge; append [ ]; + } + [ + "services" + "openssh" + ]; + } + )) + ] diff --git a/examples/nixos/pops/homeProfiles.nix b/examples/nixos/pops/homeProfiles.nix index 70aa0f3..350214c 100644 --- a/examples/nixos/pops/homeProfiles.nix +++ b/examples/nixos/pops/homeProfiles.nix @@ -1,7 +1,26 @@ -loadHomeProfiles.addLoadExtender { +(loadHomeProfiles.addLoadExtender { inputs = super.inputs__.outputs // { POS = { homeModules = super.homeModules.outputsForTarget.nixosModules; }; }; -} +}).addExporters + [ + (POP.extendPop flops.haumea.pops.exporter ( + self: super: { + exports.customProfiles = { + hyprland = + self.outputsForTarget.dmerge + { + wayland.windowManager.hyprland.__profiles__ = { + nvidia = true; + }; + } + [ + "presets" + "hyprland" + ]; + }; + } + )) + ] diff --git a/examples/nixos/pops/nixosModules.nix b/examples/nixos/pops/nixosModules.nix index 6045f00..87ebcb1 100644 --- a/examples/nixos/pops/nixosModules.nix +++ b/examples/nixos/pops/nixosModules.nix @@ -1 +1,7 @@ (loadNixOSModules.addLoadExtender { inputs = super.inputs__.outputs // { }; }) +.addExporters + [ + (POP.extendPop flops.haumea.pops.exporter ( + self: super: { exports.customModules = { }; } + )) + ] diff --git a/examples/nixos/pops/nixosProfiles.nix b/examples/nixos/pops/nixosProfiles.nix index 15e9db6..b67fc8e 100644 --- a/examples/nixos/pops/nixosProfiles.nix +++ b/examples/nixos/pops/nixosProfiles.nix @@ -1,7 +1,35 @@ -loadNixOSProfiles.addLoadExtender { +(loadNixOSProfiles.addLoadExtender { inputs = super.inputs__.outputs // { POS = { nixosModules = super.nixosModules.outputsForTarget.nixosModules; }; }; -} +}).addExporters + [ + (POP.extendPop flops.haumea.pops.exporter ( + self: super: { + exports.customProfiles = { + nix = + self.outputsForTarget.dmerge + { + nix.extraOptions = '' + allowed-uris = https://github.com/ + ''; + } + [ + "presets" + "nix" + ]; + boot = + (self.outputsForTarget.dmerge { + # boot.__profiles__.systemd-initrd.enable = true; + boot.__profiles__.systemd-boot.enable = true; + }) + [ + "presets" + "boot" + ]; + }; + } + )) + ] diff --git a/examples/nixos/pops/selfNixOSProfiles.nix b/examples/nixos/pops/selfNixOSProfiles.nix index d79341a..cecfb0d 100644 --- a/examples/nixos/pops/selfNixOSProfiles.nix +++ b/examples/nixos/pops/selfNixOSProfiles.nix @@ -1,4 +1,4 @@ -super.nixosProfiles.addLoadExtender { +(super.nixosProfiles.addLoadExtender { src = ../__nixosProfiles; loader = haumea.loaders.scoped; type = "nixosProfiles"; @@ -7,4 +7,5 @@ super.nixosProfiles.addLoadExtender { nixosProfiles = super.nixosProfiles.outputsForTarget.nixosProfiles; }; }; -} +}).addExporters + [ (POP.extendPop flops.haumea.pops.exporter (self: super: { })) ] diff --git a/flake.nix b/flake.nix index 524a5b7..1475510 100644 --- a/flake.nix +++ b/flake.nix @@ -76,6 +76,7 @@ lib = nixpkgs.lib // builtins; flops = flops.lib; haumea = flops.inputs.haumea.lib; + dmerge = flops.inputs.dmerge; POP = POP.lib; selfLib = lib.outputsForTarget.default; };