Skip to content

Instantly share code, notes, and snippets.

@infinisil
Created January 29, 2019 21:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save infinisil/c62c9f611369f511a9e7a930c5a31c00 to your computer and use it in GitHub Desktop.
Save infinisil/c62c9f611369f511a9e7a930c5a31c00 to your computer and use it in GitHub Desktop.
{ lib, ... }: with lib; {
config = {
fileSystems."/".device = "/dev/sda";
boot.loader.grub.device = "nodev";
};
options.fileSystems = mkOption {
type = types.loaOf (types.submodule ({ name, ... }: {
config = mkIf (name == "/foo") {
options = [ "foo" ];
};
}));
};
}
@infinisil
Copy link
Author

Is equivalent to:

{ lib, ... }: with lib; {

  imports = [ ./foo.nix ];

  fileSystems."/".device = "/dev/sda";
  boot.loader.grub.device = "nodev";
}

With foo.nix containing:

{ lib, ... }: with lib;
{
  options.fileSystems = mkOption {
    type = types.loaOf (types.submodule ({ name, ... }: {
      config = mkIf (name == "/foo") {
        options = [ "foo" ];
      };
    }));
  };
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment