-
Notifications
You must be signed in to change notification settings - Fork 241
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
Infect with a prebuilt flake? #108
Comments
I've tried modified this script and successfully got it working for my flake. Here's how: PrerequisitesSeems you'll need to have the flake well-defined, or else the box will get stuck somewhere right after it reboots The big thingWe'll need to look here: Lines 286 to 299 in 318fc51
That's where the # Flake adaptations
nix \
--extra-experimental-features "nix-command flakes" \
build \
--profile /nix/var/nix/profiles/system \
"${FLAKE_URL}#nixosConfigurations.${NIXOS_CONFIG_NAME}.config.system.build.toplevel" |
Following script works for me (tested on contabo). curl https://raw.githubusercontent.com/elitak/nixos-infect/master/nixos-infect \
| NIX_CHANNEL=nixos-23.05 NO_REBOOT=true bash -x \
&& { cat > /etc/nixos/flake.nix << 'EOF'
{
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixos-23.05";
};
outputs = inputs:
{
nixosConfigurations.contabo-nixos = inputs.nixpkgs.lib.nixosSystem {
system = "x86_64-linux";
modules = [
./configuration.nix
({ pkgs, ... }: {
nix = {
registry.nixpkgs.flake = inputs.nixpkgs;
settings.experimental-features = [ "nix-command" "flakes" ];
package = pkgs.nixFlakes;
};
system.stateVersion = "23.05";
})
];
};
};
}
EOF
} \
&& /root/.nix-profile/bin/nix build \
--extra-experimental-features "nix-command flakes" \
/etc/nixos/#nixosConfigurations.contabo-nixos.config.system.build.toplevel
result/activate
result/bin/switch-to-configuration switch
reboot |
Turning this into something like this would be fantastic:
Even better if would also allow for passing a key for decrypting credentials
|
I'm using flakes to configure my NixOS machines. More or less as explained here.
The point is that, if I add the flake configuration before infection, and then infect it, the new system will be configured using the
/etc/nixo/configuration.nix
file generated in the infection script, instead of using the/etc/nixos/flake.nix
that I already put there before.Is there a way to preconfigure the system before infection so that, after infected, it's directly booted to the system flake?
The text was updated successfully, but these errors were encountered: