Skip to content

Commit

Permalink
Disable auto-allocate-uids on Linux too (#638)
Browse files Browse the repository at this point in the history
* Disable auto-allocate-uids on Linux too

* Fix clippy/fmt
  • Loading branch information
Hoverbear authored Sep 22, 2023
1 parent abfde74 commit 7669045
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 18 deletions.
3 changes: 1 addition & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
* 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
+ `auto-optimise-store` is set to `true` (On Linux only)
* `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`
* `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.
Expand Down
13 changes: 2 additions & 11 deletions src/action/common/place_nix_configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,7 @@ impl PlaceNixConfiguration {

let mut defaults_conf_settings = vec![
("build-users-group", nix_build_group_name),
(
"experimental-features",
"nix-command flakes auto-allocate-uids".into(),
),
("experimental-features", "nix-command flakes".into()),
];

defaults_conf_settings.push(("bash-prompt-prefix", "(nix:$name)\\040".into()));
Expand All @@ -116,10 +113,6 @@ impl PlaceNixConfiguration {
// https://github.com/DeterminateSystems/nix-installer/issues/449#issuecomment-1551782281
#[cfg(not(target_os = "macos"))]
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
.iter()
.map(|(s, v)| format!("{s} = {v}"))
Expand Down Expand Up @@ -204,9 +197,7 @@ impl PlaceNixConfiguration {
);

// Some settings (eg `experimental-features`) we must be able to set it.
let mut required_settings = vec!["experimental-features"];
#[cfg(not(target_os = "macos"))]
required_settings.push("auto-allocate-uids");
let required_settings = vec!["experimental-features"];
for required_setting in required_settings {
if let Some((existing_setting, existing_value)) = existing_conf_settings
.iter()
Expand Down
6 changes: 1 addition & 5 deletions src/settings.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,6 @@ pub struct CommonSettings {
pub nix_build_user_prefix: String,

/// 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(
feature = "cli",
clap(
Expand All @@ -127,7 +123,7 @@ pub struct CommonSettings {
)
)]
#[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,

/// The Nix build user base UID (ascending)
Expand Down

0 comments on commit 7669045

Please sign in to comment.