From b591125ac56d7b1f6df7c64d1ca4167e3daadedf Mon Sep 17 00:00:00 2001 From: guangtao Date: Tue, 3 Oct 2023 22:35:15 -0700 Subject: [PATCH] feat: WIP add nixos example --- templates/nixos/lib/exporters.nix | 4 +- templates/nixos/lib/nixos.nix | 14 +++++- .../nixos/darwinModules/services/yabai.nix | 1 + .../nixos/darwinProfiles/presets/yabai.nix | 1 + .../nixos/homeModules/programs/emacs.nix | 8 +++ .../nixos/homeProfiles/presets/emacs.nix | 4 ++ templates/nixos/nixos/hosts/nixos/layouts.nix | 17 +++---- .../nixos/hosts/nixos/pops/homeProfiles.nix | 9 +--- .../nixos/nixos/hosts/nixos/pops/inputs.nix | 7 +-- .../nixos/hosts/nixos/pops/nixosProfiles.nix | 49 ++++++------------- templates/nixos/nixos/nixosModules/boot.nix | 8 +++ .../nixos/nixosProfiles/presets/boot.nix | 4 ++ 12 files changed, 65 insertions(+), 61 deletions(-) create mode 100644 templates/nixos/nixos/darwinModules/services/yabai.nix create mode 100644 templates/nixos/nixos/darwinProfiles/presets/yabai.nix create mode 100644 templates/nixos/nixos/homeModules/programs/emacs.nix create mode 100644 templates/nixos/nixos/homeProfiles/presets/emacs.nix create mode 100644 templates/nixos/nixos/nixosModules/boot.nix create mode 100644 templates/nixos/nixos/nixosProfiles/presets/boot.nix diff --git a/templates/nixos/lib/exporters.nix b/templates/nixos/lib/exporters.nix index 08b071e..e63729b 100644 --- a/templates/nixos/lib/exporters.nix +++ b/templates/nixos/lib/exporters.nix @@ -11,9 +11,7 @@ in (inputs.omnibus.exporters.addLoadExtender { src = ../nixos/hosts; inputs = inputs // { - self' = { - inherit (super) inputs; - }; + self'.lib = super; omnibus = inputs.omnibus.lib // { lib = super.omnibus.lib.outputs.default; }; diff --git a/templates/nixos/lib/nixos.nix b/templates/nixos/lib/nixos.nix index b95b53f..4eca0bc 100644 --- a/templates/nixos/lib/nixos.nix +++ b/templates/nixos/lib/nixos.nix @@ -3,10 +3,20 @@ (omnibus.loadHomeModules.addLoadExtender { src = ../nixos/homeModules; }); loadHomeProfiles = - (omnibus.loadHomeProfiles.addLoadExtender { src = ../nixos/homeProfiles; }); + (omnibus.loadHomeProfiles.addLoadExtender { + src = ../nixos/homeProfiles; + inputs = { + homeModules = self.loadHomeModules.outputs.default; + }; + }); loadNixOSProfiles = - (omnibus.loadNixOSProfiles.addLoadExtender { src = ../nixos/nixosProfiles; }); + (omnibus.loadNixOSProfiles.addLoadExtender { + src = ../nixos/nixosProfiles; + inputs = { + nixosModules = self.loadNixOSModules.outputs.default; + }; + }); loadNixOSModules = (omnibus.loadNixOSModules.addLoadExtender { src = ../nixos/nixosModules; }); diff --git a/templates/nixos/nixos/darwinModules/services/yabai.nix b/templates/nixos/nixos/darwinModules/services/yabai.nix new file mode 100644 index 0000000..ffcd441 --- /dev/null +++ b/templates/nixos/nixos/darwinModules/services/yabai.nix @@ -0,0 +1 @@ +{ } diff --git a/templates/nixos/nixos/darwinProfiles/presets/yabai.nix b/templates/nixos/nixos/darwinProfiles/presets/yabai.nix new file mode 100644 index 0000000..e303088 --- /dev/null +++ b/templates/nixos/nixos/darwinProfiles/presets/yabai.nix @@ -0,0 +1 @@ +{ servcies.yabai.enable = true; } diff --git a/templates/nixos/nixos/homeModules/programs/emacs.nix b/templates/nixos/nixos/homeModules/programs/emacs.nix new file mode 100644 index 0000000..d1185b9 --- /dev/null +++ b/templates/nixos/nixos/homeModules/programs/emacs.nix @@ -0,0 +1,8 @@ +{ + options.__profiles__ = with lib; { + test = mkOption { + type = types.str; + default = "test"; + }; + }; +} diff --git a/templates/nixos/nixos/homeProfiles/presets/emacs.nix b/templates/nixos/nixos/homeProfiles/presets/emacs.nix new file mode 100644 index 0000000..5caaddc --- /dev/null +++ b/templates/nixos/nixos/homeProfiles/presets/emacs.nix @@ -0,0 +1,4 @@ +{ + imports = [ homeModules.programs.emacs ]; + programs.emacs.__profiles__.test = "profile.test"; +} diff --git a/templates/nixos/nixos/hosts/nixos/layouts.nix b/templates/nixos/nixos/hosts/nixos/layouts.nix index ef9b4a6..8c591c0 100644 --- a/templates/nixos/nixos/hosts/nixos/layouts.nix +++ b/templates/nixos/nixos/hosts/nixos/layouts.nix @@ -11,7 +11,7 @@ in nixosSuites = lib.flatten [ # outputs.selfNixOSProfiles.default.bootstrap - # # self.nixosProfiles.default.presets.boot + outputs.nixosProfiles.default.presets.boot # outputs.nixosModules.default.programs.git # # # --custom profiles @@ -34,12 +34,11 @@ in ) ]; - homeSuites = - [ - # outputs.homeProfiles.customProfiles.presets.hyprland - # outputs.homeProfiles.default.presets.bat - # # # The parent directory of "presets" is categorized as a list type of "suites" - # (outputs.homeProfiles.default.shell { }).default - # super.pops.homeModules.outputs.default.wayland.windowManager.hyprland - ]; + homeSuites = [ + outputs.homeProfiles.default.presets.emacs + # outputs.homeProfiles.default.presets.bat + # # # The parent directory of "presets" is categorized as a list type of "suites" + # (outputs.homeProfiles.default.shell { }).default + # super.pops.homeModules.outputs.default.wayland.windowManager.hyprland + ]; } diff --git a/templates/nixos/nixos/hosts/nixos/pops/homeProfiles.nix b/templates/nixos/nixos/hosts/nixos/pops/homeProfiles.nix index ff0c715..b660810 100644 --- a/templates/nixos/nixos/hosts/nixos/pops/homeProfiles.nix +++ b/templates/nixos/nixos/hosts/nixos/pops/homeProfiles.nix @@ -1,10 +1,5 @@ -(omnibus.loadHomeProfiles.addLoadExtender { - inputs = super.inputs.outputs // { - omnibus = { - homeModules = super.homeModules.outputs.nixosModules; - }; - }; -}).addExporters +(self'.lib.nixos.loadHomeProfiles.addLoadExtender { inputs = { }; }) +.addExporters [ (POP.extendPop flops.haumea.pops.exporter ( self: super: { diff --git a/templates/nixos/nixos/hosts/nixos/pops/inputs.nix b/templates/nixos/nixos/hosts/nixos/pops/inputs.nix index 6e54b7a..386d8d1 100644 --- a/templates/nixos/nixos/hosts/nixos/pops/inputs.nix +++ b/templates/nixos/nixos/hosts/nixos/pops/inputs.nix @@ -1,14 +1,11 @@ -(self'.inputs.loadInputs.addInputsExtender ( +(self'.lib.inputs.addInputsExtender ( POP.extendPop flops.flake.pops.inputsExtender ( self: super: let selfInputs = omnibus.loadInputs.setInitInputs ../__lock; in { - inputs = { - std = local.outputs.std; - nixpkgs = omnibus.loadInputs.outputs.nixpkgs.legacyPackages; - } // selfInputs.outputs; + inputs = { } // selfInputs.outputs; } ) )).setSystem diff --git a/templates/nixos/nixos/hosts/nixos/pops/nixosProfiles.nix b/templates/nixos/nixos/hosts/nixos/pops/nixosProfiles.nix index 06fa7b4..83ebba9 100644 --- a/templates/nixos/nixos/hosts/nixos/pops/nixosProfiles.nix +++ b/templates/nixos/nixos/hosts/nixos/pops/nixosProfiles.nix @@ -1,41 +1,20 @@ -(omnibus.loadNixOSProfiles.addLoadExtender { - inputs = super.inputs.outputs // { - omnibus = { - nixosModules = super.nixosModules.outputs.nixosModules; - }; - }; -}).addExporters +(self'.lib.nixos.loadNixOSProfiles.addLoadExtender { inputs = { }; }) +.addExporters [ (POP.extendPop flops.haumea.pops.exporter ( self: super: { - exports.customProfiles = self.outputs.__extenders [ - { - value = - { selfModule' }: - selfModule' ( - m: - dmerge m { - nix.extraOptions = '' - allowed-uris = https://github.com/ - ''; - } - ); - path = [ - "presets" - "nix" - ]; - } - { - # boot.__profiles__.systemd-initrd.enable = true; - value = - { selfModule' }: - selfModule' (m: dmerge m { boot.__profiles__.systemd-boot.enable = true; }); - path = [ - "presets" - "boot" - ]; - } - ]; + exports.customProfiles = self.outputs.__extenders [ { + # boot.__profiles__.systemd-initrd.enable = true; + value = + { selfModule' }: + selfModule' ( + m: dmerge m { boot.__profiles__.test = "nixosProfiles.test with Dmerge"; } + ); + path = [ + "presets" + "boot" + ]; + } ]; } )) ] diff --git a/templates/nixos/nixos/nixosModules/boot.nix b/templates/nixos/nixos/nixosModules/boot.nix new file mode 100644 index 0000000..d1185b9 --- /dev/null +++ b/templates/nixos/nixos/nixosModules/boot.nix @@ -0,0 +1,8 @@ +{ + options.__profiles__ = with lib; { + test = mkOption { + type = types.str; + default = "test"; + }; + }; +} diff --git a/templates/nixos/nixos/nixosProfiles/presets/boot.nix b/templates/nixos/nixos/nixosProfiles/presets/boot.nix new file mode 100644 index 0000000..9aaccd5 --- /dev/null +++ b/templates/nixos/nixos/nixosProfiles/presets/boot.nix @@ -0,0 +1,4 @@ +{ + imports = [ nixosModules.boot ]; + boot.__profiles__.test = "nixosProfiles.boot"; +}