Skip to content

XMonad: enable configured recompile#155478

Merged
Lassulus merged 3 commits intoNixOS:masterfrom
ivanbrennan:xmonad-enable-configured-recompile
Jan 20, 2022
Merged

XMonad: enable configured recompile#155478
Lassulus merged 3 commits intoNixOS:masterfrom
ivanbrennan:xmonad-enable-configured-recompile

Conversation

@ivanbrennan
Copy link
Member

@ivanbrennan ivanbrennan commented Jan 18, 2022

Motivation for this change

The NixOS xmonad module builds an xmonad binary that's not capable of recompiling xmonad with a local config (e.g. ~/.config/xmonad/xmonad.hs) if the module's config option was set. That capability is useful when trying out changes to your config, but since it increases the closure size, it should be opt-in.

Add a new module option, enableConfiguredRecompile, to opt into including the necessary Haskell dependencies in the binary's environment, even if the config option was set (they're already included if it was not set, to allow xmonad to recompile using an xmonad config not managed by nixos).

This behavior was previously added unconditionally (#107696), and later removed (#143886) due to its affect on closure size and the reasonable argument that it's not a common enough use-case.

Additionally, the example config will not work with XMonad 0.17.0. Provide an example of how to configure 0.17.0

Things done
  • Built on platform(s)
    • x86_64-linux
    • aarch64-linux
    • x86_64-darwin
    • aarch64-darwin
  • For non-Linux: Is sandbox = true set in nix.conf? (See Nix manual)
  • Tested, as applicable:
  • Tested compilation of all packages that depend on this change using nix-shell -p nixpkgs-review --run "nixpkgs-review rev HEAD". Note: all changes have to be committed, also see nixpkgs-review usage
  • Tested basic functionality of all binary files (usually in ./result/bin/)
  • 22.05 Release Notes (or backporting 21.11 Release notes)
    • (Package updates) Added a release notes entry if the change is major or breaking
    • (Module updates) Added a release notes entry if the change is significant
    • (Module addition) Added a release notes entry if adding a new NixOS module
    • (Release notes changes) Ran nixos/doc/manual/md-to-db.sh to update generated release notes
  • Fits CONTRIBUTING.md.

Commit 9a5b5d9 added Haskell
dependencies (GHC and packages) to the xmonad binary's environment even
if xmonad had been preconfigured (via the "config" option). The intent
was to enable one-off recompiling using a local config file (e.g.
~/.config/xmonad/xmonad.hs), so the user can get quick feedback while
developing their config.

While this works, it may not be a common use-case, and it requires some
careful crafting in xmonad.hs itself. On top of that, it significantly
increases the size of the closure.

Given all that, commit b69d9d3 removed
GHC and packages from the binary's environment.

But there are still those among us who want to be able to recompile from
a preconfigured xmonad, so let's provide a way to opt-into configured
recompilation.
@github-actions github-actions bot added 6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` labels Jan 18, 2022
@ofborg ofborg bot added 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux. labels Jan 18, 2022
@Synthetica9
Copy link
Member

Would it be possible to test this in nixosTests.xmonad?

@Lassulus
Copy link
Member

code looks good, old behavior seems to be still ok. an addition to the test would be nice thought

@ivanbrennan
Copy link
Member Author

ivanbrennan commented Jan 18, 2022

@Synthetica9 @Lassulus Thanks, I'll take a look at adding tests. I haven't written nixos tests before, so I'm referencing these docs (my mistake, I meant these docs 😁 ).

@Lassulus
Copy link
Member

I guess you can just extend https://github.com/NixOS/nixpkgs/blob/master/nixos/tests/xmonad.nix to have the new option enabled and create a xmonad.hs in the correct location, recompile it and check if the new version was compiled/applied

Update the example config to show a working example for xmonad 0.17.0, which
added an argument to the `launch` function and adjusted the location of the
recompiled binary.
Add test coverage for the enableConfiguredRecompile option, checking
that we can compile and exec a new xmonad from a user's local config, as
well as restart the originally configured xmonad.

As I needed a reliable way to wait for recompilation to finish before
proceeding with subsequent test steps, I adjusted the startup behavior
to write a file ("oldXMonad" or "newXMonad") to /etc upon startup, and
replaced some "sleep" calls with "wait_for_file".
@ivanbrennan ivanbrennan force-pushed the xmonad-enable-configured-recompile branch from 90090b6 to 44af29e Compare January 20, 2022 06:54
@Lassulus
Copy link
Member

alright, the test ran on my system, and instead of sleeping we wait for xmonad to touch files which seems more robust.

@Lassulus Lassulus merged commit 634bcb8 into NixOS:master Jan 20, 2022
@Synthetica9
Copy link
Member

I hope these sleeps aren't too strict on really congested build machines, if this starts failing we could do machine.wait_until_succeeds/-fails,

@ivanbrennan
Copy link
Member Author

I hope these sleeps aren't too strict on really congested build machines, if this starts failing we could do machine.wait_until_succeeds/-fails,

@Synthetica9 Good point. I'll make a followup PR to clean these sleeps up.

@ivanbrennan ivanbrennan deleted the xmonad-enable-configured-recompile branch January 21, 2022 18:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

6.topic: nixos Issues or PRs affecting NixOS modules, or package usability issues specific to NixOS 8.has: module (update) This PR changes an existing module in `nixos/` 10.rebuild-darwin: 0 This PR does not cause any packages to rebuild on Darwin. 10.rebuild-linux: 1-10 This PR causes between 1 and 10 packages to rebuild on Linux.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants