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

Fixes #92: Make nix-user example work (including flakes) #93

Closed
wants to merge 1 commit into from

Conversation

kolloch
Copy link
Contributor

@kolloch kolloch commented Nov 3, 2023

Makes executing nix within the nix-user container possible :)

/thirdparty/nix2container master                                                                                                                                       base 14:27:00
❯ nix run .\#examples.nix-user.copyToDockerDaemon && docker run -it nix-user:latest
Copy to Docker daemon image nix-user:latest
Getting image source signatures
Copying blob a24921896e21 done  
Copying config ff83ffb7fb done  
Writing manifest to image destination
Running checks against store uri: local
[PASS] PATH contains only one nix version.
[PASS] All profiles are gcroots.
[PASS] Client protocol matches store protocol.
[INFO] You are trusted by store uri: local
total 24
drwxr-xr-x  1 user user 4096 Jan  1  1970 .
drwxr-xr-x  1    0    0 4096 Nov  3 13:28 ..
drwxr-xr-x 54 user user 4096 Jan  1  1970 store
drwxr-xr-x  1 user user 4096 Jan  1  1970 var
bash-5.2$ nix run nixpkgs#hello
Hello, world!
bash-5.2$ 

Copy link
Owner

@nlewo nlewo left a comment

Choose a reason for hiding this comment

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

Hello @kolloch,

Thanks for these fixes!

I would prefer to keep the nix-user example as simple as possible. For instance, I don't think we should enable flakes since it's not related to the nix-user example itself.
Also, this example is used as a kind of unit test by the nix2container test suite (in the ./tests project directoy).

What I understand is that you would like to have an example of a fully working nix image which seems to be relevant!
So, maybe we could rename the nix.nix to nix-database.nix and create a new nix.nix example with a fully working nix image (users, flakes, SSL, ...). Also, we should add a test for this new image but I could help on this part since we will have to make some tradeoff (no internet for instance).

wdyt?

@kolloch
Copy link
Contributor Author

kolloch commented Nov 4, 2023

Sure! I don't mind to split it into another file.

To avoid misleading users such as me, I'd comment on the original file that some more steps are needed to make this work in practice. I mistook the example as a best practice recommendation and getting started basis.

If the "new" example will serve as the getting started basis, I'd keep adding to the nix.conf in there: It is a very common requirement if you want to build upon that example.

And I am all for tests. One think that might potentially make this difficult, is that for a meaninful test, you'd need to load the image into a docker runtime and execute some commands in it. Does your CI support that?

@nlewo
Copy link
Owner

nlewo commented Nov 4, 2023

I mistook the example as a best practice recommendation and getting started basis.

I'm sorry about this: this should no longer be in a example directory... Ideally we should have an example section and a test section but this kind of improvements takes time to implement :/ At least, currently, all "examples" are tested. (btw, +1 for a comment in this file).

If the "new" example will serve as the getting started basis, I'd keep adding to the nix.conf in there: It is a very common requirement if you want to build upon that example.

Agreed (and i'm also in favor of enabling flakes).

One think that might potentially make this difficult, is that for a meaninful test, you'd need to load the image into a docker runtime and execute some commands in it. Does your CI support that?

Yes, the CI does that... in an impure way (see this doc) but in practice it works pretty well (in the future, I'm planning to run this in a NixOS VM to make it pure).

@kolloch
Copy link
Contributor Author

kolloch commented Nov 6, 2023

How shall I call the new directory then?

Or shall I rename examples to testImages or similar?

@kolloch kolloch closed this Feb 16, 2024
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