Created
April 1, 2025 19:40
-
-
Save danidiaz/efd1aa2c934972ecc099eaca75c8ec88 to your computer and use it in GitHub Desktop.
Basic example of Nix modules
This file contains 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
{ | |
description = "A very basic example of modules"; | |
inputs = { | |
nixpkgs.url = "github:nixos/nixpkgs?ref=nixos-unstable"; | |
}; | |
outputs = { self, nixpkgs }: { | |
# nix eval .#.lib.boo.config | |
lib = { | |
boo = nixpkgs.lib.evalModules { | |
modules = [ | |
({lib, ...} : { | |
options = | |
{ | |
a = lib.mkOption { type = lib.types.str; }; | |
b = lib.mkOption { type = lib.types.str; }; | |
c = lib.mkOption { type = lib.types.str; }; | |
}; | |
}) | |
({lib, ...} : { | |
config = { a = "aaa"; }; | |
}) | |
({lib, ...} : { | |
# https://nix.dev/tutorials/module-system/index.html | |
b = "bbb"; | |
}) | |
({ | |
# https://nix.dev/tutorials/module-system/index.html | |
c = "ccc"; | |
}) | |
]; | |
}; | |
# nix eval .#.lib.ty | |
ty = nixpkgs.lib.attrNames self.lib.boo.type; | |
}; | |
}; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment