mirror of
https://github.com/xmonad/xmonad-contrib.git
synced 2025-08-01 12:41:52 -07:00
Merge pull request #711 from LSLeary/flake-module
Apply Patch in Nix Flake; Enable Configuration (Contrib Edition)
This commit is contained in:
52
NIX.md
52
NIX.md
@@ -15,3 +15,55 @@ pkgs: devInputs: devInputs // {
|
|||||||
[ cabal-install hlint ghcid ormolu implicit-hie haskell-language-server ];
|
[ cabal-install hlint ghcid ormolu implicit-hie haskell-language-server ];
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## NixOS Modules
|
||||||
|
|
||||||
|
The core and contrib flakes provide NixOS configuration modules.
|
||||||
|
You can bring them into your system flake like so:
|
||||||
|
|
||||||
|
```nix
|
||||||
|
{
|
||||||
|
inputs = {
|
||||||
|
nixpkgs.url = github:NixOS/nixpkgs/nixos-<version>;
|
||||||
|
xmonad.url = github:xmonad/xmonad;
|
||||||
|
xmonad-contrib.url = github:xmonad/xmonad-contrib;
|
||||||
|
};
|
||||||
|
|
||||||
|
outputs = { self, nixpkgs, xmonad, xmonad-contrib }: {
|
||||||
|
nixosConfigurations.<hostname> = nixpkgs.lib.nixosSystem rec {
|
||||||
|
system = <arch>;
|
||||||
|
modules = [
|
||||||
|
./configuration.nix
|
||||||
|
xmonad.nixosModule
|
||||||
|
xmonad-contrib.nixosModule
|
||||||
|
];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
Then you can set the provided options in your `configuration.nix` under `flake`:
|
||||||
|
|
||||||
|
```nix
|
||||||
|
services.xserver.windowManager.xmonad = {
|
||||||
|
enable = true;
|
||||||
|
enableContribAndExtras = true;
|
||||||
|
flake = {
|
||||||
|
enable = true;
|
||||||
|
# prefix = "unstable";
|
||||||
|
compiler = "ghc921";
|
||||||
|
};
|
||||||
|
};
|
||||||
|
```
|
||||||
|
|
||||||
|
This will use core and contrib from git for your system xmonad, building your
|
||||||
|
config with the compiler of your choice.
|
||||||
|
|
||||||
|
With the flake enabled, the `xmonad.haskellPackages` option is not used directly,
|
||||||
|
and is instead set by the `flake.compiler` option. When `compiler` is unset,
|
||||||
|
the default `pkgs.haskellPackages` is used.
|
||||||
|
|
||||||
|
The `prefix` option is used if you wish to select your haskell packages from
|
||||||
|
within, e.g., unstable overlaid into `pkgs` as `pkgs.unstable`.
|
||||||
|
|
||||||
|
See the flakes themselves and nix flake documentation for full detail.
|
||||||
|
28
flake.nix
28
flake.nix
@@ -1,4 +1,5 @@
|
|||||||
# This file is maintained by @IvanMalison (github)
|
# This file is maintained by @IvanMalison and @LSLeary (github)
|
||||||
|
# See NIX.md for an overview of module usage.
|
||||||
{
|
{
|
||||||
inputs = {
|
inputs = {
|
||||||
flake-utils.url = github:numtide/flake-utils;
|
flake-utils.url = github:numtide/flake-utils;
|
||||||
@@ -6,17 +7,24 @@
|
|||||||
xmonad.url = github:xmonad/xmonad;
|
xmonad.url = github:xmonad/xmonad;
|
||||||
};
|
};
|
||||||
outputs = { self, flake-utils, nixpkgs, git-ignore-nix, xmonad }:
|
outputs = { self, flake-utils, nixpkgs, git-ignore-nix, xmonad }:
|
||||||
|
with xmonad.lib;
|
||||||
let
|
let
|
||||||
overlay = final: prev: {
|
hoverlay = final: prev: hself: hsuper: {
|
||||||
haskellPackages = prev.haskellPackages.override (old: {
|
xmonad-contrib = hself.callCabal2nix "xmonad-contrib"
|
||||||
overrides = prev.lib.composeExtensions (old.overrides or (_: _: {}))
|
(git-ignore-nix.lib.gitignoreSource ./.) { };
|
||||||
(hself: hsuper: {
|
|
||||||
xmonad-contrib =
|
|
||||||
hself.callCabal2nix "xmonad-contrib" (git-ignore-nix.lib.gitignoreSource ./.) { };
|
|
||||||
});
|
|
||||||
});
|
|
||||||
};
|
};
|
||||||
|
overlay = fromHOL hoverlay { };
|
||||||
overlays = xmonad.overlays ++ [ overlay ];
|
overlays = xmonad.overlays ++ [ overlay ];
|
||||||
|
nixosModule = { config, lib, ... }: with lib;
|
||||||
|
let
|
||||||
|
cfg = config.services.xserver.windowManager.xmonad;
|
||||||
|
comp = { inherit (cfg.flake) prefix compiler; };
|
||||||
|
in {
|
||||||
|
config = mkIf (cfg.flake.enable && cfg.enableContribAndExtras) {
|
||||||
|
nixpkgs.overlays = [ (fromHOL hoverlay comp) ];
|
||||||
|
};
|
||||||
|
};
|
||||||
|
nixosModules = xmonad.nixosModules ++ [ nixosModule ];
|
||||||
in flake-utils.lib.eachDefaultSystem (system:
|
in flake-utils.lib.eachDefaultSystem (system:
|
||||||
let
|
let
|
||||||
pkgs = import nixpkgs { inherit system overlays; };
|
pkgs = import nixpkgs { inherit system overlays; };
|
||||||
@@ -31,5 +39,5 @@
|
|||||||
nativeBuildInputs = [ pkgs.cabal-install ];
|
nativeBuildInputs = [ pkgs.cabal-install ];
|
||||||
});
|
});
|
||||||
defaultPackage = pkgs.haskellPackages.xmonad-contrib;
|
defaultPackage = pkgs.haskellPackages.xmonad-contrib;
|
||||||
}) // { inherit overlay overlays; } ;
|
}) // { inherit hoverlay overlay overlays nixosModule nixosModules; } ;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user