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

Improve Home Manager support: profiles/suites, modules, extern, flake outputs #156

Merged
merged 5 commits into from
Mar 23, 2021

Conversation

Pacman99
Copy link
Member

@Pacman99 Pacman99 commented Mar 9, 2021

A really simple method of implementing #119.

This relies on a feature that I added in home-manager master for module options of extraSpecialArgs and sharedModules, nix-community/home-manager#1793. I could try and get that backported to 20.09. But I thought I'd get some feedback on these changes first.

@Pacman99 Pacman99 marked this pull request as draft March 9, 2021 21:03
@nrdxp nrdxp self-requested a review March 10, 2021 06:35
@nrdxp
Copy link
Collaborator

nrdxp commented Mar 13, 2021

bors try

@bors
Copy link
Contributor

bors bot commented Mar 13, 2021

try

Configuration problem:
bors.toml: not found

@Pacman99 Pacman99 force-pushed the first-user branch 3 times, most recently from 313d5a2 to 79f9bfc Compare March 14, 2021 08:41
@Pacman99
Copy link
Member Author

Updated to match the lib changes.

Also I dropped hmActivationPackages and this time exported homeConfigurations with a hyphen seperating hosts and users. So all host/user pairs get exported as host-user.

I think this is significantly simpler. I only exported the activation packages in the first place due to nix's issues with nested outputs. So separating with a hyphen allows for easy debugging. And with the flk script, it really only affects someone who manually builds the activation package and even that isn't that bad.

@nrdxp
Copy link
Collaborator

nrdxp commented Mar 14, 2021

This already is looking amazing, once you get it ready for review and it's approved, you can merge it yourself when your confident it's done. Good work.

bors delegate+

@bors
Copy link
Contributor

bors bot commented Mar 14, 2021

✌️ Pacman99 can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@Pacman99
Copy link
Member Author

This already is looking amazing, once you get it ready for review and it's approved, you can merge it yourself when your confident it's done. Good work.

Wow thats cool! Thanks! I think I might try to get the sharedModules and extraSpecialArgs PR backported to 20.09 in home-manager so I can get this merged sooner.

@nrdxp
Copy link
Collaborator

nrdxp commented Mar 14, 2021

Alternatively, I was thinking of upgrading the nixos flake to nixos-unstable for the time being, at least until the next stable release.

@Pacman99
Copy link
Member Author

Ohh that makes things simpler. Can you do that as a separate commit? There might be other things to fix after upgrading, that doesn't make sense to include in this PR.

@nrdxp
Copy link
Collaborator

nrdxp commented Mar 14, 2021

Yeah, I'll try to manage it soon. I'm working on cleaning up some other things as well. Hopefully by the end of the day.

@Pacman99
Copy link
Member Author

I dropped the commit updating the flake, so this should theoretically merge cleanly once the flake is updated. But I can fix any other conflicts once you upgrade.

@Pacman99 Pacman99 marked this pull request as ready for review March 14, 2021 23:48
@Pacman99
Copy link
Member Author

I added some more defaults to the hmConfig. Although, optimally, that would not be needed with #127.

@nrdxp
Copy link
Collaborator

nrdxp commented Mar 15, 2021

I've update my local config to nixos-unstable and it seems to be working fine, after some fixes. However, I can't push it up yet, as it somehow broke the ci runner and all tests are failing with an exception. Once I figure it out, I'll push it.

@Pacman99
Copy link
Member Author

I think the check for devshell on aarch64 will fail. Because nix flake check tries to evaluate it(not build) and nixUnstable is still broken for aarch64 on nixos-unstable - hydra hasn't updated the channel with the fix yet.

@nrdxp
Copy link
Collaborator

nrdxp commented Mar 15, 2021

Yeah I saw that, but actually every single derivation is failing due to an exception in hercules-ci's cpp code. I am gonna try reverting the update to the hercules flake and see if that helps. If not, it may be related to the update to Nix. I believe I can work around it either way, hopefully won't take too long.

@nrdxp
Copy link
Collaborator

nrdxp commented Mar 16, 2021

It seems fixing the ci-agent is going to be slightly more involved than I initially suspected. hercules-ci/hercules-ci-agent#291

We may have to rely on upstream to patch it before it works. I was thinking I could use a container as a workaround, but the containers seem to use the hosts nix-daemon, so it didn't pan out.

So the alternatives seem to be:

  • to simply update the revision and run an older version on the ci-runner for now until a fix is found (will probably have to go with this one)
  • let it stay broken and manually merge this and other PR's hoping a bunch of stuff doesn't break (probably not this one)
  • use a virtual machine (might work but performance may suffer, I'll experiment)

@Pacman99
Copy link
Member Author

Is the ci runner on an old revision evaluate the checks ok? I think the first option is the best so at least we can keep changing things.

@nrdxp
Copy link
Collaborator

nrdxp commented Mar 16, 2021

yes it seems to be working again after downgrading. Assuming all these checks pass, I'll push the changes with the nixos-unstable update.

@nrdxp
Copy link
Collaborator

nrdxp commented Mar 16, 2021

Before we merge this, be sure to rebase after I push the update, because I'm also going to make a change to the bors.toml. After merging my last PR as a squash merge, I decided I don't like it, and am going to use a regular merge commit instead. BORS pulls the toml from the PR and not the main branch so it's important you have the new one.

@Pacman99
Copy link
Member Author

Ok thats makes sense, will do. Yeah squash merges aren't great for larger PR's.

@nrdxp
Copy link
Collaborator

nrdxp commented Mar 20, 2021

besides the merge conflicts, is this still blocked?

@Pacman99
Copy link
Member Author

I rebased and fixed conflicts. But I can't actually test this new version, so after the update I will have to rebase again and run through any errors that may have come up after the rebase.

Also I switched to use user@host pairs based on the pr in home-manager that adds --flake support to home manager: nix-community/home-manager#1856.

Copy link
Collaborator

@nrdxp nrdxp left a comment

Choose a reason for hiding this comment

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

My review was pretty brief on this as I don't really have a ton of time and don't want to hold it up any longer. I've already delegated merge permission to you, so if you've tested it and believe it is ready. Please go ahead and merge it.

@nrdxp
Copy link
Collaborator

nrdxp commented Mar 23, 2021

bors try

bors bot added a commit that referenced this pull request Mar 23, 2021
@bors
Copy link
Contributor

bors bot commented Mar 23, 2021

try

Build failed:

@Pacman99
Copy link
Member Author

This is ready for final review. I updated the home-manager input in this PR(first commit), and rebased with core. Checks succeed for me. I added some docs to users/README.md, so I think thats the last thing to check - @blaggacao I would appreciate your input for that, you're usually good with docs..
bors try

bors bot added a commit that referenced this pull request Mar 23, 2021
@bors
Copy link
Contributor

bors bot commented Mar 23, 2021

try

Build succeeded:

flake.nix Outdated Show resolved Hide resolved
Copy link
Collaborator

@nrdxp nrdxp left a comment

Choose a reason for hiding this comment

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

I don't think any of my comments are major blockers. Overall this looks great. Good job on another great PR.

CHANGELOG.md Outdated
@@ -43,6 +43,7 @@
- iso: avoid systemd service startup [\#202](https://github.com/divnix/devos/pull/202)
- hosts/devosSystem: pass modules as attrset [\#198](https://github.com/divnix/devos/pull/198)
- doc: enact bootstrapping section [\#196](https://github.com/divnix/devos/pull/196)
- flake: nixos -\> nixos-unstable [\#192](https://github.com/divnix/devos/pull/192)
Copy link
Collaborator

Choose a reason for hiding this comment

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

why is this here? Isn't it already in core?

Copy link
Member Author

Choose a reason for hiding this comment

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

rebase error, fixed

@Pacman99
Copy link
Member Author

I'm going to go ahead and merge, this should be complete.
bors r+

@bors
Copy link
Contributor

bors bot commented Mar 23, 2021

Build succeeded:

@bors bors bot merged commit 74c23ce into divnix:core Mar 23, 2021
@Pacman99 Pacman99 deleted the first-user branch March 23, 2021 17:21
Copy link
Collaborator

@nrdxp nrdxp left a comment

Choose a reason for hiding this comment

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

We are gonna need a follow up, cleanup/enhancement PR. I wouldn't mind doing it, if nobody else wishes to do so. I've mentions a copule places that need fixing.

home-manager.useUserPackages = lib.mkForce false;
home-manager.sharedModules = [
{
home.packages = config.environment.systemPackages;
Copy link
Collaborator

Choose a reason for hiding this comment

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

hindsight review:

As it turns out, this may be a bit too aggressive. We may have to have a follow up PR to remove it, as it includes a lot of unrelated system packages and, worse, causes package conflicts in the community branch.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah thats fine we can remove that line. It worked for me and I didn't think it would cause any issues.

useGlobalPkgs = true;
useUserPackages = true;

extraSpecialArgs = extern.userSpecialArgs // { suites = suites.user; };
Copy link
Collaborator

Choose a reason for hiding this comment

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

We may need to add inherit (config.nixpkgs) pkgs as home-manager doesn't seem to have a pkgs argument. This may be a bug upstream however, as I believe home-manager is supposed to pass in packages. In practice though, at least with this implementation, I had to add a pkgs arg to get doom-emacs to work, for example.

Copy link
Member Author

Choose a reason for hiding this comment

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

Are you sure thats the problem? Because home-manager already does that when useGlobalPkgs is true.

Copy link
Member Author

Choose a reason for hiding this comment

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

" using the system configuration's pkgs
argument in Home Manager. This disables the Home Manager
options nixpkgs.*"
^ from hm nixos module

Copy link
Collaborator

@nrdxp nrdxp Mar 24, 2021

Choose a reason for hiding this comment

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

I ran into these issues while trying to merge this into community. I just pushed the merge so you should now be able to reproduce by simply checking out the latest community branch and running flk home NixOS nixos

Copy link
Collaborator

@nrdxp nrdxp Mar 24, 2021

Choose a reason for hiding this comment

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

Perhaps shared modules don't get passed a pkgs arg, since that is how doom-emacs is entering the configuration. Not sure if this intentional by upstream or a bug. I'll search hm issue tracker to see if I can find some additional context.

Copy link
Member Author

Choose a reason for hiding this comment

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

Could be true, I tried adding pkgs to the hm section in users/nixos and used it to add vim to home.packages and that works fine. So your theory does make sense.

Copy link
Member Author

@Pacman99 Pacman99 Mar 24, 2021

Choose a reason for hiding this comment

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

In home manager, the ways pkgs is set is using _module.args.pkgs in home-manager/modules/modules.nix. And I wonder if doesn't get passed to modules that were imported before that. But that doesn't make sense to me, since the module system should be recursive.

Copy link
Collaborator

@nrdxp nrdxp Mar 24, 2021

Choose a reason for hiding this comment

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

I believe I've isolated the problem. Gonna fix and test locally then will link to an new home-manager PR if I'm correct.

Copy link
Collaborator

Choose a reason for hiding this comment

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

okay, I've offered a minimally invasive solution in nix-community/home-manager#1879

@Pacman99
Copy link
Member Author

We are gonna need a follow up, cleanup/enhancement PR. I wouldn't mind doing it, if nobody else wishes to do so. I've mentions a copule places that need fixing.

I likely won't be able to test the fixes since I can't reproduce the issues.

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