|
2 | 2 | , system ? builtins.currentSystem |
3 | 3 | , configuration ? <nixos-config> |
4 | 4 |
|
| 5 | +, flakeStr ? null # flake as named on the command line |
5 | 6 | , flakeUri ? null |
6 | 7 | , flakeAttr ? null |
7 | 8 | }: |
|
31 | 32 | (getFlakeOutput [ "packages" "${system}" "nixosConfigurations" "${flakeAttr}" ]); |
32 | 33 |
|
33 | 34 | flakeModule = getFlakeOutput [ "nixosModules" "${flakeAttr}" ]; |
| 35 | + |
| 36 | + nixosShellModules = |
| 37 | + if flakeSystem ? options.nixos-shell then |
| 38 | + [ nixos-shell-config ] |
| 39 | + else |
| 40 | + [ nixos-shell nixos-shell-config ]; |
34 | 41 | in |
35 | 42 | if flakeUri != null then |
36 | 43 | if flakeSystem != null then |
37 | | - flakeSystem.override |
38 | | - (attrs: { |
39 | | - modules = |
40 | | - let |
41 | | - nixosShellModules = |
42 | | - if flakeSystem ? options.nixos-shell then |
43 | | - [ nixos-shell-config ] |
44 | | - else |
45 | | - [ nixos-shell nixos-shell-config ]; |
46 | | - in |
47 | | - attrs.modules ++ nixosShellModules; |
48 | | - }) |
| 44 | + if flakeSystem ? "extendModules" then |
| 45 | + flakeSystem.extendModules { modules = nixosShellModules; } |
| 46 | + else if flakeSystem ? "override" then |
| 47 | + flakeSystem.override (attrs: { modules = attrs.modules ++ nixosShellModules; }) |
| 48 | + else |
| 49 | + throw '' |
| 50 | + '${flakeStr}#${flakeAttr}' is missing the expected 'override' attribute. |
| 51 | +
|
| 52 | + Please ensure that '${flakeStr}#${flakeAttr}' is an overridable attribute set by declaring it with 'lib.makeOverridable'. |
| 53 | +
|
| 54 | + For instance: |
| 55 | +
|
| 56 | + nixosConfigurations = let |
| 57 | + lib = nixpkgs.lib; |
| 58 | + in { |
| 59 | + "${flakeAttr}" = lib.makeOverridable lib.nixosSystem { |
| 60 | + # ... |
| 61 | + }; |
| 62 | + }; |
| 63 | +
|
| 64 | + Alternatively, upgrade to a version of nixpkgs that provides the 'extendModules' function on NixOS system configurations. |
| 65 | +
|
| 66 | + See https://github.com/Mic92/nixos-shell#start-a-virtual-machine for additional information. |
| 67 | + '' |
49 | 68 | else if flakeModule != null then |
50 | 69 | mkShellSystem flakeModule |
51 | 70 | else |
|
0 commit comments