Last active
July 9, 2024 19:54
-
-
Save Noah765/4332c33297e03f3e9ffbee2efb3e5893 to your computer and use it in GitHub Desktop.
Combined Manager debugging
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| inputs.nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable"; | |
| outputs = | |
| inputs: | |
| let | |
| lib = inputs.nixpkgs.lib; | |
| combinedManagerToNixosConfig = | |
| config: | |
| config | |
| // { | |
| class = "nixos"; | |
| options = config.options.os; | |
| config = config.config.os; | |
| }; | |
| in | |
| { | |
| nixosConfigurations.default = combinedManagerToNixosConfig ( | |
| lib.evalModules { | |
| modules = [ | |
| ( | |
| { options, config, ... }: | |
| { | |
| options = { | |
| os = lib.mkOption { | |
| type = lib.types.submoduleWith { | |
| modules = | |
| import "${inputs.nixpkgs}/nixos/modules/module-list.nix" | |
| ++ [ | |
| { | |
| nixpkgs.system = "x86_64-linux"; # Required for some module args | |
| } | |
| ] | |
| ++ [ | |
| ( | |
| { config, lib, ... }: | |
| { | |
| options = { | |
| environment.persistence = lib.mkOption { | |
| default = { }; | |
| type = | |
| with lib.types; | |
| attrsOf ( | |
| lib.types.submodule ( | |
| { name, ... }: | |
| { | |
| options = { | |
| persistentStoragePath = lib.mkOption { | |
| type = path; | |
| default = name; | |
| }; | |
| files = lib.mkOption { | |
| default = [ ]; | |
| type = listOf (submodule { | |
| options = { | |
| persistentStoragePath = lib.mkOption { | |
| type = path; | |
| default = config.environment.persistence.${name}.persistentStoragePath; | |
| }; | |
| file = lib.mkOption { type = str; }; | |
| }; | |
| }); | |
| }; | |
| }; | |
| } | |
| ) | |
| ); | |
| }; | |
| }; | |
| config.systemd.services."${(lib.head config.environment.persistence."/persist/system".files) | |
| .persistentStoragePath | |
| }" = { }; | |
| } | |
| ) | |
| ]; | |
| }; | |
| }; | |
| }; | |
| config = { | |
| os.environment.persistence."/persist/system".files = [ { file = "/test"; } ]; | |
| impermanence.files = [ { file = "/etc/test"; } ]; | |
| }; | |
| imports = [ | |
| { | |
| options.impermanence.files = | |
| (lib.evalModules { | |
| modules = | |
| [ { _module.args.name = "/persist/system"; } ] | |
| ++ (options.os.type.getSubOptions [ ]) | |
| .environment.persistence.type.nestedTypes.elemType.getSubModules; | |
| }).options.files; | |
| config.os.environment.persistence."/persist/system".files = config.impermanence.files; | |
| } | |
| ]; | |
| } | |
| ) | |
| ]; | |
| } | |
| ); | |
| }; | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment