From 4cf804880711e27e752ec2a7c6472f14abb8efab Mon Sep 17 00:00:00 2001 From: Timothy DeHerrera Date: Mon, 6 Jan 2020 00:01:00 -0700 Subject: [PATCH] overlays: init overlays directory Overlays now live globally in the overlays directory. They will be pulled into the flake and the rest of your configuration automatically from there. --- README.md | 9 +++++++- configuration.nix | 7 ++++-- flake.nix | 9 +++++--- hosts/default.nix | 1 + overlays/cursor.nix | 7 ++++++ overlays/kakoune.nix | 15 ++++++++++++ overlays/pkgs.nix | 1 + overlays/qute.nix | 6 +++++ overlays/redshift.nix | 11 +++++++++ overlays/wl-clipboard.nix | 11 +++++++++ profiles/develop/kakoune/default.nix | 27 ---------------------- profiles/graphical/default.nix | 17 -------------- profiles/graphical/qutebrowser/default.nix | 8 ------- profiles/graphical/sway/default.nix | 21 ----------------- 14 files changed, 71 insertions(+), 79 deletions(-) create mode 100644 overlays/cursor.nix create mode 100644 overlays/kakoune.nix create mode 120000 overlays/pkgs.nix create mode 100644 overlays/qute.nix create mode 100644 overlays/redshift.nix create mode 100644 overlays/wl-clipboard.nix diff --git a/README.md b/README.md index fee6d61..b51fc7f 100644 --- a/README.md +++ b/README.md @@ -20,6 +20,8 @@ git checkout -b $new_branch template # generate hardware config nixos-generate-config --show-hardware-config > ./hosts/${new_host}.nix +# ensure configuration lives in expected location +ln -s $PWD /etc/nixos # `rebuild` wrapper for `nix build` bypassing `nixos-rebuild` # Usage: rebuild [host] {switch|boot|test|dry-activate} @@ -146,13 +148,18 @@ folder by default. To keep [profiles](profiles) reusable across configurations, secrets should only be imported from the `users` or [`hosts`](hosts) directory. -## Modules and Packages +## Modules, Packages and Overlays All expressions in both [modules/defualt.nix](modules/default.nix) and [pkgs/default.nix](pkgs/default.nix) are available globally, anywhere else in the repo. They are additionally included in the `nixosModules` or `overlays` flake outputs. Packages can manually be added to [flake.nix](flake.nix) for inclusion in the `packages` output as well. +All overlays should be defined in the [overlays](overlays) directory. They will +be automatically pulled in for use by all configurations. Nix command line tools +will be able to read overlays from here as well since it is set as +`nixpkgs-overlays` in `NIX_PATH`. + The directory structure is identical to nixpkgs to provide a kind of staging area for any modules or packages we might be wanting to merge there later. If your not familiar or can't be bothered, simply dropping a valid nix file and pointing the diff --git a/configuration.nix b/configuration.nix index 73cf215..f854201 100644 --- a/configuration.nix +++ b/configuration.nix @@ -19,8 +19,11 @@ in { ] ++ config; networking.hostName = hostname; - nix.nixPath = - [ "nixpkgs=${}" "nixos-config=/etc/nixos/configuration.nix" ]; + nix.nixPath = [ + "nixpkgs=${}" + "nixos-config=/etc/nixos/configuration.nix" + "nixpkgs-overlays=/etc/nixos/overlays" + ]; nixpkgs.overlays = lib.singleton (import ./pkgs); } diff --git a/flake.nix b/flake.nix index 97952cc..d607c02 100644 --- a/flake.nix +++ b/flake.nix @@ -3,12 +3,12 @@ epoch = 201909; - inputs.nixpkgs.url = "github:nrdxp/nixpkgs/fork"; + inputs.nixpkgs.url = "github:nrdxp/nixpkgs/fork-010520"; inputs.home.url = "github:nrdxp/home-manager/flakes"; outputs = args@{ self, home, nixpkgs }: let - inherit (builtins) listToAttrs baseNameOf; + inherit (builtins) listToAttrs baseNameOf attrNames readDir; inherit (nixpkgs.lib) removeSuffix; pkgs = import nixpkgs { @@ -22,7 +22,10 @@ overlay = import ./pkgs; - overlays = [ self.overlay ]; + overlays = let + overlays = map (name: import (./overlays + "/${name}")) + (attrNames (readDir ./overlays)); + in overlays; packages.x86_64-linux = { inherit (pkgs) sddm-chili dejavu_nerdfont purs; diff --git a/hosts/default.nix b/hosts/default.nix index 7915817..0ecedae 100644 --- a/hosts/default.nix +++ b/hosts/default.nix @@ -20,6 +20,7 @@ let nix.nixPath = [ "nixpkgs=${nixpkgs}" "nixos-config=/etc/nixos/configuration.nix" + "nixpkgs-overlays=/etc/nixos/overlays" ]; system.configurationRevision = self.rev; diff --git a/overlays/cursor.nix b/overlays/cursor.nix new file mode 100644 index 0000000..b73a061 --- /dev/null +++ b/overlays/cursor.nix @@ -0,0 +1,7 @@ +final: prev: { + # set default cursor theme when installed + cursor = prev.writeTextDir "share/icons/default/index.theme" '' + [icon theme] + Inherits=Adwaita + ''; +} diff --git a/overlays/kakoune.nix b/overlays/kakoune.nix new file mode 100644 index 0000000..4e4aa52 --- /dev/null +++ b/overlays/kakoune.nix @@ -0,0 +1,15 @@ +final: prev: { + kakoune = prev.kakoune.override { + configure.plugins = with final.kakounePlugins; [ + (kak-fzf.override { fzf = final.skim; }) + kak-auto-pairs + kak-buffers + kak-powerline + ]; + }; + + # wrapper to specify config dir + kakoune-config = prev.writeShellScriptBin "k" '' + XDG_CONFIG_HOME=/etc/xdg exec ${final.kakoune}/bin/kak "$@" + ''; +} diff --git a/overlays/pkgs.nix b/overlays/pkgs.nix new file mode 120000 index 0000000..f87a3ef --- /dev/null +++ b/overlays/pkgs.nix @@ -0,0 +1 @@ +../pkgs/default.nix \ No newline at end of file diff --git a/overlays/qute.nix b/overlays/qute.nix new file mode 100644 index 0000000..92165ab --- /dev/null +++ b/overlays/qute.nix @@ -0,0 +1,6 @@ +final: prev: { + # wrapper to specify config file + qute = prev.writeShellScriptBin "qute" '' + exec ${prev.qutebrowser}/bin/qutebrowser -C /etc/xdg/qutebrowser/config.py "$@" + ''; +} diff --git a/overlays/redshift.nix b/overlays/redshift.nix new file mode 100644 index 0000000..a199893 --- /dev/null +++ b/overlays/redshift.nix @@ -0,0 +1,11 @@ +final: prev: { + # with sway/wayland support + redshift = prev.redshift.overrideAttrs (o: { + src = prev.fetchFromGitHub { + owner = "CameronNemo"; + repo = "redshift"; + rev = "39c162ca487a59857c2eac231318f4b28855798b"; + sha256 = "1in27draskwwi097wiam26bx2szcf58297am3gkyng1ms3rz6i58"; + }; + }); +} diff --git a/overlays/wl-clipboard.nix b/overlays/wl-clipboard.nix new file mode 100644 index 0000000..d9f288c --- /dev/null +++ b/overlays/wl-clipboard.nix @@ -0,0 +1,11 @@ +final: prev: { + # nixpkgs version causing issues for me + wl-clipboard = prev.wl-clipboard.overrideAttrs (o: { + src = prev.fetchFromGitHub { + owner = "bugaevc"; + repo = "wl-clipboard"; + rev = "c010972e6b0d2eb3002c49a6a1b5620ff5f7c910"; + sha256 = "020l3jy9gsj6gablwdfzp1wfa8yblay3axdjc56i9q8pbhz7g12j"; + }; + }); +} diff --git a/profiles/develop/kakoune/default.nix b/profiles/develop/kakoune/default.nix index f988b2e..5bb67ea 100644 --- a/profiles/develop/kakoune/default.nix +++ b/profiles/develop/kakoune/default.nix @@ -17,31 +17,4 @@ "xdg/kak/autoload/default".source = "${pkgs.kakoune-unwrapped}/share/kak/rc"; }; - - nixpkgs.overlays = let - kak = final: prev: { - kakoune = prev.kakoune.override { - configure.plugins = with prev.kakounePlugins; [ - (kak-fzf.override { fzf = prev.skim; }) - kak-auto-pairs - kak-buffers - kak-powerline - ]; - }; - - kakoune-config = prev.writeShellScriptBin "k" '' - XDG_CONFIG_HOME=/etc/xdg exec ${final.kakoune}/bin/kak "$@" - ''; - - kakoune-unwrapped = prev.kakoune-unwrapped.overrideAttrs (o: rec { - version = "2019.12.10"; - src = prev.fetchFromGitHub { - repo = "kakoune"; - owner = "mawww"; - rev = "v${version}"; - hash = "sha256-TnRQ73bIQGavXNp+wrKtYHgGem+R6JDWt333z2izYzE="; - }; - }); - }; - in [ kak ]; } diff --git a/profiles/graphical/default.nix b/profiles/graphical/default.nix index fd80f6e..2371bbc 100644 --- a/profiles/graphical/default.nix +++ b/profiles/graphical/default.nix @@ -64,21 +64,4 @@ in { theme = "chili"; }; }; - - nixpkgs.overlays = let - overlay = final: prev: { - cursor = prev.writeTextDir "share/icons/default/index.theme" '' - [icon theme] - Inherits=Adwaita - ''; - - ffmpeg-full = prev.ffmpeg-full.override { - svt-av1 = prev.svt-av1; - dav1d = prev.dav1d; - libaom = null; - opencore-amr = null; - libopus = prev.libopus; - }; - }; - in [ overlay ]; } diff --git a/profiles/graphical/qutebrowser/default.nix b/profiles/graphical/qutebrowser/default.nix index b6d2653..f6709bb 100644 --- a/profiles/graphical/qutebrowser/default.nix +++ b/profiles/graphical/qutebrowser/default.nix @@ -16,12 +16,4 @@ in { systemPackages = with pkgs; [ qute qutebrowser mpv youtubeDL ]; }; - - nixpkgs.overlays = let - overlay = final: prev: { - qute = prev.writeShellScriptBin "qute" '' - exec ${prev.qutebrowser}/bin/qutebrowser -C /etc/xdg/qutebrowser/config.py "$@" - ''; - }; - in [ overlay ]; } diff --git a/profiles/graphical/sway/default.nix b/profiles/graphical/sway/default.nix index ea256dc..746d50f 100644 --- a/profiles/graphical/sway/default.nix +++ b/profiles/graphical/sway/default.nix @@ -87,25 +87,4 @@ in { RestartSec = 3; }; }; - - nixpkgs.overlays = let - overlay = final: prev: { - redshift = prev.redshift.overrideAttrs (o: { - src = prev.fetchFromGitHub { - owner = "CameronNemo"; - repo = "redshift"; - rev = "39c162ca487a59857c2eac231318f4b28855798b"; - sha256 = "1in27draskwwi097wiam26bx2szcf58297am3gkyng1ms3rz6i58"; - }; - }); - wl-clipboard = prev.wl-clipboard.overrideAttrs (o: { - src = prev.fetchFromGitHub { - owner = "bugaevc"; - repo = "wl-clipboard"; - rev = "c010972e6b0d2eb3002c49a6a1b5620ff5f7c910"; - sha256 = "020l3jy9gsj6gablwdfzp1wfa8yblay3axdjc56i9q8pbhz7g12j"; - }; - }); - }; - in [ overlay ]; }