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

lorri: init at version unstable-2019-10-30 #72889

Merged
merged 2 commits into from Nov 14, 2019

Conversation

curiousleo
Copy link
Contributor

Motivation for this change

lorri is still unstable, but already makes it easier to work with project-specific Nix shells.

Things done
  • Tested using sandboxing (nix.useSandbox on NixOS, or option sandbox in nix.conf on non-NixOS linux)
  • Built on platform(s)
    • NixOS
    • macOS
    • other Linux distributions
  • Tested via one or more NixOS test(s) if existing and applicable for the change (look inside nixos/tests)
  • Tested compilation of all pkgs that depend on this change using nix-shell -p nix-review --run "nix-review wip" (trivially true: lorri is not depended on by any other package at the moment)
  • Tested execution of all binary files (usually in ./result/bin/)
  • Determined the impact on package closure size (by running nix path-info -S before and after)
    $ nix path-info -I nixpkgs=. -rsSh nixpkgs.lorri
    /nix/store/q10rsx05prs1qj2z5a8k45mik0r9nqfc-lorri-rolling-release-2019-10-30	   3.4M	  33.5M
  • Ensured that relevant documentation is up to date
  • Fits CONTRIBUTING.md.
Notify maintainers

cc @Profpatsch @grahamc @ocharles

description = "Your project's nix-env";
homepage = "https://github.com/target/lorri";
license = licenses.asl20;
maintainers = [ maintainers.Profpatsch ];
Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Profpatsch :D - let me know if you're okay with this

Copy link
Member

Choose a reason for hiding this comment

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

Sure. We should add Graham and yourself :)

Copy link
Member

@Profpatsch Profpatsch left a comment

Choose a reason for hiding this comment

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

Great work!

nixos/modules/services/development/lorri.nix Show resolved Hide resolved
description = "Your project's nix-env";
homepage = "https://github.com/target/lorri";
license = licenses.asl20;
maintainers = [ maintainers.Profpatsch ];
Copy link
Member

Choose a reason for hiding this comment

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

Sure. We should add Graham and yourself :)

pkgs/tools/misc/lorri/runtime-closure.nix.template Outdated Show resolved Hide resolved

rustPlatform.buildRustPackage rec {
pname = "lorri";
version = "rolling-release-2019-10-30";
Copy link
Member

Choose a reason for hiding this comment

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

I think we wanted to push this as 0.5 (should also put that into the Cargo.toml in upstream).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool - I'm happy to change this to reflect a new release of lorri. For now, I think that rolling-release-2019-10-30 is an accurate name for the revision this is pulling from.

Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the porting effort.
I think unstable-YYYY-MM-DD is the preferred naming schema. But 0.5 is released soon. So no further change needed.

cargoSha256 = "1daff4plh7hwclfp21hkx4fiflh9r80y2c7k2sd3zm4lmpy0jpfz";

# Note that https://travis-ci.org/target/lorri/builds/605036891 passed.
doCheck = false;
Copy link
Member

Choose a reason for hiding this comment

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

Are the tests failing? We might want to enable them, because we pin a different nixpkgs version in the lorri repo (which we don’t update that often usually).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, they were failing due to path issues. I'll look into making them pass.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Okay, here's what I've tried:

  • If I just set doCheck = true, two tests fail. One of them because it fails to write something to /nix/var. I believe that this error does not occur upstream because of the bogus-nixpkgs NIX_PATH: https://github.com/target/lorri/blob/95c3e3da1be4f0d8ddb62dce21afa02d8cecfdf7/default.nix#L18. I don't really understand the effect of setting this.
  • The bogus-nixpkgs thing in the upstream default.nix requires that directory to exist, and possibly also to be populated with packages that are used for testing: https://github.com/target/lorri/tree/95c3e3da1be4f0d8ddb62dce21afa02d8cecfdf7/nix/bogus-nixpkgs. I think there is a way to make this work, which is essentially "copy every .nix file from the lorri repo into nixpkgs in this PR".
  • As a last alternative, I kept doCheck = false and tried to create an integration test in nixpkgs/nixos/tests. I didn't get very far unfortunately: making the Python test helpers do what I want is non-trivial.

Copy link
Member

Choose a reason for hiding this comment

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

  • I don't really understand the effect of setting this.

Setting it in the checkPhase should be fine and fix that issue.

  • which is essentially "copy every .nix file from the lorri repo into nixpkgs in this PR".

Just the stuff under nix/bogus-nixpkgs should be necessary.

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 couldn't get it to work, and I'm not convinced it is worth cluttering the nixpkgs repo with lorri's nix files and slowing down the nixpkgs build given that lorri has CI. You can see my attempts in the commit history of this branch.

Copy link
Member

Choose a reason for hiding this comment

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

@curiousleo you can just point the NIX_PATH to $src. No need to have these nix files locally.

Copy link
Member

Choose a reason for hiding this comment

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

Yep, you can do something like

preCheck = ''
  export NIX_PATH=nixpkgs=${src}/nix/bogus-nixpkgs
''

Copy link
Contributor Author

Choose a reason for hiding this comment

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

you can just point the NIX_PATH to $src. No need to have these nix files locally.

I must have misunderstood @Profpatsch - I thought you said that there were checks preventing the use of this technique in order to ensure all nix files are actually checked into this repo.

That makes things much neater, of course! :)

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yep, you can do something like

preCheck = ''
  export NIX_PATH=nixpkgs=${src}/nix/bogus-nixpkgs
''

The test errors with "can't write to /nix/store" persist. Do you think running the unit tests is necessary if there is an integration test (https://github.com/NixOS/nixpkgs/blob/115d1ec64f851df9db365ad7b6bf7b3e629f32d0/nixos/tests/lorri/default.nix)? If yes, I'm going to need help with getting doCheck = true to work.

Copy link
Member

Choose a reason for hiding this comment

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

Let’s just set it to false for now, to get it in. We are running the tests upstream anyway.

nixos/modules/services/development/lorri.nix Outdated Show resolved Hide resolved
nixos/modules/services/development/lorri.nix Outdated Show resolved Hide resolved
nixos/modules/services/development/lorri.nix Outdated Show resolved Hide resolved
nixos/modules/services/development/lorri.nix Outdated Show resolved Hide resolved
PrivateTmp = true;
ProtectSystem = "strict";
ProtectHome = "read-only";
Restart = "on-failure";
Copy link
Member

Choose a reason for hiding this comment

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

Not sure, it’s certainly more user-friendly, but would we be notified of issues that way?

Copy link
Contributor

Choose a reason for hiding this comment

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

It should still appear in the syslog, and if it keeps crashing, systemd won't restart it indefinitely, so should be fine IMHO.

@ofborg ofborg bot requested a review from Profpatsch November 6, 2019 17:19
serviceConfig = {
ExecStart = "${pkgs.lorri}/bin/lorri daemon";
PrivateTmp = true;
ProtectSystem = "strict";
Copy link
Member

Choose a reason for hiding this comment

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

Remark: Even more strict would be if we'd have systemd-confinement for user units.

Copy link
Contributor

Choose a reason for hiding this comment

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

I'd keep that as a follow-up.

Copy link
Contributor Author

@curiousleo curiousleo left a comment

Choose a reason for hiding this comment

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

Thanks @aszlig and @Profpatsch for the reviews! I will now do the following:

  1. Remove the systemd service from this PR as suggested by @Profpatsch.
  2. Address your comments on the package declaration to get it into a mergeable state.
  3. Create a second PR with just the systemd service and address your comments related to the service declaration there. I'll reply to your comments here and point to the changes I'll have made so you'll see that I will have addressed them.

nixos/modules/services/development/lorri.nix Show resolved Hide resolved

rustPlatform.buildRustPackage rec {
pname = "lorri";
version = "rolling-release-2019-10-30";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Cool - I'm happy to change this to reflect a new release of lorri. For now, I think that rolling-release-2019-10-30 is an accurate name for the revision this is pulling from.

cargoSha256 = "1daff4plh7hwclfp21hkx4fiflh9r80y2c7k2sd3zm4lmpy0jpfz";

# Note that https://travis-ci.org/target/lorri/builds/605036891 passed.
doCheck = false;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, they were failing due to path issues. I'll look into making them pass.

@curiousleo
Copy link
Contributor Author

Comments on the package declaration addressed, PTAL. (See #72889 (review) for what I'm planning to do next.)

@ofborg ofborg bot requested a review from grahamc November 8, 2019 12:51
@curiousleo curiousleo marked this pull request as ready for review November 8, 2019 13:07
@curiousleo curiousleo changed the title lorri (including user service): init at version rolling-release-2019-10-30 lorri: init at version rolling-release-2019-10-30 Nov 8, 2019
@curiousleo
Copy link
Contributor Author

I have not yet addressed all review comments - no need to review again at this point, thanks!

nixos/modules/services/development/lorri.nix Outdated Show resolved Hide resolved
nixos/modules/services/development/lorri.nix Outdated Show resolved Hide resolved
nixos/modules/services/development/lorri.nix Show resolved Hide resolved
nixos/modules/services/development/lorri.nix Show resolved Hide resolved
nixos/modules/services/development/lorri.nix Outdated Show resolved Hide resolved
nixos/modules/services/development/lorri.nix Outdated Show resolved Hide resolved
serviceConfig = {
ExecStart = "${pkgs.lorri}/bin/lorri daemon";
PrivateTmp = true;
ProtectSystem = "strict";
Copy link
Contributor

Choose a reason for hiding this comment

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

I'd keep that as a follow-up.

PrivateTmp = true;
ProtectSystem = "strict";
ProtectHome = "read-only";
Restart = "on-failure";
Copy link
Contributor

Choose a reason for hiding this comment

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

It should still appear in the syslog, and if it keeps crashing, systemd won't restart it indefinitely, so should be fine IMHO.

nixos/tests/lorri/default.nix Outdated Show resolved Hide resolved
@curiousleo curiousleo force-pushed the add-lorri branch 2 times, most recently from c990d27 to 061169f Compare November 12, 2019 14:22
@curiousleo
Copy link
Contributor Author

Comments addressed, PTAL.

@curiousleo curiousleo changed the title lorri: init at version rolling-release-2019-10-30 lorri: init at version unstable-2019-10-30 Nov 13, 2019
@curiousleo
Copy link
Contributor Author

@grahamc @Profpatsch mind taking another look?

@flokli
Copy link
Contributor

flokli commented Nov 13, 2019

@GrahamcOfBorg test lorri

)

# Start the daemon and wait until it is ready
machine.execute("lorri daemon > lorri.stdout 2> lorri.stderr &")
Copy link
Contributor

Choose a reason for hiding this comment

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

At least according to previous discussions, we don't really want to run lorri as the root user, do we?

I'd suggest to import ./common/user-account.nix, and run it as alice or bob.

We also don't test the socket activation at all. I propose starting and forking the daemon manually should be done for alice, and bob should rely on systemd socket activation. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My thinking:

no test < current test < what you're proposing

Unfortunately I can't get your proposal to work! So I'm inclined to merge now with the test as-is, and improve on the test in a follow-up.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Captured this task here: target/lorri#218

Copy link
Member

@Profpatsch Profpatsch left a comment

Choose a reason for hiding this comment

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

I think we can merge
Addressed the description part, PTAL. Would love a meta.longDescription as well, but that can be fixed later.

We can pull the tests into a different PR if you want, the module and package are good!

Includes user service (nixos/modules/services/development/lorri) that
starts on demand.
@Profpatsch
Copy link
Member

@GrahamcOfBorg test lorri

@Profpatsch
Copy link
Member

LGTM!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants