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

Disable auto-allocate-uids on Linux too #638

Merged
merged 2 commits into from
Sep 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
15 changes: 3 additions & 12 deletions src/action/common/place_nix_configuration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,10 +39,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 @@ -60,10 +57,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 @@ -95,7 +88,7 @@ impl PlaceNixConfiguration {

// We only scan one include of depth -- we should make this any depth, make sure to guard for loops
if line.starts_with("include") || line.starts_with("!include") {
let allow_not_existing = line.starts_with("!");
let allow_not_existing = line.starts_with('!');
// Need to read it in if it exists for settings
let path = line
.trim_start_matches("include")
Expand Down Expand Up @@ -148,9 +141,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 @@ -110,10 +110,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 @@ -124,7 +120,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
Loading