mirror of
https://github.com/xmonad/xmonad.git
synced 2025-08-15 03:55:45 -07:00
Merge pull request #392 from LSLeary/flake-module
Apply Patch in Nix Flake; Enable Configuration
This commit is contained in:
73
flake.nix
73
flake.nix
@@ -1,20 +1,70 @@
|
|||||||
# This file is maintained by @IvanMalison (github)
|
# This file is maintained by @IvanMalison and @LSLeary (github)
|
||||||
|
# See xmonad-contrib/NIX.md for an overview of module usage.
|
||||||
{
|
{
|
||||||
inputs = {
|
inputs = {
|
||||||
flake-utils.url = github:numtide/flake-utils;
|
flake-utils.url = github:numtide/flake-utils;
|
||||||
git-ignore-nix.url = github:hercules-ci/gitignore.nix/master;
|
git-ignore-nix.url = github:hercules-ci/gitignore.nix/master;
|
||||||
|
unstable.url = github:NixOS/nixpkgs/nixos-unstable;
|
||||||
};
|
};
|
||||||
outputs = { self, flake-utils, nixpkgs, git-ignore-nix }:
|
outputs = { self, flake-utils, nixpkgs, unstable, git-ignore-nix }:
|
||||||
let
|
let
|
||||||
overlay = final: prev: {
|
hpath = { prefix ? null, compiler ? null }:
|
||||||
haskellPackages = prev.haskellPackages.override (old: {
|
(if prefix == null then [] else [ prefix ]) ++
|
||||||
overrides = prev.lib.composeExtensions (old.overrides or (_: _: {}))
|
(if compiler == null
|
||||||
(hself: hsuper: {
|
then [ "haskellPackages" ]
|
||||||
xmonad = hself.callCabal2nix "xmonad" (git-ignore-nix.lib.gitignoreSource ./.) { };
|
else [ "haskell" "packages" compiler ]
|
||||||
});
|
);
|
||||||
});
|
fromHOL = hol: comp: final: prev: with prev.lib; with attrsets;
|
||||||
|
setAttrByPath (hpath comp)
|
||||||
|
((getAttrFromPath (hpath comp) prev).override (old: {
|
||||||
|
overrides = composeExtensions (old.overrides or (_: _: {}))
|
||||||
|
(hol final prev);
|
||||||
|
}));
|
||||||
|
patch = unstable
|
||||||
|
+ "/pkgs/development/haskell-modules/patches/xmonad_0_17_0-nix.patch";
|
||||||
|
hoverlay = final: prev: hself: hsuper:
|
||||||
|
with prev.haskell.lib.compose; {
|
||||||
|
xmonad = appendPatch patch
|
||||||
|
(hself.callCabal2nix "xmonad"
|
||||||
|
(git-ignore-nix.lib.gitignoreSource ./.) { });
|
||||||
};
|
};
|
||||||
|
overlay = fromHOL hoverlay { };
|
||||||
overlays = [ overlay ];
|
overlays = [ overlay ];
|
||||||
|
nixosModule = { config, pkgs, lib, ... }: with lib; with attrsets;
|
||||||
|
let
|
||||||
|
cfg = config.services.xserver.windowManager.xmonad.flake;
|
||||||
|
comp = { inherit (cfg) prefix compiler; };
|
||||||
|
in {
|
||||||
|
options = {
|
||||||
|
services.xserver.windowManager.xmonad.flake = with types; {
|
||||||
|
enable = mkEnableOption "flake";
|
||||||
|
prefix = mkOption {
|
||||||
|
default = null;
|
||||||
|
type = nullOr string;
|
||||||
|
example = literalExpression "\"unstable\"";
|
||||||
|
description = ''
|
||||||
|
Specify a nested alternative <literal>pkgs</literal> by attrName.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
compiler = mkOption {
|
||||||
|
default = null;
|
||||||
|
type = nullOr string;
|
||||||
|
example = literalExpression "\"ghc922\"";
|
||||||
|
description = ''
|
||||||
|
Which compiler to build xmonad with.
|
||||||
|
Must be an attribute of <literal>pkgs.haskell.packages</literal>.
|
||||||
|
Sets <option>xmonad.haskellPackages</option> to match.
|
||||||
|
'';
|
||||||
|
};
|
||||||
|
};
|
||||||
|
};
|
||||||
|
config = mkIf cfg.enable {
|
||||||
|
nixpkgs.overlays = [ (fromHOL hoverlay comp) ];
|
||||||
|
services.xserver.windowManager.xmonad.haskellPackages =
|
||||||
|
getAttrFromPath (hpath comp) pkgs;
|
||||||
|
};
|
||||||
|
};
|
||||||
|
nixosModules = [ nixosModule ];
|
||||||
in flake-utils.lib.eachDefaultSystem (system:
|
in flake-utils.lib.eachDefaultSystem (system:
|
||||||
let pkgs = import nixpkgs { inherit system overlays; };
|
let pkgs = import nixpkgs { inherit system overlays; };
|
||||||
in
|
in
|
||||||
@@ -23,5 +73,8 @@
|
|||||||
packages = p: [ p.xmonad ];
|
packages = p: [ p.xmonad ];
|
||||||
};
|
};
|
||||||
defaultPackage = pkgs.haskellPackages.xmonad;
|
defaultPackage = pkgs.haskellPackages.xmonad;
|
||||||
}) // { inherit overlay overlays; } ;
|
}) // {
|
||||||
|
inherit hoverlay overlay overlays nixosModule nixosModules;
|
||||||
|
lib = { inherit hpath fromHOL; };
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user