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

Allow usage with nix daemon #45

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

AleksanderGondek
Copy link
Contributor

This commit removes the restriction of running the project only via single-user nix installation.
To ensure disruptor is run with appropriate settings, a comparison is made betweeen global nix configuration and those specified in scripts/nix.conf file - any differences is clearly communicated to user

This commit removes the restriction of running the project only via single-user nix installation.
To ensure disruptor is run with appropriate settings, a comparison is made betweeen global nix configuration and those specified in scripts/nix.conf file - any differences is clearly communicated to user
@AleksanderGondek
Copy link
Contributor Author

AleksanderGondek commented Mar 29, 2022

Example of warning:

$ ./nix-shell.sh
The configuration of host nix daemon differs from the expected one.
These are the offending settings:
{ keep-outputs = "'true' change to => 'false';"; require-sigs = "'false' change to => 'true';"; }
---
Please update your configuration otherwise the shell may not work as intended.
direnv: loading ~/projects/disruptor/.envrc

[nix-shell:~/projects/disruptor]$

@AleksanderGondek AleksanderGondek changed the title Allow usage with nix deamon Allow usage with nix daemon Mar 29, 2022
@r2r-dev
Copy link
Collaborator

r2r-dev commented Mar 29, 2022

Alt Text

nix show-config --json > "${global_nix_conf_settings}" 2>/dev/null
# shellcheck disable=SC2181
if [ $? -ne 0 ]; then
fail "nix show-config command has failed. Please enable it by following this steps: https://nixos.wiki/wiki/Nix_command"
Copy link
Collaborator

Choose a reason for hiding this comment

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

Why not add --experimental-features nix-command to the command above?

Also this condition can be reached in cases when installed nix version is below 2.4.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I will add the flag, I have been stuck thinking about unprivledged user but in other cases it saves the user a trip to nix.conf.

As to nix version... isn't it available even in version 2.0?
https://github.com/NixOS/nix/blob/2.0/src/nix/show-config.cc

This change adds '--experimental-features nix-command' param to nix show-config invocation to address invocations of privileged users who have not yet enabled nix-command
@r2r-dev
Copy link
Collaborator

r2r-dev commented Mar 30, 2022

I like where this is heading. I'm ok with merging these changes. However, I think large chunks of this solution could be moved to shell.nix entirely. Some references:
https://github.com/NixOS/nixpkgs/blob/420a0cce9358acf8b9c9c2ae3a0e421097f84c50/nixos/modules/services/misc/nix-daemon.nix#L72
https://github.com/cheronobyl/nixflk/blob/27513eeed119ccb82eee0abb60b93f0cd9758473/shell.nix#L25

In general, as soon as we know that nix binary is available in any shape or form, we can leverage initial nix expression, e.g. shell.nix to perform the rest of checks, and config set-up. You can even import nix library to ease the pain:
https://github.com/nix-community/nixpkgs.lib

@finn-qarik finn-qarik force-pushed the master branch 4 times, most recently from b7588d4 to aec36d2 Compare April 19, 2024 10:54
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants