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

nixos-generate-config: add system.copySystemConfiguration = true; #24707

Closed
wants to merge 1 commit into from
Closed

nixos-generate-config: add system.copySystemConfiguration = true; #24707

wants to merge 1 commit into from

Conversation

techhazard
Copy link
Contributor

Motivation for this change

nixos-generate-config: add system.copySystemConfiguration = true;

This adds the above line to nixos-generate-config.pl and explains its
effect.

This is added as an initial method for backing up configuration.nix
which is useful for both novice users (which do not split-up the file as
quickly) and for advanced users (before they have configured backups).

Added because of github PR #16922 and noobs (e.g. myself)

As argued in the PR (#16922) it makes little sense to have the default setting set to true, but the arguments of @ryantrinkle and myself still stand: It is very convenient to have backups in the initial setting up of a new nixos system.

I have not yet run any test with this, because I don't know how to build the new nixos-generate-config. Could someone help me with that?

Things done
  • Tested using sandboxing
    (nix.useSandbox on NixOS,
    or option build-use-sandbox in nix.conf
    on non-NixOS)
  • Built on platform(s)
    • NixOS
    • macOS
    • Linux
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nox --run "nox-review wip"
  • Tested execution of all binary files (usually in ./result/bin/)
  • Fits CONTRIBUTING.md.

This adds the above line to `nixos-generate-config.pl` and explains its
effect.

This is added as an initial method for backing up `configuration.nix`
which is useful for both novice users (which do not split-up the file as
quickly) and for advanced users (before they have configured backups).

Added because of github PR #16922 and
[noobs](http://lists.science.uu.nl/pipermail/nix-dev/2017-April/023379.html)
@mention-bot
Copy link

@awesomefireduck, thanks for your PR! By analyzing the history of the files in this pull request, we identified @edolstra, @aszlig and @wkennington to be potential reviewers.

@aszlig
Copy link
Member

aszlig commented Apr 7, 2017

@awesomefireduck: You could run the installer VM tests, like this (while in the top-level dir of the nixpkgs repository):

$ nix-build nixos/tests/installer.nix

It would probably also make sense to add a test case to check whether the configuration.nix in the store exists and has the same contents as the one in /etc/nixos.

@techhazard
Copy link
Contributor Author

The tests ran successfully, I think.
It exited with code 0 and I got the following output:

collecting coverage data
syncing
test script finished in 559.70s
vde_switch: EOF on stdin, cleaning up and exiting
cleaning up

Is there any more output I need to look at?

@vcunat
Copy link
Member

vcunat commented Apr 10, 2017

Well, we can do something like this. If so, I'd personally prefer if the comment was less verbose, e.g. two lines – I see no use in copying too much information in there when people can easily find it in the manual.

Also, we might instead consider something like the line suggested on ML: environment.etc.nixos-orig.source = ./.;.

@techhazard
Copy link
Contributor Author

The option by @ben0x539 (environment.etc.nixos-orig.source = ./. ;) seems like a more robust way to handle this. Maybe it's an idea to make system.copySystemConfiguration = true; into an alias thereof?

@bobvanderlinden
Copy link
Member

I was going through older PRs and this one stood out. This seems like a good idea and only a small addition 👍

Any idea how could you would alias system.copySystemConfiguration = true; to something that includes ./.?

Copy link
Member

@infinisil infinisil left a comment

Choose a reason for hiding this comment

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

I'd like to move this PR forward and merge it soon, this is a very reasonable change, and very useful even if copySystemConfiguration only copies configuration.nix.

# It can be found in every profile in /nix/var/nix/profiles/ ,
# and the currently used one at /run/current-system/ .
# Note that this only copies configuration.nix,
# and not any included files like hardware-configuration.nix.
Copy link
Member

Choose a reason for hiding this comment

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

I suggest a message like this instead:

# Guard against accidental deletion of configuration.nix,
# allowing recovery from /run/current-system/configuration.nix

Copy link
Contributor

Choose a reason for hiding this comment

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

Or even like this:

# If you don't do backups of this file, it is a good idea to set this option to `true`.
# Then, if you accidentally remove configuration.nix, you can find it in
# - /run/current-system/configuration.nix (last one)
# - /nix/var/nix/profiles/system-*/configuration.nix (old versions)
system.copySystemConfiguration = false;

@infinisil
Copy link
Member

@techhazard You still interested in pursuing this? If you're not, I'll take over

@techhazard
Copy link
Contributor Author

@infinisil I'm not, feel free to take over :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

9 participants