Skip to content

Commit

Permalink
Merge pull request #303 from nix-community/welcome
Browse files Browse the repository at this point in the history
feat: add welcome message
  • Loading branch information
nzbr authored Oct 2, 2023
2 parents 46d35ee + 83d3356 commit 337edef
Show file tree
Hide file tree
Showing 3 changed files with 67 additions and 38 deletions.
82 changes: 44 additions & 38 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -26,49 +26,55 @@
};
nixosModules.default = self.nixosModules.wsl;

nixosConfigurations = {
modern = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
self.nixosModules.default
{ wsl.enable = true; }
];
};
nixosConfigurations =
let
initialConfig = {
wsl.enable = true;

legacy = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
self.nixosModules.default
{
wsl.enable = true;
wsl.nativeSystemd = false;
}
];
};
programs.bash.loginShellInit = "nixos-wsl-welcome";
};
in
{
modern = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
self.nixosModules.default
initialConfig
];
};

legacy = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
self.nixosModules.default
initialConfig
{ wsl.nativeSystemd = false; }
];
};

test = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
self.nixosModules.default
({ config, pkgs, ... }: {
wsl.enable = true;
wsl.nativeSystemd = false;
test = nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
self.nixosModules.default
({ config, pkgs, ... }: {
wsl.enable = true;
wsl.nativeSystemd = false;

system.activationScripts.create-test-entrypoint.text =
let
syschdemdProxy = pkgs.writeShellScript "syschdemd-proxy" ''
shell=$(${pkgs.glibc.bin}/bin/getent passwd root | ${pkgs.coreutils}/bin/cut -d: -f7)
exec $shell $@
system.activationScripts.create-test-entrypoint.text =
let
syschdemdProxy = pkgs.writeShellScript "syschdemd-proxy" ''
shell=$(${pkgs.glibc.bin}/bin/getent passwd root | ${pkgs.coreutils}/bin/cut -d: -f7)
exec $shell $@
'';
in
''
mkdir -p /bin
ln -sfn ${syschdemdProxy} /bin/syschdemd
'';
in
''
mkdir -p /bin
ln -sfn ${syschdemdProxy} /bin/syschdemd
'';
})
];
})
];
};
};
};

} //
flake-utils.lib.eachSystem
Expand Down
1 change: 1 addition & 0 deletions modules/default.nix
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
./recovery.nix
./systemd
./version.nix
./welcome.nix
./wsl-conf.nix
./wsl-distro.nix

Expand Down
22 changes: 22 additions & 0 deletions modules/welcome.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
{ lib, pkgs, config, ... }:
let
welcomeMessage = pkgs.writeText "nixos-wsl-welcome-message" ''
Welcome to your new NixOS-WSL system!
Please run `sudo nix-channel --update` and `sudo nixos-rebuild switch` now, to ensure you're running the latest NixOS and NixOS-WSL versions.
If you run into issues, please report them on our Github page at https://github.com/nix-community/NixOS-WSL or come talk to us on Matrix at #wsl:nixos.org.
❄️ Enjoy NixOS-WSL! ❄️
Note: this message will disappear after you rebuild your system. If you want to see it again, run `nixos-wsl-welcome`.
'';
welcome = pkgs.writeShellScriptBin "nixos-wsl-welcome" ''
cat ${welcomeMessage}
'';
in
{
config = lib.mkIf config.wsl.enable {
environment.systemPackages = [ welcome ];
};
}

0 comments on commit 337edef

Please sign in to comment.