Skip to content

Conversation

amozeo
Copy link
Contributor

@amozeo amozeo commented Jul 16, 2024

Description of changes

Introduces templates to nixos-generate-config. These templates are additional files that are copied over to destination directory.

Things done

  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandboxing enabled in nix.conf? (See Nix manual)
    • sandbox = relaxed
    • sandbox = true
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 24.11 Release Notes (or backporting 23.11 and 24.05 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
  • Fits CONTRIBUTING.md.

Add a 👍 reaction to pull requests you find important.

@amozeo amozeo requested a review from infinisil as a code owner July 16, 2024 20:50
@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 6.topic: flakes The experimental Nix feature 6.topic: lib The Nixpkgs function library labels Jul 16, 2024
@amozeo amozeo changed the title Nixos/tools/nixos generate config templates nixos-generate-config: add templates Jul 16, 2024
@amozeo amozeo changed the title nixos-generate-config: add templates nixos-generate-config: introduce templates Jul 16, 2024
infinisil and others added 6 commits August 10, 2024 23:18
In bash it's convention for "" to represent false, and "1" true.
The `buildingAttribute` variable didn't honor that before.
Otherwise we'd run into trouble when a filename contained e.g. a space
To more accurately represent what it does
Opens the file that would be built from
Previously, `nixos-rebuild -A foo` would build the `default.nix` in the
current directory, while `nixos-rebuild` without `-A` would not use
file-based building at all.

This difference compared to what `nix-build` would do is confusing.

Furthermore, using `default.nix` is not great, because there's many of
those files all around, and they're almost never for NixOS.

This commit fixes those two issues by:
- Removing support for using `default.nix` as a default when using `--attr`
- If it exists, using the `<nixos-system>` entry in NIX_PATH as the default
- Otherwise, use the `system.nix` file in the current directory or any
  of its parents, if it exists, as a default
- Otherwise, use `/etc/nixos/system.nix` as a default

While `system.nix` could be conflated with the `system` Nixpkgs
argument, there's no practical way for this to cause problems, because
`system` is never specified in a file.

Having this finally allows using `nixos-rebuild` without any arguments
and without any `NIX_PATH` entries, effectively a way to declaratively
use NixOS from just /etc/nixos!
@amozeo amozeo marked this pull request as draft August 21, 2024 00:20
@amozeo
Copy link
Contributor Author

amozeo commented Aug 22, 2024

closing in favor of #333788

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
6.topic: flakes The experimental Nix feature 6.topic: lib The Nixpkgs function library 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/`
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants