|
49 | 49 | # Write wsl.conf so that it is present when NixOS is started for the first time |
50 | 50 | cp ${config.environment.etc."wsl.conf".source} ./etc/wsl.conf |
51 | 51 |
|
52 | | - # Copy the system configuration |
53 | | - mkdir -p ./etc/nixos/nixos-wsl |
54 | | - cp -R ${lib.cleanSource ../.}/. ./etc/nixos/nixos-wsl |
55 | | - mv ./etc/nixos/nixos-wsl/configuration.nix ./etc/nixos/configuration.nix |
56 | | - # Patch the import path to avoid havin a flake.nix in /etc/nixos |
57 | | - sed -i 's|import \./default\.nix|import \./nixos-wsl|' ./etc/nixos/configuration.nix |
| 52 | + ${lib.optionalString config.wsl.tarball.includeConfig '' |
| 53 | + # Copy the system configuration |
| 54 | + mkdir -p ./etc/nixos/nixos-wsl |
| 55 | + cp -R ${lib.cleanSource ../.}/. ./etc/nixos/nixos-wsl |
| 56 | + mv ./etc/nixos/nixos-wsl/configuration.nix ./etc/nixos/configuration.nix |
| 57 | + # Patch the import path to avoid having a flake.nix in /etc/nixos |
| 58 | + sed -i 's|import \./default\.nix|import \./nixos-wsl|' ./etc/nixos/configuration.nix |
| 59 | + ''} |
58 | 60 | ''; |
59 | 61 |
|
60 | 62 | in |
61 | | -mkIf config.wsl.enable { |
62 | | - # These options make no sense without the wsl-distro module anyway |
| 63 | +{ |
| 64 | + |
| 65 | + options.wsl.tarball = { |
| 66 | + includeConfig = mkOption { |
| 67 | + type = types.bool; |
| 68 | + default = true; |
| 69 | + description = "Whether or not to copy the system configuration into the tarball"; |
| 70 | + }; |
| 71 | + }; |
63 | 72 |
|
64 | | - system.build.tarball = pkgs.callPackage "${nixpkgs}/nixos/lib/make-system-tarball.nix" { |
65 | | - # No contents, structure will be added by prepare script |
66 | | - contents = [ ]; |
67 | 73 |
|
68 | | - fileName = "nixos-wsl-${pkgs.hostPlatform.system}"; |
| 74 | + config = mkIf config.wsl.enable { |
| 75 | + # These options make no sense without the wsl-distro module anyway |
69 | 76 |
|
70 | | - storeContents = pkgs2storeContents [ |
71 | | - config.system.build.toplevel |
72 | | - channelSources |
73 | | - preparer |
74 | | - ]; |
| 77 | + system.build.tarball = pkgs.callPackage "${nixpkgs}/nixos/lib/make-system-tarball.nix" { |
| 78 | + # No contents, structure will be added by prepare script |
| 79 | + contents = [ ]; |
75 | 80 |
|
76 | | - extraCommands = "${preparer}/bin/wsl-prepare"; |
| 81 | + fileName = "nixos-wsl-${pkgs.hostPlatform.system}"; |
77 | 82 |
|
78 | | - # Use gzip |
79 | | - compressCommand = "gzip"; |
80 | | - compressionExtension = ".gz"; |
81 | | - }; |
| 83 | + storeContents = pkgs2storeContents [ |
| 84 | + config.system.build.toplevel |
| 85 | + channelSources |
| 86 | + preparer |
| 87 | + ]; |
| 88 | + |
| 89 | + extraCommands = "${preparer}/bin/wsl-prepare"; |
82 | 90 |
|
| 91 | + # Use gzip |
| 92 | + compressCommand = "gzip"; |
| 93 | + compressionExtension = ".gz"; |
| 94 | + }; |
| 95 | + |
| 96 | + }; |
83 | 97 | } |
0 commit comments