Skip to content

Instantly share code, notes, and snippets.

@CRTified
Created November 7, 2023 22:15
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save CRTified/69f83b3c1eef037413a400566e583cd3 to your computer and use it in GitHub Desktop.
Save CRTified/69f83b3c1eef037413a400566e583cd3 to your computer and use it in GitHub Desktop.
Scoping of `self` demo
$ nix build .#nixosConfigurations.demo.config.system.build.toplevel
trace: I'm Mr. Meeseeks! Existence is pain!
trace: I'm Mr. Meeseeks! Look at me!
{ self }:
{ config, lib, ... }: {
system.nixos.tags = [ (self.lib.doSomeStuff "Existence is pain!") ];
}
{
inputs.nixpkgs.url = "nixpkgs";
outputs = { self, nixpkgs }: {
nixosConfigurations.demo = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
self.nixosModules.sameFile
self.nixosModules.externalFile
{
boot.isContainer = true; # Hack to have an easy time building
system.stateVersion = "23.11";
}
];
};
nixosModules = {
sameFile = { config, lib, ... }: {
system.nixos.tags = [ (self.lib.doSomeStuff "Look at me!") ];
};
externalFile = import ./externalModule.nix { inherit self; };
};
lib.doSomeStuff = x: builtins.trace "I'm Mr. Meeseeks! ${x}" "Mr.Mee";
};
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment