Disable auto-allocate-uids on Linux too (#638)

* Disable auto-allocate-uids on Linux too

* Fix clippy/fmt
This commit is contained in:
Ana Hobden 2023-09-22 10:44:40 -07:00 committed by GitHub
parent abfde74d1f
commit 7669045865
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 18 deletions

View file

@ -418,11 +418,10 @@ curl -sSf -L https://github.com/DeterminateSystems/nix-installer/releases/downlo
Differing from the upstream [Nix](https://github.com/NixOS/nix) installer scripts: Differing from the upstream [Nix](https://github.com/NixOS/nix) installer scripts:
* In `nix.conf`: * In `nix.conf`:
+ the `auto-allocate-uids`, `nix-command` and `flakes` features are enabled + the `nix-command` and `flakes` features are enabled
+ `bash-prompt-prefix` is set + `bash-prompt-prefix` is set
+ `auto-optimise-store` is set to `true` (On Linux only) + `auto-optimise-store` is set to `true` (On Linux only)
* `extra-nix-path` is set to `nixpkgs=flake:nixpkgs` * `extra-nix-path` is set to `nixpkgs=flake:nixpkgs`
* `auto-allocate-uids` is set to `true`. (On Linux only)
* an installation receipt (for uninstalling) is stored at `/nix/receipt.json` as well as a copy of the install binary at `/nix/nix-installer` * an installation receipt (for uninstalling) is stored at `/nix/receipt.json` as well as a copy of the install binary at `/nix/nix-installer`
* `nix-channel --update` is not run, `~/.nix-channels` is not provisioned * `nix-channel --update` is not run, `~/.nix-channels` is not provisioned
* `NIX_SSL_CERT_FILE` is set in the various shell profiles if the `ssl-cert-file` argument is used. * `NIX_SSL_CERT_FILE` is set in the various shell profiles if the `ssl-cert-file` argument is used.

View file

@ -95,10 +95,7 @@ impl PlaceNixConfiguration {
let mut defaults_conf_settings = vec![ let mut defaults_conf_settings = vec![
("build-users-group", nix_build_group_name), ("build-users-group", nix_build_group_name),
( ("experimental-features", "nix-command flakes".into()),
"experimental-features",
"nix-command flakes auto-allocate-uids".into(),
),
]; ];
defaults_conf_settings.push(("bash-prompt-prefix", "(nix:$name)\\040".into())); defaults_conf_settings.push(("bash-prompt-prefix", "(nix:$name)\\040".into()));
@ -116,10 +113,6 @@ impl PlaceNixConfiguration {
// https://github.com/DeterminateSystems/nix-installer/issues/449#issuecomment-1551782281 // https://github.com/DeterminateSystems/nix-installer/issues/449#issuecomment-1551782281
#[cfg(not(target_os = "macos"))] #[cfg(not(target_os = "macos"))]
defaults_conf_settings.push(("auto-optimise-store", "true".into())); defaults_conf_settings.push(("auto-optimise-store", "true".into()));
// Auto-allocate uids is broken on Mac. Tools like `whoami` don't work.
// e.g. https://github.com/NixOS/nix/issues/8444
#[cfg(not(target_os = "macos"))]
defaults_conf_settings.push(("auto-allocate-uids", "true".into()));
let defaults_conf_insert_fragment = defaults_conf_settings let defaults_conf_insert_fragment = defaults_conf_settings
.iter() .iter()
.map(|(s, v)| format!("{s} = {v}")) .map(|(s, v)| format!("{s} = {v}"))
@ -204,9 +197,7 @@ impl PlaceNixConfiguration {
); );
// Some settings (eg `experimental-features`) we must be able to set it. // Some settings (eg `experimental-features`) we must be able to set it.
let mut required_settings = vec!["experimental-features"]; let required_settings = vec!["experimental-features"];
#[cfg(not(target_os = "macos"))]
required_settings.push("auto-allocate-uids");
for required_setting in required_settings { for required_setting in required_settings {
if let Some((existing_setting, existing_value)) = existing_conf_settings if let Some((existing_setting, existing_value)) = existing_conf_settings
.iter() .iter()

View file

@ -113,10 +113,6 @@ pub struct CommonSettings {
pub nix_build_user_prefix: String, pub nix_build_user_prefix: String,
/// Number of build users to create /// Number of build users to create
#[cfg_attr(
all(target_os = "linux", feature = "cli"),
doc = "On Linux, Nix's `auto-allocate-uids` feature will be enabled, so users don't need to be created."
)]
#[cfg_attr( #[cfg_attr(
feature = "cli", feature = "cli",
clap( clap(
@ -127,7 +123,7 @@ pub struct CommonSettings {
) )
)] )]
#[cfg_attr(all(target_os = "macos", feature = "cli"), clap(default_value = "32"))] #[cfg_attr(all(target_os = "macos", feature = "cli"), clap(default_value = "32"))]
#[cfg_attr(all(target_os = "linux", feature = "cli"), clap(default_value = "0"))] #[cfg_attr(all(target_os = "linux", feature = "cli"), clap(default_value = "32"))]
pub nix_build_user_count: u32, pub nix_build_user_count: u32,
/// The Nix build user base UID (ascending) /// The Nix build user base UID (ascending)