Created
November 7, 2023 22:15
-
-
Save CRTified/69f83b3c1eef037413a400566e583cd3 to your computer and use it in GitHub Desktop.
Scoping of `self` demo
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
$ nix build .#nixosConfigurations.demo.config.system.build.toplevel | |
trace: I'm Mr. Meeseeks! Existence is pain! | |
trace: I'm Mr. Meeseeks! Look at me! |
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
{ self }: | |
{ config, lib, ... }: { | |
system.nixos.tags = [ (self.lib.doSomeStuff "Existence is pain!") ]; | |
} |
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
{ | |
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