|
1 | 1 | # This module generates nixos-install, nixos-rebuild, |
2 | 2 | # nixos-generate-config, etc. |
3 | 3 |
|
4 | | -{ config, lib, pkgs, ... }: |
| 4 | +{ config, lib, pkgs, options, ... }: |
5 | 5 |
|
6 | 6 | let |
7 | 7 | makeProg = args: pkgs.replaceVarsWith (args // { |
|
23 | 23 | hostPlatformSystem = pkgs.stdenv.hostPlatform.system; |
24 | 24 | detectvirt = "${config.systemd.package}/bin/systemd-detect-virt"; |
25 | 25 | btrfs = "${pkgs.btrfs-progs}/bin/btrfs"; |
26 | | - inherit (config.system.nixos-generate-config) configuration desktopConfiguration; |
| 26 | + inherit (config.system.nixos-generate-config) configuration desktopConfiguration flake; |
27 | 27 | xserverEnabled = config.services.xserver.enable; |
28 | 28 | }; |
29 | 29 | manPage = ./manpages/nixos-generate-config.8; |
|
55 | 55 | withReexec = true; |
56 | 56 | }; |
57 | 57 |
|
| 58 | + defaultFlakeTemplate = '' |
| 59 | + { |
| 60 | + inputs = { |
| 61 | + # This is pointing to an unstable release. |
| 62 | + # If you prefer a stable release instead, you can this to the latest number shown here: https://nixos.org/download |
| 63 | + # i.e. nixos-24.11 |
| 64 | + # Use `nix flake update` to update the flake to the latest revision of the chosen release channel. |
| 65 | + nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable"; |
| 66 | + }; |
| 67 | + outputs = inputs\@{ self, nixpkgs, ... }: { |
| 68 | + # NOTE: '${options.networking.hostName.default}' is the default hostname |
| 69 | + nixosConfigurations.${options.networking.hostName.default} = nixpkgs.lib.nixosSystem { |
| 70 | + modules = [ ./configuration.nix ]; |
| 71 | + }; |
| 72 | + }; |
| 73 | + } |
| 74 | + ''; |
| 75 | + |
58 | 76 | defaultConfigTemplate = '' |
59 | 77 | # Edit this configuration file to define what should be installed on |
60 | 78 | # your system. Help is available in the configuration.nix(5) man page, on |
|
176 | 194 | in |
177 | 195 | { |
178 | 196 | options.system.nixos-generate-config = { |
| 197 | + |
| 198 | + flake = lib.mkOption { |
| 199 | + internal = true; |
| 200 | + type = lib.types.str; |
| 201 | + default = defaultFlakeTemplate; |
| 202 | + description = '' |
| 203 | + The NixOS module that `nixos-generate-config` |
| 204 | + saves to `/etc/nixos/flake.nix` if --flake is set. |
| 205 | +
|
| 206 | + This is an internal option. No backward compatibility is guaranteed. |
| 207 | + Use at your own risk! |
| 208 | +
|
| 209 | + Note that this string gets spliced into a Perl script. The perl |
| 210 | + variable `$bootLoaderConfig` can be used to |
| 211 | + splice in the boot loader configuration. |
| 212 | + ''; |
| 213 | + }; |
| 214 | + |
179 | 215 | configuration = lib.mkOption { |
180 | 216 | internal = true; |
181 | 217 | type = lib.types.str; |
|
196 | 232 | desktopConfiguration = lib.mkOption { |
197 | 233 | internal = true; |
198 | 234 | type = lib.types.listOf lib.types.lines; |
199 | | - default = []; |
| 235 | + default = [ ]; |
200 | 236 | description = '' |
201 | 237 | Text to preseed the desktop configuration that `nixos-generate-config` |
202 | 238 | saves to `/etc/nixos/configuration.nix`. |
|
0 commit comments