Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow building tarballs that do not contain the system config #80

Merged
merged 2 commits into from
Apr 17, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
58 changes: 36 additions & 22 deletions modules/build-tarball.nix
Original file line number Diff line number Diff line change
Expand Up @@ -49,35 +49,49 @@ let
# Write wsl.conf so that it is present when NixOS is started for the first time
cp ${config.environment.etc."wsl.conf".source} ./etc/wsl.conf

# Copy the system configuration
mkdir -p ./etc/nixos/nixos-wsl
cp -R ${lib.cleanSource ../.}/. ./etc/nixos/nixos-wsl
mv ./etc/nixos/nixos-wsl/configuration.nix ./etc/nixos/configuration.nix
# Patch the import path to avoid havin a flake.nix in /etc/nixos
sed -i 's|import \./default\.nix|import \./nixos-wsl|' ./etc/nixos/configuration.nix
${lib.optionalString config.wsl.tarball.includeConfig ''
# Copy the system configuration
mkdir -p ./etc/nixos/nixos-wsl
cp -R ${lib.cleanSource ../.}/. ./etc/nixos/nixos-wsl
mv ./etc/nixos/nixos-wsl/configuration.nix ./etc/nixos/configuration.nix
# Patch the import path to avoid havin a flake.nix in /etc/nixos

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having*

sed -i 's|import \./default\.nix|import \./nixos-wsl|' ./etc/nixos/configuration.nix
''}
'';

in
mkIf config.wsl.enable {
# These options make no sense without the wsl-distro module anyway
{

options.wsl.tarball = {
includeConfig = mkOption {
type = types.bool;
default = true;
description = "Whether or not to copy the system configuration into the tarball";
};
};

system.build.tarball = pkgs.callPackage "${nixpkgs}/nixos/lib/make-system-tarball.nix" {
# No contents, structure will be added by prepare script
contents = [ ];

fileName = "nixos-wsl-${pkgs.hostPlatform.system}";
config = mkIf config.wsl.enable {
# These options make no sense without the wsl-distro module anyway

storeContents = pkgs2storeContents [
config.system.build.toplevel
channelSources
preparer
];
system.build.tarball = pkgs.callPackage "${nixpkgs}/nixos/lib/make-system-tarball.nix" {
# No contents, structure will be added by prepare script
contents = [ ];

extraCommands = "${preparer}/bin/wsl-prepare";
fileName = "nixos-wsl-${pkgs.hostPlatform.system}";

# Use gzip
compressCommand = "gzip";
compressionExtension = ".gz";
};
storeContents = pkgs2storeContents [
config.system.build.toplevel
channelSources
preparer
];

extraCommands = "${preparer}/bin/wsl-prepare";

# Use gzip
compressCommand = "gzip";
compressionExtension = ".gz";
};

};
}