a flake module to ease creating and managing multiple hosts in your nix flake.
7
fork

Configure Feed

Select the types of activity you want to include in your feed.

refactor: use __curPos instead of importing

+25 -40
+1 -12
flake-module.nix
··· 1 - { easy-hosts }: 2 1 { 3 2 lib, 4 3 inputs, ··· 11 10 inherit (lib.options) mkOption mkEnableOption literalExpression; 12 11 inherit (lib) types; 13 12 14 - inherit 15 - (import ./lib.nix { 16 - inherit 17 - lib 18 - inputs 19 - withSystem 20 - easy-hosts 21 - ; 22 - }) 13 + inherit (import ./lib.nix { inherit lib inputs withSystem; }) 23 14 constructSystem 24 15 mkHosts 25 16 buildHosts ··· 52 43 { 53 44 # module for flake-parts 54 45 _class = "flake"; 55 - # re-add `_file` after that gets stripped by `import`. Improves docs and errors 56 - _file = "${__curPos.file}"; 57 46 58 47 options = { 59 48 easy-hosts = {
+20 -22
flake.nix
··· 1 1 { 2 2 inputs = { }; 3 3 4 - outputs = 5 - { self }: 6 - { 7 - flakeModule = import ./flake-module.nix { easy-hosts = self; }; 8 - flakeModules.default = import ./flake-module.nix { easy-hosts = self; }; 4 + outputs = _: { 5 + flakeModule = ./flake-module.nix; 6 + flakeModules.default = ./flake-module.nix; 9 7 10 - templates = { 11 - multi = { 12 - path = ./examples/multi; 13 - description = "A multi-system flake with auto construction enabled, but only using x86_64-linux."; 14 - }; 8 + templates = { 9 + multi = { 10 + path = ./examples/multi; 11 + description = "A multi-system flake with auto construction enabled, but only using x86_64-linux."; 12 + }; 15 13 16 - multi-specialised = { 17 - path = ./examples/multi-specialised; 18 - description = "A multi-system flake with auto construction enabled, using the custom class system of easy-hosts"; 19 - }; 14 + multi-specialised = { 15 + path = ./examples/multi-specialised; 16 + description = "A multi-system flake with auto construction enabled, using the custom class system of easy-hosts"; 17 + }; 20 18 21 - not-auto = { 22 - path = ./examples/not-auto; 23 - description = "A flake with auto construction disabled, using only the `easyHosts.hosts` attribute."; 24 - }; 19 + not-auto = { 20 + path = ./examples/not-auto; 21 + description = "A flake with auto construction disabled, using only the `easyHosts.hosts` attribute."; 22 + }; 25 23 26 - only = { 27 - path = ./examples/only; 28 - description = "A flake with auto construction enabled, with only one class and a more 'flat' structure."; 29 - }; 24 + only = { 25 + path = ./examples/only; 26 + description = "A flake with auto construction enabled, with only one class and a more 'flat' structure."; 30 27 }; 31 28 }; 29 + }; 32 30 }
+4 -6
lib.nix
··· 2 2 lib, 3 3 inputs, 4 4 withSystem, 5 - easy-hosts, 6 - ... 7 5 }: 8 6 let 9 7 inherit (inputs) self; ··· 263 261 # well this is how we do it use it for all args that don't need to rosolve module structure 264 262 (singleton { 265 263 key = "easy-hosts#specialArgs"; 266 - _file = "${easy-hosts.outPath}/lib.nix"; 264 + _file = "${__curPos.file}"; 267 265 268 266 _module.args = withSystem system ( 269 267 { self', inputs', ... }: ··· 277 275 # like the system type and the hostname 278 276 (singleton { 279 277 key = "easy-hosts#hostname"; 280 - _file = "${easy-hosts.outPath}/lib.nix"; 278 + _file = "${__curPos.file}"; 281 279 282 280 # we set the systems hostname based on the host value 283 281 # which should be a string that is the hostname of the system ··· 286 284 287 285 (singleton { 288 286 key = "easy-hosts#nixpkgs"; 289 - _file = "${easy-hosts.outPath}/lib.nix"; 287 + _file = "${__curPos.file}"; 290 288 291 289 nixpkgs = { 292 290 # you can also do this as `inherit system;` with the normal `lib.nixosSystem` ··· 305 303 # modules, if this is not set then you will get an error 306 304 (optionals (class == "darwin") (singleton { 307 305 key = "easy-hosts#nixpkgs-darwin"; 308 - _file = "${easy-hosts.outPath}/lib.nix"; 306 + _file = "${__curPos.file}"; 309 307 310 308 # without supplying an upstream nixpkgs source, nix-darwin will not be able to build 311 309 # and will complain and log an error demanding that you must set this value